How to Play NIM – Rules, Variations, and Winning Strategies

How to Play NIM – Rules, Variations, and Winning Strategies

Nim is a simple but deep strategy game played with piles of objects (like coins, sticks, or stones). On each turn, a player removes one or more objects from a single pile. The game continues until all objects are gone — and in the most common form (misère play), the player who takes the last object loses.

It’s easy to set up anywhere and can be played casually with kids or at a competitive level with serious strategy.

Objective

Force your opponent into a position where they are stuck taking the last object.

Age Range

Ages 7 and up. Younger kids can play casually, while older kids and adults will enjoy the math and strategy involved.

Game Length

5–15 minutes, depending on the number of piles and objects.

Why We Like It for Kids and Families

  • Super simple setup – any small objects work.
  • Quick games – perfect filler game.
  • Strategic depth – teaches logical thinking and planning.
  • History tie-in – Nim is one of the earliest games studied by mathematicians and even one of the first computer games.

Skills Learned

  • Logical reasoning
  • Strategic planning
  • Counting and subtraction
  • Pattern recognition

What You Need

  • 1+ friends (2 players is standard)
  • A handful of small objects (coins, sticks, beans, matches, etc.)

How to Play Nim – 3 Main Versions

1. Classic 3-Pile Nim

  • Set up 3 piles of coins, stones, or other objects (each with any number).
  • On your turn, remove one or more objects from only one pile.
  • The player forced to take the last object loses (misère play).

2. Row Setup (1-3-5-7 Matchsticks)

  • Arrange matchsticks or tallies in 4 rows: 1, 3, 5, and 7.
  • On your turn, remove any number of sticks from a single row.
  • Continue until all sticks are gone. The player forced to take the last one loses.

3. Single-Pile Takeaway (1–3 Game)

  • Start with one pile (e.g., 21 coins).
  • Each turn, a player takes 1, 2, or 3 objects.
  • The player forced to take the last object loses.

Rules Summary

  • Players take turns removing objects.
  • You may only take from one pile (or row) per turn.
  • In misère play, the player who takes the last object loses.
  • In “normal play” (variation), the last player to take wins.

Variations

  • Normal Play Ending: Instead of losing, the player who takes the last object wins.
  • Paper-and-Pencil Nim: Draw piles of tally marks and erase them each turn instead of using objects.
  • Uneven Piles: Start with any configuration (e.g., piles of 2, 7, and 10). The strategy is the same.

Example Playthroughs of Nim

1. Classic 3-Pile Nim

Setup: Piles of 3, 5, and 7 coins.

  • Player A takes 2 from the pile of 7 → (3, 5, 5).
  • Player B takes 3 from the pile of 5 → (3, 2, 5).
  • Player A takes all 3 from the first pile → (0, 2, 5).
  • Player B takes 2 from the 5 → (0, 2, 3).
  • Player A takes 2 from the 3 → (0, 2, 1).
  • Player B is forced to take the last object and loses!

2. Row Setup (1–3–5–7 Matchsticks)

Setup: Rows of 1, 3, 5, and 7 sticks.

  • Player A takes all 7 → (1, 3, 5, 0).
  • Player B takes 2 from the row of 5 → (1, 3, 3, 0).
  • Player A takes 1 from the row of 3 → (1, 2, 3, 0).
  • Player B takes the last single stick → (0, 2, 3, 0).
  • Player A takes 2 from the row of 3 → (0, 2, 1, 0).
  • Player B has no choice but to take the last stick and loses!

3. Single-Pile Takeaway (1–3 Game)

Setup: A single pile of 21 beans.

  • Player A takes 1 → 20 left.
  • Player B takes 3 → 17 left.
  • Player A takes 1 → 16 left.
  • Player B takes 2 → 14 left.
  • Player A takes 2 → 12 left.
  • Player B takes 3 → 9 left.
  • Player A takes 1 → 8 left.
  • Player B takes 3 → 5 left.
  • Player A takes 1 → 4 left.
  • Player B is forced to take the last 3 → leaving 1 bean. Player A is stuck with the last object and loses.

Strategies

Hey — for family fun, don’t stress about “nim-sums” and math. Just jump in, experiment, and enjoy the tension of the final moves. The fun is in laughing when you get stuck taking the last object. Over time, you’ll naturally start spotting patterns and setting little traps.

Quick Tips Box

  • In 3-Pile Nim, try to leave your opponent with piles that feel “evened out” or awkward.
  • In the 1-3-5-7 row setup, don’t be afraid to take a whole row if it sets up the endgame.
  • In the single-pile 1–3 version, always aim to leave multiples of 4.

Casual Play & Simple Tips

  • Focus on leaving piles that force your opponent into a bad move.
  • Think one or two turns ahead, especially when the piles are small.
  • Experiment with different moves — even mistakes teach you what to avoid.

For Advanced Players (Nim is a Solved Game)

Nim is one of those solved games — like tic-tac-toe — where the winning strategy is guaranteed if you know the math. The secret is calculating the nim-sum (a binary XOR of the pile sizes).

  • If the nim-sum = 0 at the start, the second player can always win with perfect play.
  • If the nim-sum ≠ 0, the first player can force a win by moving to a nim-sum of 0.

That might sound complicated, but here’s the cool part: figuring it out is half the fun. Once you “get it,” you’ve joined the Nim strategy club — just like when you first realized tic-tac-toe is always winnable (or drawn) with perfect play.

We’ll probably drop in some video tutorials here to walk through examples of the math strategy and show how it works in each version.

FAQs

Q: How many piles should you start with?
A: Three is the classic setup, but you can play with any number.

Q: Who invented Nim?
A: Nim has ancient roots, with versions played in China and Europe. The modern name “Nim” comes from the early 20th century.

Q: Is it true Nim was one of the first computer games?
A: Yes! In 1940, a machine called Nimatron was built for the New York World’s Fair, letting visitors play Nim against a computer. It’s considered one of the first electronic computer games.

Q: Can you play with uneven piles (like 2, 7, and 10 objects)?
A: Absolutely. In fact, the strategy gets more interesting with uneven piles.

Q: Can Nim be played without objects?
A: Yes! You can play with pencil and paper by drawing tally marks in piles or in the 1-3-5-7 row setup.

Q: Is Nim always winnable with perfect play?
A: Yes. Like tic-tac-toe, Nim is a solved game — but only if the player knows the strategy. Casual play often comes down to bluffing and mistakes.

Back to blog

About Game On Family Products