DEV Community

KateMLady
KateMLady

Posted on

Game strategies tree

In this and future posts I will add screenshots of Jupyter Notebook for clarity. The GitHub link will help you find the code if needed.

Image description

Classes and matrices allow you to maneuver the data structure in any language, Jupyter Noterbook makes it possible to write capacious and accurate algorithms, without the IDLE environment.

A strategy tree is needed for:

  • Creating vertices of variants of a matrix game - the task of finding the optimal winning strategy given the initial data
  • From game to game, optimize the strategy tree so as to maximize winnings with your opponent
  • Solving such an “abstract” class of problems helps to immerse oneself in matrix patterns and the peculiarities of working with them. And it's fun!

Image description

In the screenshots I show only a systematic structure; you don’t have to pay detailed attention to variables and data. The generation of vertex components is created separately for each level of the graph. Sequentially filling a dynamic array in Python.

Image description

Let's see the result (it's better to read the topic on the Internet yourself and look at the example on my blog): by optimizing the game from vertex to vertex, we find a winning strategy and the path from the vertices to it.

Top comments (0)