AIs for Games, Part I, Brute Force TicTacToe
I start my AI for Games project by creating a brute force algorithm for TicTacToe
Other posts in series
The AI in Action
Below are screenshots illustrating the AI in action.
1) I run the program, select the AI to play first, and respond to its first move.
2) The AI plays in the top left, forcing me to play in the middle left.
3) The end is nigh. The AI creates two threats at once. I stop one of them…
4) But I cannot stop both.
AI: 1, Humans: 0.
Comments
This program is highly inefficient. E.g it will search through every possible move, even if it has already found a winning sequence. My focus was on getting something working, rather than trying to optimise it.
Next steps
- Coding up more complicated games. I have already done this for Pentago (see github).
- Coding up the alpha-beta pruning algorithm
- Coding up a neural network to create a heuristic function
Code
The code for this is available on github.