Notakto: X-only tic-tac-toe
Tic-tac-toe with a twist: both players place X. A board with three in a row is dead and takes no more moves. Whoever completes a line on the last live board loses. The AI has searched the entire game tree. Can you beat it?
Your XAI's XChanging the number of boards or who moves first starts a new game; the AI strength applies from the next move.
Key facts
- Both players have exactly the same moves; there are no "your pieces" and "my pieces". That makes it an impartial game. Whoever makes the last move loses, which is the misère convention. The two colours of X above only show who played what.
- 1 board: the first player wins, and only by taking the centre. Any other first move loses. With perfect play the game lasts 6 moves.
- 2 boards: the first player loses. With perfect play the game lasts 11 moves. The second player cannot simply copy moves onto the other board: once the first player kills a board, copying would kill the last one.
- 3 boards: the first player wins, and any first move does it. All 9 cells are winning moves. With perfect play the game lasts 14 moves.
- In general: with an odd number of empty boards the first player wins; with an even number, the first player loses. In the misère quotient an empty board has value c, so n empty boards have value cⁿ. Since c³ = ac² and a² = 1, from n = 2 on cⁿ alternates between c² (player to move loses) and ac² (player to move wins), and every even power is c². We checked 1 to 6 boards by exhaustive search, and every case fits this rule.
- So with "I move first" the win is yours, but one wrong move and the perfect AI takes the win and never gives it back. With "AI moves first" the perfect AI gives you no chance. To practise, turn on "Show hints": green dots are winning moves, red dots are losing ones.
Why the Nim method fails
For impartial games under normal play (the last mover wins), each component gets a Grundy value, and a sum of components is solved by XOR-ing those values. That is the Sprague–Grundy theorem, and it is how Nim is solved.
Under misère play this breaks down. With several boards, who makes the last move depends on when each board gets killed, and the parities interact, so a single number per board is not enough.
Plambeck and Siegel introduced misère quotients: under misère play, each board position maps to an element of a finite commutative monoid. For several boards you multiply the elements and check whether the product lands in the "player to move loses" class or the "player to move wins" class. In 2013, Plambeck and Whitehead used this method in "The Secrets of Notakto: Winning at X-only Tic-Tac-Toe" to solve Notakto on any number of 3×3 boards, with a monoid of just 18 elements.
How the AI plays
The perfect AI does not use the monoid. It searches the whole game tree directly: rotations and reflections of a board count as the same position, dead boards are dropped, and that leaves only 46 essentially different live boards, so every position with 3 boards is solved in the browser in an instant. When it can win, it takes the fastest win; when it cannot, it plays the move that lasts longest.
The casual AI plays at random, except that it never completes a line on the last board on purpose.
Comments