0

I want to implement the Minimax algorithm in java. I couldnt find a good tree representation. Is there an existing one or should I make my own?

  • by the way this is for the pacman game Thanks

1 Answers1

1

You don't need one.

The minimax algorithm is frequently illustrated with a tree.

However, that tree represents the steps taken by the algorithm to choose the best move. It is not a data structure held by the algorithm.

Instead, you'll use iteration and recursion. At each interior node of the tree, you'll iterate through the children, and use recursion on each child.

Andy Thomas
  • 84,978
  • 11
  • 107
  • 151
  • I understand how you don't need a tree only to compute the minimax value. But if you're to use it in a game (question states Pacman) you need to keep track of the movement. Can you do that without a tree? – garci560 Aug 28 '17 at 18:18
  • Yes -- you can keep track of the current game state, regardless how it was reached -- and use minimax to find the single next move. – Andy Thomas Aug 29 '17 at 02:33