Gameweave
Nim
2 players
Play now

Nim Player Guide

Nim is a game with no luck and no hidden information, and it has a complete mathematical solution. That makes it unusual: with the right method, you can work out the best move in any position. This guide is written for the version on Gameweave, the misère game a pub plays: three rows of 3, 5 and 7 matches, take any number from one row, and whoever takes the last match loses.

Opening ideas

The method: binary and "nim-sum"

Write each row's count in binary (as sums of 4, 2 and 1):
  • •
    3 = 2 + 1
  • •
    5 = 4 + 1
  • •
    7 = 4 + 2 + 1
Now look at each power of two in turn and count how many rows contain it. If every power appears an even number of times, the position is balanced. If any power appears an odd number of times, it is unbalanced. Mathematicians call this check the nim-sum: a balanced position has a nim-sum of zero.
The key fact: from a balanced position, every move unbalances it; from an unbalanced position, there is always a move that balances it. In ordinary Nim (where taking the last match wins), you win by always handing your opponent a balanced position.

The misère twist

This version is misère: you want your opponent to take the last match. The method changes in only one place. Play exactly as above, until your move would leave only rows of one match (or empty rows). At that point, leave an odd number of single-match rows instead. Then your opponent must eventually take the last one.

The opening position

At the start, 4 appears twice (in 5 and 7), 2 appears once (in 7), and 1 appears three times. The 2s and the 1s are odd, so the position is unbalanced, and the player who moves first can win. In fact there are three winning first moves, and each one takes a single match:
  • •
    take 1 from the row of 3, leaving 2, 5, 7;
  • •
    take 1 from the row of 5, leaving 3, 4, 7;
  • •
    take 1 from the row of 7, leaving 3, 5, 6.
Check any of them: every power of two then appears an even number of times. Any other first move hands the win to your opponent, if they know the method.

During the game

  • •
    Rebalance after every move. When it is your turn, find a row you can shrink so that each power of two appears an even number of times again. There is always such a row when the position is unbalanced.
  • •
    Learn some balanced positions by heart. These are losing positions for the player to move, while at least one row has two or more matches:
    • •
      two equal rows, such as 2 and 2, or 4 and 4, with the rest empty;
    • •
      1, 2, 3;
    • •
      1, 4, 5;
    • •
      2, 4, 6;
    • •
      3, 5, 6.
  • •
    Mirror equal rows. If you leave two equal rows, copy your opponent: whatever they take from one row, take the same from the other. Keep copying until the misère moment described below.
  • •
    If you are second, keep it complicated. When your opponent starts from the opening position and finds a winning move, you cannot force a win. Make moves that leave many matches and several rows, so that they have more chances to slip.

Endgame

Most misère games are decided in the last few moves, where the twist applies.
  • •
    Odd number of single rows wins. If every non-empty row holds exactly one match, the player to move loses when the number of rows is odd. With rows 1, 1, 1 and you to move, you will be left with the last match.
  • •
    One big row left. If exactly one row has two or more matches, shrink it to either 0 or 1 so that an odd number of single-match rows remains. This is the moment the misère game differs from ordinary Nim.
  • •
    A worked example: 1, 1, 2. Ordinary Nim says take both matches from the row of 2, leaving 1, 1. In misère that loses: your opponent takes one, and you must take the last. Instead, take one match from the row of 2, leaving 1, 1, 1. Your opponent takes one, you take one, and they must take the last.
  • •
    Breaking a mirror. Suppose you have left 2 and 2. If your opponent takes one match (leaving 1 and 2), take the whole row of 2, leaving a single match for them. If they take a whole row (leaving 0 and 2), take one from the other row, again leaving a single match.

Common mistakes

  • •
    Playing ordinary Nim to the end. Forgetting the misère switch at the last moment throws away a won game.
  • •
    Taking a whole row out of habit. Big grabs feel strong but usually unbalance the position for your opponent's benefit.
  • •
    Miscounting the binary. Write it down. A single wrong bit gives the wrong move.
  • •
    Thinking the game is luck. It is not. If you lose from a winning position, there was a move that would have won.
  • •
    Making the first move without thinking. Only three of the possible opening moves win.

Practising on Gameweave

  • •
    The first player alternates between games, so you will practise both the winning side and the defending side.
  • •
    Each row has a button for every number of matches you may take from it. Pressing a button takes that many from that row, and your turn ends.
  • •
    There are no options to set. The rows always start at 3, 5 and 7, so the same analysis holds every game.
  • •
    When you move first, aim to win from the very first move: take one match from any row, then keep the position balanced.
  • •
    When you move second, watch your opponent's first move. If they took anything other than a single match, the position is now unbalanced for you, and you can win.
  • •
    Keep a sheet of paper beside you. Writing the three counts in binary before each move is the fastest way to learn the method.
Nim still
Nim
Verified
No ratings yet
2 players
2–5 min
Play now

Facts

Players
2 players
Play time
2–5 min
Games played
Not played yet
Updated
5 days ago
Version
1.2.0
Minimum age
All ages
License