| ||||||||||||||
| ||||||||||||||
|
||||||||||||||
|
This essay is a little advancement over the Simple Board Game AI essay. In that essay, we looked at immediate moves - how the computer would deal with the current situation and make a move accordingly. Now, what happens if we would like the computer to strategize a little a look ahead. This is where minimax trees come in handy.
MaxImagine a simple game that only has three moves, one move results in a win, another a draw, and finally a loss. Therefore, we want to assess each node and figure what the outcome will be. Let us extend our game to one that allows you to make three moves per go, and only takes two goes to win. Therefore, we will want to look ahead to find out which move combination works for us. We can generate a game tree of all the possible moves:
In our example, since the tree is only two layers deep this seems rather trivial. But imagine a tree 10 layers keep, this method would allow you to simply calculate which moves would lead to a winning situation. Most of you will already notice a large fault in this - trees this large are incredibly expensive in both memory and computational terms. A 10-layer tree that branches three times for each node would have 59,049 nodes. This is relatively simple - a Tictactoe tree would have 362,880 (9!) nodes. Therefore, we have to cut down the depth of our tree. This gives us a problem, though - if we limit the depth we are not guarenteed a winning scenario as one of the nodes. This is where the clever programming has to come in. You must create some sort of evaluation function that can assess how close to a winning situation the board is. Since the nodes are not so clear-cut (win, draw, loss) a more complicated numbering system has to be used. The system is completely dependent on the programmer and the board game in question. This is only half the problem, though, because we have not yet factored in an opponent player.
Min and MaxVery few board games are one player, so how can we add this into our tree? Think about it, when we are playing for ourselves we are attempting to maximize our score, so our opponent will want to minimize our score. Let us look at a game tree - this one though is limited to a depth of 2. Here is our game tree with evaluations assigned to the final nodes:
Minimax ConclusionIn conclusion, let me put the algorithm into a stepped form:
* This is one of the pitfalls of the minimax algorithm. It assumes that our opponent is completely defensive.
Submitted: 23/08/2001 Article content copyright © James Matthews, 2001.
|
|
|||||||||||||
All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -