Strategy to win at tic tac toe, checkers, Nim and Gomoku

These four games have rules you can learn in a minute, but winning often takes a few key ideas. Here are the ones that matter in each game, with a Nim example solved by hand and tips for practicing against the computer.

Updated:

Tic tac toe: how to never lose

On the classic 3×3 board, if both players play without mistakes, the game always ends in a draw. So the strategy is to make no mistakes yourself and set traps so your opponent makes one.

For the player who opens (X moves first), the best first moves are the center or a corner; both guarantee at least a draw. The corner is more dangerous for the opponent: only one reply doesn't lose, the center. If you are O and X opens in a corner, you must go to the center. If X opens in the center, you must answer in a corner; an edge square loses.

The golden rule for every turn: first check whether you can win; if not, whether your opponent is about to win and you must block; if not, look to create a fork.

The fork: two threats at once

A fork is a move that creates two lines of two marks, each with the third square empty. Your opponent can block only one, and you complete the other. Number the squares 1 to 9 from left to right and top to bottom. Example: X plays 1, O answers badly on the edge (2), X plays 5 (center) and threatens 9; O blocks at 9, and X plays 7. Now X has two threats: 1-4-7 (needs 4) and 3-5-7 (needs 3). O blocks one and X wins with the other.

Defending means looking one step ahead: before you block, ask whether your block forces the opponent into creating a fork. Sometimes it's better to force the opponent by creating a threat of your own so they have to block.

On the 4×4 and 5×5 boards (four in a row wins) there is more room to build double threats, so the game is less mechanical. The Ultimate variant adds a layer: the square you pick inside a small board decides which small board your opponent plays in. Avoid sending them to a board where they are about to win, and try to send them to one that is already won or full, because then they can play anywhere.

Checkers: forced captures and structure

In the ABC SyG Checkers you can choose between two rule sets: "Classic" (men and kings move and capture one square at a time; men only capture forward) and "Flying kings" (the king travels any number of free squares along a diagonal, men also capture backward, and you must take the maximum number of pieces). In both, capturing is mandatory and jumps can be chained. There are many checkers and draughts variants around the world, so if you play under another rule set, check the differences.

What pays off most in practice:

Crowning changes the game, especially with flying kings, where a single king can dominate an almost empty board. Before launching an attack, count how many moves your opponent has left: whoever runs out of legal moves loses.

Nim: the exact strategy

Nim is a game that theory solves completely. There are several piles of stones; on each turn you remove any number of stones (at least one) from a single pile. In the classic version, whoever takes the last stone wins. In the tool, you tap a stone and it and all the stones to its right in the same pile are picked.

The key is the nim-sum: write the pile sizes in binary and add each column without carrying (this is the XOR operation). If the result is 0, the player to move is in a losing position (if the opponent plays well); if it is not 0, there is a move that leaves it at 0, and that is the winning move.

The 3-4-5 position
PileStonesBinary
13011
24100
35101
Nim-sum (XOR)2010

Worked example with piles of 3, 4 and 5. Left column (the 4s): two ones (in 4 and 5), an even total, gives 0. Middle column (the 2s): one 1 (in 3), an odd total, gives 1. Right column (the 1s): two ones (in 3 and 5), gives 0. The nim-sum is 010, which is 2. Since it isn't 0, the player to move wins.

To find the move, look for a pile that gets smaller when you apply XOR with 2. 3 XOR 2 = 1 (smaller than 3): it works. 4 XOR 2 = 6 and 5 XOR 2 = 7 are larger, so they don't. So take 2 stones from the pile of 3, leaving 1. The position is now 1-4-5: 1 XOR 4 XOR 5 = 0, and your opponent is in a losing position.

Use the same method every turn. If your opponent takes the whole pile of 4 (leaving 1-0-5), the nim-sum is 4; 5 XOR 4 = 1, so take 4 stones from that pile, leaving 1-0-1, with nim-sum 0.

Misère Nim: when taking the last stone loses

Under "Rules and options" you can choose the variant in which whoever takes the last stone loses. The strategy is almost identical: play with the nim-sum exactly as in the classic version until your move would leave only piles of one stone or none. At that moment you switch: leave an odd number of piles of one stone, so that your opponent is the one stuck with the last stone.

For example, with piles 1 and 3 in misère, you take all 3 stones from the second pile: a single pile of one stone remains, and your opponent has to take it and loses. With 3-4-5 the first player also wins, because several piles have more than one stone: play as in the classic version, with the same first move.

Gomoku: open threats and double threats

In Gomoku (free-style version, 9×9, 13×13 or 15×15 boards) whoever lines up five or more stones wins. The first player, Black, has a considerable advantage: on the unrestricted 15×15 board it has been proven that Black can win with perfect play. So if you play White, precise defense comes first.

The vocabulary you need:

The attacking plan is to force your opponent with simple fours (which demand a block) until you build a double threat. On defense, block open threes as soon as they appear, and do it with a stone that also helps your own line. On a phone, the 9×9 or 13×13 board is better, with larger intersections to tap.

Connect 4 and how to practice against the computer

Connect 4 follows the same logic of double threats: with perfect play the first player can always win, and opening in the center column is best. A good idea is to create two stacked threats, one square that completes your line and the one right above it, because your opponent can't block both.

To improve at any of these games, play against the computer starting at the easiest level and moving up when you win several times in a row. Alternate who goes first so you learn both sides. When you lose, use «Undo» to go back and see what would have happened with a different move; against the computer it takes back your move and its reply. Scores and settings are saved only in your browser.

Frequently asked questions

Can you always win at tic tac toe?

No. On the 3×3 board, with perfect play from both sides, it is always a draw. What you can do is never lose and take advantage of your opponent's mistakes, especially with forks.

What is the best first move in tic tac toe?

The center or a corner; both guarantee at least a draw. The corner gives the opponent more chances to go wrong, because only one reply (the center) avoids losing.

What is the nim-sum?

It is the result of adding the pile sizes in binary without carrying (the XOR operation). If it is 0, the player to move is in a losing position; if it isn't 0, a move exists that leaves it at 0.

What is the difference between classic and flying-kings checkers?

In classic, men and kings move and capture one square at a time. With flying kings, the king travels any distance along a diagonal, men also capture backward, and you must take the maximum number of pieces.

Why does Black have an advantage in Gomoku?

Because it moves first and can build threats earlier. In the free-style version, with no restrictions on Black, the advantage is large enough to win with perfect play on the 15×15 board.