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

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



The book Python Programming for the Absolute Beginner uses this algorithm:

Number the board

012
345
678

best_moves = [4,0,2,6,8,1,3,5,7]

choose first available out of best_moves

It turns out that you can modify this scheme pretty easily with one-turn-lookahead to guarantee a draw for either player.