Video 2, chapter 19

The Take-Away Game

How the take-away game, a subtraction game with moves of one to three counters, is solved by backward induction, why its losing positions under normal play are the multiples of four, and how misère play changes them.

  • Video 2, chapter 19
  • Find the winning move

A pile holds 21 counters. Two players take turns removing one, two or three counters, and whoever takes the last counter wins. You move first, so is there a way to win however well your opponent plays, and if there is, how many counters should you take? This page works backward from the empty pile, finds that the multiples of four are the positions to hand your opponent, and gives a strategy from 21 that has an answer to every possible move.

Key terms

Subtraction game

Definition A subtraction game is a game for two players with one pile of counters and a fixed set SS of positive whole numbers, called the subtraction set. The players take turns, and a move removes ss counters for some ss in SS that is no larger than the pile. Both players see the pile at all times, and nothing is decided by chance. Under normal play, the rule used on this page, the player who makes the last move wins, so a player who has no legal move loses. When 11 is in SS, every nonempty pile allows a move, so the last move is the one that takes the last counter.

The take-away game is the subtraction game with S={1,2,3}S = \{1, 2, 3\}, here started from 2121 counters. A pile of nn counters is a losing position for the player about to move, meaning that this player cannot force a win against correct play, exactly when nn is a multiple of 44, including n=0n = 0. Since 2121 is not a multiple of 44, the first player can force a win. The only winning opening is to take 11 counter and leave 2020. After that, whenever the opponent takes rr counters, the first player takes 4−r4 - r, which leaves a multiple of 44 again. If the game started from 2020 counters instead, the first player would already be in a losing position, and the second player could force a win with the same reply rule.

In plain words Think of the counters as groups of four plus a few left over. Your opening move removes the leftovers. After that, each round of one move by your opponent and one by you removes exactly one group, because your move always tops up the opponent’s move to four. When the last group is gone, you are the one who took the last counter.

Example You open by taking 11 from 2121, leaving 2020. The table shows one way the rest of the game can go.

Pile before the roundOpponent takesYou takePile after the round
202022221616
161633111212
1212113388
88222244
44331100

Your reply is always legal. Before each round the pile is 4k4k for some whole number k≥1k \ge 1. The opponent takes rr counters with 1≤r≤31 \le r \le 3, which leaves 4k−r≥14k - r \ge 1, so the opponent never takes the last counter. Your reply of 4−r4 - r is also between 11 and 33, and it is at most 4k−r4k - r, so the counters are there to take. It leaves 4(k−1)4(k - 1), the next smaller multiple of 44. The other two openings fail. Taking 22 leaves 1919 and taking 33 leaves 1818, and the opponent then takes 33 or 22 to hand you 1616.

Normal play

Definition A game is played under the normal play rule when the player who makes the last move wins. Equivalently, the player whose turn comes when no legal move is left loses. Under the misère rule the player who makes the last move loses instead. In a counter game in which a single counter can always be taken, normal play means that taking the last counter wins, and misère play means that taking the last counter loses. Winning and losing positions are worked out backward from the end of the game, so changing this one rule can change the answer for every pile.

In plain words Normal play rewards the player who moves last. Misère play punishes that player, so each side tries to leave the last counter for the other.

Example Play the take-away game under the misère rule. A pile of 11 is now a losing position, because the player to move must take the last counter. Piles of 22, 33 and 44 are winning, because taking 11, 22 or 33 leaves a single counter for the opponent. A pile of 55 is losing, because every move leaves 44, 33 or 22, and each of these is winning for the opponent. Continuing in the same way, the losing piles under misère play are

1, 5, 9, 13, 17, 21, …,1, \ 5, \ 9, \ 13, \ 17, \ 21, \ \dots,

the numbers that leave remainder 11 when divided by 44. So with 2121 counters the first player, who wins under normal play, is in a losing position under misère play. The second player now wins with the same reply rule. After a move of rr counters, the second player takes 4−r4 - r, which keeps the pile one more than a multiple of four until the first player faces a single counter and has to take it.

Winning position

Definition Consider a game for two players who take turns, see the whole position and leave nothing to chance. A position is a winning position if the player whose turn it is has a strategy, a rule for choosing each move, that wins against every possible sequence of moves by the opponent. In a game that always ends after finitely many moves and cannot end in a draw, such as a subtraction game, a position from which a move is possible is winning exactly when at least one legal move from it leads to a losing position.

In plain words A position is winning when you have at least one good move, one that hands your opponent a losing position. It does not matter how many bad moves are available as well.

Example In the take-away game the piles 55, 66 and 77 are winning, because taking 11, 22 or 33 respectively leaves 44, a losing position. From 66, taking 11 or 33 would be a mistake, since it leaves 55 or 33 and hands the win to the opponent, but one good move is enough. The starting pile of 2121 is winning for the same reason, and taking 11 is its only good move.

Losing position

Definition In the same kind of game, a position is a losing position if the player whose turn it is has no strategy that wins against every possible reply. In a finite game with no draws this happens exactly when the opponent has such a strategy. A position from which a move is possible is losing exactly when every legal move leads to a winning position. A position with no legal move gets its label from the rule for the end of the game, and under normal play it is losing.

