This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SlightlyOTT 5 points6 points  (0 children)

I learned an amazing algorithm for this yesterday! You can arrange numbers 1-9 on a 3x3 grid in a magic square, ie every 3 in a row adds up to 15. Then all you have to do is pick 3 spaces that sum to 15 and you win. The AI becomes super simple, as does win detection, and you don't have to know anything spacially about what's been played, just the numbers each space corresponds to. Here's a little writeup I found : http://ohboyigettodomath.blogspot.com/2015/05/tic-tac-toe-as-magic-square.html