# minimax search related question

## Recommended Posts

sleeper123    122
Hi, I've got a question regarding applying minimax to tic-tac-toe. This involves using no heuristics and creating the full tree of all possible play. If we take the possible squares as :- A | B | C - - - - - D | E | F - - - - - G | H | I From the start of the game the first player could place an x in any of A-I. If you use minimax (as I understand how it works anyway?) to determine where it should place its move, then it could be any of them as from this position all lower nodes will have an equal value. So to get the choice of where to play first and not always the same square, is it as simple as choosing a random square? Also as we move down the tree (ie. as the game progresses) there will be other circumstances where the most favourable lower nodes will have the same value, so again at this point is it a case of picking a random lower node from the favourable ones? More generally, are my questions above valid or am I missing something fundamental about assigning values to the various nodes of the tree? If so could someone try and correct me (by the way I've understood the assigning system a node can have one of only three values : -1 , 0 and 1)

##### Share on other sites
alvaro    21246
What you are saying is basically correct. A simple way of picking a good random move is to use random numbers as the evaluation of draws.

You also have the problem that a pure minimax searcher like that will not prefer short wins to long ones, so in this position both D and H win the game, but D looks silly:
x|o| -+-+- |o| -+-+-x| |

I would do something like this to solve both problems:
* A win by player 1 has a score of 120-n, where n is the number of moves played on the board.
* A win by player 2 has a score of -120+n.
* A draw has a score of -100+(std::rand()%201).

That should behave correctly in all situations.

##### Share on other sites
sleeper123    122
Thanks for that alvaro, that clears up a lot.
Cheers.