[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Just finished TicTacToe, but How would I do some AI?



Lamonte Harris wrote:
Yah, http://wecodepython.info/code/TicTacToe/TicTacToe.py is the code and http://wecodepython.info/games/TicTacToe.zip <http://wecodepython.info/games/TicTacToe.zip> is the exe, Does anyone know how to do AI, if so can someone explain the mechanism to doing it?
Read about A* searching algorithm.
basically you search for paths that have the highest chance of winning and take the one with the highest chance. Because tic-tac-toe is so simple you can just do an exhaustive search of all possibilities, straight to the ending case in every situation, whereas with Chess you have to do some optimizations and only look ahead a certain number of moves, because otherwise it'd take years to perform each move.