This Nim game is a brain teaser that trains logical reasoning and concentration. Compete against "The Master" to see who can remove the last stone from the board.
WARNING: This game is not easy to win.
Nim is an ancient logic game invented centuries ago. This version of Nim is tough. If you make even one mistake, The Master will show you who's boss.
To begin, click the Small, Medium, or Large link under the picture at left. This opens the game in a pop-up window.
After the short advertisement, the Nim Master main menu appears. Click "Normal Game" or "Reverse Game" to start playing. See below for instructions.
Yes, it is possible to beat the computer. I've beaten The Master twice (see below), but I've lost a lot more times than I've won. Below I give some tips on how to win at Nim.
Nim has been played since long before computers were invented. It's similar to the Chinese game Jianshizi, which means "picking stones".
In pubs, you'll sometimes see patrons playing Nim with match sticks. This flash game, Nim Master, is played with pebbles.
You can play Nim against a friend anytime with any collection of like-sized objects. You don't need a board, dice, or any other gear.
Besides match sticks or pebbles, you can use coins, beads, seeds, popcorn, or other small, similar-size objects.
HOW TO PLAY. There are two modes to choose from in Nim Master:
1) Normal game. Take the last stone to win.
2) Reverse game. Leave the last stone to win.
The Normal mode is the most commonly played, so I'll describe that here.
In this Nim game, the pebbles are laid out in five rows. Each row contains a varying number of stones. You take turns with the computer removing stones. You goal is to plan your moves so that you, and not the computer, remove the last stone from the board.
The number of stones in each row varies each time you play. I've seen as few as 5 stones in one row, and as many as 10 stones. In other words, you'll see 5, 6, 7, 8, 9, or 10 stones per row.
You always go first. You can take as many stones from a single row as you want. For example, you can remove 1 stone, 2 stones, 6 stones, or the entire row if you wish.
The computer then takes a turn, removing one or more stones from whichever row it chooses.
HOW TO WIN AT NIM. The challenge in this Nim game is that The Master always plays a near-perfect game. The computer follows a math algorithm which practically guarantees it victory if you make a single mistake. Therefore you must not make a mistake!
The way to not make a mistake at Nim is to understand a concept known as the "nim sum".
If you learn how the nim sum works, then you can win this Nim Master game and when you play Nim against a friend.
We'll skip the complicated math and focus on practical use. The nim sum boils down to separating the stones in each row into groups of 4, 2, and 1, then canceling like pairs in each column. Then:
If there are no unpaired multiples in any column, the nim sum for the board is zero. If this is the case at the end of your turn, it is a winning configuration for you.
If there are one or more unpaired multiples, the nim sum is greater than zero. This is a losing configuration for you.
So, again, the secret to winning at Nim is:
Note: If both players play a perfect game, then the player who starts will lose. In this Nim game, you always go first, which, as you should now understand, puts you at an immediate disadvantage against the computer.
Remember that the next time you play a Nim game against a real person. Let your opponent make the first move!
Below are simple examples of calculating the nim sum, so you can at least win at Nim sometimes.
Simple Nim Sum Calculations
Example A: Row 1 has 7 stones. Row 2 has 5 stones.
Separating the stones into groups of 4, 2, and 1 gives:
Row 1: 7 stones = 1x4 + 1x2 + 1x1 (i.e., 7 = 4+2+1)
Row 2: 5 stones = 1x4 + 0x2 + 1x1 (i.e., 5 = 4+0+1)
Now subtract the like groups in each column from each other:
4 2 1 4 0 1 ------------------ 0 2 0 = nim sum is non-zero
Let's assume it's your turn at this point. Notice that the 4's have canceled out, and the 1's canceled out, but there is an unpaired 2 in the second column.
Your best move, therefore, is to remove 2 stones from Row 1. That will set the nim sum equal to zero. At the end of your turn, the nim sum would look like this:
4 0 1 4 0 1 ------------------ 0 0 0 = nim sum is zero
Example B: Let's try all five rows. Row 1: 6 stones; Row 2: 5 stones; Row 3: 7 stones, Row 4: 2 stones, and Row 5: 6 stones.
Separating into groups of 4, 2, and 1:
Row 1: 6 stones = 1x4 + 1x2 + 0x1 (i.e., 6 = 4+2+0)
Row 2: 5 stones = 1x4 + 0x2 + 1x1 (i.e., 5 = 4+0+1)
Row 3: 7 stones = 1x4 + 1x2 + 1x1 (i.e., 7 = 4+2+1)
Row 4: 5 stones = 0x4 + 0x2 + 0x1 (i.e., 5 = 4+0+1)
Row 5: 6 stones = 1x4 + 1x2 + 0x1 (i.e., 6 = 4+2+0)
As a nim sum table:
4 2 0 4 0 1 4 2 1 4 0 1 4 2 0 ------------------ 4 2 1
The current nim sum is non-zero. Assuming it's your now your turn, your best move may be to remove Row 3 entirely. This results in:
4 2 0 4 0 1 0 0 0 4 0 1 4 2 0 ------------------ 0 0 0
Once again we've achieved our goal, a zero nim sum.
It's not impossible to win at Nim Master, but it is expecially tough because the rows can contain up to 10 pebbles.
This makes the nim sum calculations even more challenging than a simple Nim game at the pub would usually be. In fact, you may need to write your nim sums on paper as you play this game.
Got any tips? If you have any tips or tricks on how to quickly calculate nim sums or other ways to beat this Nim Master game, feel free to leave a comment below.
The rest of us would appreciate it!
This Nim game seems complicated the first time you play. But it's quite satisfying to beat The Master. Practice your nim sums, and you can beat him, too.
If you found the page above interesting, fun, or useful, please click the "Like" and/or "+1" buttons below. Feel free to leave a comment as well. Thanks very much!