Search code examples
algorithmartificial-intelligenceminimax

Running Minimax/Expectimax on the next state chosen


If I run a minimax/expectimax for a current state or the start state, and suppose the root has three children (chance nodes) and runs the minimax/expectimax algorithm. Suppose, it finds the optimal terminal node and in turn gets the optimal child of the root. That means it'll choose that particular move that leads to that terminal state which has the optimal utility. And we call the path from the root to that terminal state , path P.

And we assume the opposite player also makes a move as predicted by the expectimax/minimax tree and that move is in path P, then should we run the expectimax/minimax algorithm again on the new state or we can just see path P, and guess the next move from the next node in that path P only.

Is my logic correct or am I missing something from the expectimax/minimax algorithm for two players.

Also, some links to examples of how it is implemented actually would be nice.


Solution

  • No, you are not missing anything. The problem with the minimax algorithm is the size of the game tree. Usually when implementing the minimax algorithm one may choose to limit the tree depth to avoid massive computations. If you choose to limit the tree depth, on the next step you shouldn't always move to the next node in path P but rather compute the tree again and maybe the path will change due to the added depth. Here is a link to a minimax implementation in a project I wrote. minimax implementation (Note that this implementation also includes alpha-beta pruning for faster computation).

    If you choose not to limit the depth of the state tree, there is no point in calculating it again and in that case you would continue in path P.