In plain words Whatever you do from a losing position, your opponent has an answer that keeps you losing. You can still win if your opponent makes a mistake, but you cannot force a win against correct play.

Example In the take-away game the pile of 44 is losing. You cannot take all four, and taking 11, 22 or 33 leaves 33, 22 or 11, which your opponent takes at once. The pile of 88 is losing too, since every move leaves 77, 66 or 55, and from each of these the opponent can leave you 44. A player facing 2020 counters against an opponent who knows the reply rule loses whatever they do, but against an opponent who once leaves a pile that is not a multiple of four, they can take over the reply rule and win.

Backward induction

Definition Backward induction is a method for solving a game that always ends after finitely many moves. It labels the positions starting from those where the game is over. A position with no legal move gets the label given by the rule for the end of the game. Any other position is labeled once every position one move away from it is labeled, and it is winning if at least one of those is losing and losing if all of them are winning. In a subtraction game every move makes the pile smaller, so labeling the piles 0,1,2,…0, 1, 2, \dots in increasing order reaches every pile. In any finite game for two players who alternate, with full information and no chance or draws, the method shows that every position is either winning or losing, never both and never neither.

In plain words Start at the end, where the answer is obvious, and work back one step at a time, using the answers you already have to find the next one.

Example For the take-away game under normal play, the table lists the piles from 00 to 88, where their moves lead and the label that follows.

PileMoves lead toLabel
00no movelosing
1100winning
221,01, 0winning
332,1,02, 1, 0winning
443,2,13, 2, 1losing
554,3,24, 3, 2winning
665,4,35, 4, 3winning
776,5,46, 5, 4winning
887,6,57, 6, 5losing

The labels repeat with period four, and the same reasoning proves this for every pile. Suppose the piles below nn are labeled losing exactly at the multiples of four. If n=4kn = 4k with k≥1k \ge 1, every move leaves 4k−14k - 1, 4k−24k - 2 or 4k−34k - 3, none of them a multiple of four, so nn is losing. If n=4k+jn = 4k + j with jj equal to 11, 22 or 33, taking jj counters leaves 4k4k, so nn is winning.

Check yourself

  1. Play the take-away game with 3030 counters, moves of one, two or three counters, and normal play. Should you move first, and if so, what should you take?
Show the answer

Yes, move first. The pile 30=4⋅7+230 = 4 \cdot 7 + 2 is not a multiple of four, so it is a winning position for the player to move. Take 22 counters and leave 2828. After that, answer every move of rr counters with 4−r4 - r, so that after your moves the pile is 2424, 2020, 1616, 1212, 88, 44 and finally 00. Taking 11 or 33 at the start would be a mistake, because it leaves 2929 or 2727, and the opponent could take 11 or 33 to hand you 2828 or 2424.

  1. Change the rule so that a move takes one, two, three, four or five counters, still under normal play, and start with 100100 counters. Which piles are losing, and what is the winning first move?
Show the answer

The losing piles are now the multiples of 66. Backward induction proves it as before. The empty pile is losing. From a pile 6k6k with k≥1k \ge 1, every move of ss counters with 1≤s≤51 \le s \le 5 leaves 6k−s6k - s, which is not a multiple of 66. From a pile 6k+j6k + j with 1≤j≤51 \le j \le 5, taking jj counters leaves 6k6k. Since

100=6⋅16+4,100 = 6 \cdot 16 + 4,

the winning first move is to take 44 counters and leave 9696. After that, answer a move of ss counters with 6−s6 - s. In general, when a move takes from one up to mm counters, the losing piles are the multiples of m+1m + 1.

  1. Now allow moves of one, three or four counters, under normal play, with 2121 counters. A guess based on the largest move says to leave a multiple of five. Find the losing piles by backward induction and decide whether you should move first.
Show the answer

Label the piles in increasing order. The empty pile is losing. The pile of 11 is winning, since taking it leaves 00. The pile of 22 is losing, since its only move leaves 11. The piles of 33 and 44 are winning, since you can take them whole. The piles of 55 and 66 are winning, since taking 33 or 44 leaves 22. The pile of 77 is losing, since its moves leave 66, 44 and 33, all winning. The pile of 88 is winning, since taking 11 leaves 77, and the pile of 99 is losing, since its moves leave 88, 66 and 55.

The guess fails already at 55, which is winning. The losing piles are exactly those with remainder 00 or 22 when divided by 77. From remainder 00 the moves give remainders 66, 44 and 33, and from remainder 22 the legal moves give remainders 11, 66 and 55, so a losing pile never leads to another losing pile. From remainders 11, 33 and 44, taking 11, 33 or 44 counters reaches remainder 00, and from remainders 55 and 66, taking 33 or 44 counters reaches remainder 22. These moves are always legal, because a pile with remainder jj has at least jj counters.

Since 21=3⋅721 = 3 \cdot 7, the pile of 2121 is losing for the player to move, so you should let your opponent go first. If the opponent takes 11 and leaves 2020, take 44 to leave 1616. If they take 33 and leave 1818, take 44 to leave 1414. If they take 44 and leave 1717, take 33 to leave 1414. Keep leaving a pile with remainder 00 or 22, and you will take the last counter.