|
This is a Tic-Tac-Toe AI for mostly experimental purposes. It was developed to support the discussion on this thread: http://www.boardgamegeek.com/article/2378652#2378652. A few varieties are included. Some do not play perfectly.
How to play:
It has minimal UI, so if you don't have patience don't try it.
You need the Python programming language interpreter:
http://www.python.org/
Run python. At the prompt type the following:
from tictactoe import *
game.evaluate()
The second line will take a few seconds. It is computing its moves for every possible game.
Now you are ready to play. Make a move by calling the play_avg function with some x,y coordinates where you want to play. Coordinates range from 0 to 2. E.g. type:
play_avg(2,0)
The computer will play its move and show the board. You are playing Xs.
Keep making moves until the game ends. You can play again by typing:
reset()
If you want to let the computer go first, just type:
play_avg()
The above is the non-perfect AI. To play against the perfect AI, substitute the play_minimax function for play_avg.
You can play against the slightly more conservative variation by editing the source code. Replace the call to score_avg_neutral in score_avg by a call to score_avg_pessimistic.
|