I'm currently working on a tictactoe as a school project, but I want to be sure to get max score from the project, so I want to spice up my current project a little bit. I have pretty decent looking basic tictactoe game that is player vs "computer". The computer itself can't be called AI, because it's simply random values from random generator looking to be upgraded into an actual AI)
But the real question is: How can I approach creating AI for the game ?(yes I have heard about minimax, but couldn't really find a way to "insert" this into my project with entirely understanding every bit of it.)
My current "matrix" looks like this, but I've implemented values 1-9 (as char's)
00 01 02 1 2 3
10 11 12 4 5 6
20 21 22 7 8 9
Is it too much work to just consider every possible move there is and write them all up to make the AI unbeatable?
If there are useful books on the subject that are publicly available I would love to hear about them aswell.
Am mainly hoping for different approaches/perspectives on the situation, not complete solutions for me to copypaste - so I can actually learn a thing or two from this.
TTT is the classic example of 'transposition tables'. The idea here is that (first move)
is the same position as
is the same as
and again at
so you can apply the exact same decision to each of those if you look at the board as if rotated, mirrored, or flipped, etc.
I forget the exact number of positions but it is actually quite small so you can code them all in followed by the next best move. This leads to a boring computer player that never makes a mistake, draws or wins all games.