Follow TV Tropes

Following

Game of Nim

Go To

"I know a game I always win."
"It's not much of a game if you can't lose."
"Oh, I can lose, but I always win."

James Fixx described this two-player game in his 1972 book Games for the Superintelligent, although it is certainly older, appearing in the 1961 French film Last Year at Marienbad.

The game begins with matchsticks arranged in three rows: three on the top, five in the middle, and seven at the bottom. Players take turns removing matches, from only one row at a time. The objective is to remove the last match.

The solution involves writing the number of matchsticks in each row in binary and making selections so that there is an even number of each binary digit.

One popular variant (aka misère nim) requires one to force one's opponent to remove the last match.

Follow the aforementioned strategy, except when this would leave only single matches, in which case you want to leave an odd number of single matches.

More general versions of both games exist with different numbers and sizes of rows (or piles, as the case may be). In all cases, depending on the starting positionnote , either one side or the other can follow the strategies above, and cannot be beaten if the player follows it carefully. If they make a mistake, the other player may take over with said strategy. This makes it very easy to implement in a computer game—the human player has the advantage and can win if they do the right thing, but a single slip-up and the computer will win instead.


This game makes an appearance in:

Anime & Manga

  • Yu-Gi-Oh! (first anime series): Dark Yugi challenges the school's Alpha Bitch Kaoruko Himekoji to misère nim. Instead of matchsticks, they use the flowers on the latter's person. As usual, Dark Yugi pulls a come-from-behind victory—while his opponent focuses entirely on the bouquet she was holding, she forgets she has an extra flower in her hair. As an added element of Hoist by His Own Petard, Yugi figures out that it's Kaourko who attacked and chloroformed his friend Miho; the rose petals he found near Miho fell from the exact same rose he pulled to win the game.
    Dark Yugi: I said all the flowers you had. I never said just the bouquet.

Fan Works

  • HOME (2013): The game of Nim in the park from OFF is now a game where you throw birds at balloons. The birds explode into a squirt of blood when they hit the wall.

Live-Action TV

  • Dara Ó Briain's School Of Hard Sums: Yucky Choccy is played with a tray of chocolates and a chilli pepper.
  • Fort Boyard: One of the challenges against the Masters of Time involves a game of Nim.
  • Squid Game: In "Gganbu", the objective is to pick a game that involves marbles and play it with one's partner. The characters win if they manage to win over all ten of their partner's marbles. Gi-hun convinces a senile Il-nam to play a game of Nim with the marbles. In the first round, Gi-hun loses as he's the one holding the last marble; desperate, he guiltily exploits Il-nam's lapse in lucidity to win.

Magazines

  • Scientific American: Yucky Choccy, a version involving a bar of chocolate, the corner chunk of which is soap, so the loser is the person who has to eat the soap, is described in one of Ian Stewart's maths columns.

Tabletop Games

  • The Amazing Dr. Nim: It's a marble track with several gates that can either allow marbles to pass or block them. To beat it, it includes an "equalizer" gate. When set to on, this causes it to make a single non-optimal play over the course of the game, allowing a perfect human player to win an otherwise unwinnable game.

Video Games

  • Become The Pirate King!: It adapts Mihawk's Curbstomp Battle against Zoro at the Baratie. The matchsticks represent how many (ineffectual) attacks each player makes against him; whoever's stuck making the thirtieth attack loses, and gets chopped down to 1 HP by his counterattack. Things are spiced up by a limited-use Special Attack mechanic (a Random Number Generator that may let you make anywhere up to nine attacks) and occasional power-ups that either let you skip a turn or add an extra attack opportunity.
  • Clubhouse Games: Rebranded as 'Last One', is one of the games included, although as a Japan-exclusive. It's played as originally, with matchsticks in three rows.
  • Cursed Trilogy: In the second game, Randall plays a version of the game with a cloaked figure. There is a set of marbles on the table, either player can take up to four at a time, you choose who goes first, and if the figure takes the last marble you die. The answer is to let the figure go first, then take marbles on each of your turns so that the total marbles taken between their turn and yours is 5.
  • Humbug: This Interactive Fiction title pits you against an octopus in a game of Nim.
  • The Keepers Lost Progeny: In the bonus chapter of the collector's edition, you play against the computer. Each player takes turns to remove between one and three daggers. Unfortunately, you can't win in ordinary play, as a) you always go first, and b) the computer follows every move by taking (4-n) daggers, where n is the number you took. You can only "win" by playing three games—during the third, the computer will make a deliberate mistake.
  • Math Workshop: One of the puzzles is a game of Nim that replaces the matchsticks with toy rockets arranged in three rows. The goal is to be the one who launches the last rocket.
  • OFF: A mandatory puzzle in the amusement park of Zone 2 has you and your opponent take turns popping balloons, picking to pop one, two, or three each turn.note 
  • Pokémon Black and White: In the Dream World, you can play a game against ghost-type Pokémon where the players take turns blowing out candles. Some candles, however, give you extra points, while others subtract them, and later ones take two turns to extinguish.
  • Super Mario Bros.:
    • Mario Party 2: In the minigame Honeycomb Havoc, you have a tree with fruits, coins, and beehives set up in a row, and each of the four players can take one or two items from the tree—if you get the beehive, you're out.
    • Super Mario RPG: You have to make sure your opponent takes the last coin from a box. Although the CPU apparently doesn't know how to count because it often takes multiple coins if there's more than one coin left, causing it to lose.
  • Tales Series:
    • Tales of Phantasia: There is an NPC in Alvanista Castle who will challenge you to a "subtraction game" in which players take turns removing 1, 2, or 3 rocks from a pile. Whoever takes the last one is losing. It's made extra difficult because the player has only 3 seconds to choose a number. Should you win though, the NPC will give you a combat accessory, though to get that in the PS1 version you will also have to play a second round with a much bigger pile of rocks. You will also get a title for Cress for winning the harder variant.
    • Tales of Eternia: You can play an "arithmetic contest" Mini-Game against a NPC in Barole that is basically the Game of Nim. It has the additional rule that no more than three tokens can be taken per turn, though. Winning will unlock the "Mathematician" title for Reid, which is kinda deserved because the dev team seems to have implemented a perfect-play algorithm and the game will win if the player makes a single mistake starting with the question, "Who goes first?".
  • Teenage Mutant Ninja Turtles: Fall of the Foot Clan: In a bonus stage, you play a game of Nim against Krang by removing shurikens until there are none left, with the winner being the one who removes the last shuriken.
  • Zork Zero: One of the puzzles is a game of Nim in which the matchsticks get replaced by flowers arranged in rows. Fortunately, you can cheat—the number of flowers in each corner of the screen when you're playing Nim gives you a winning move each turn. This too is one of the puzzles in Zork.

Webcomics

Websites

  • Ted: The "Rogue AI Riddle" pits the player against an AI in a variant of the game. You start on top of 25 meters of electrified water while Nim starts at the bottom. Both players must lower the water level to exactly 0 on their turn, and can only lower the water levels by 1, 3, or 4 levels.
Western Animation
  • Cyberchase: In "Problem-Solving in Shangri-La", both the kids and Hacker have to win two out of three games of him before they can leave. Shangri-La being a Land of Dragons, it's played with sentient mini-Terracotta warriors and [[dragons. They all struggle to find the winning strategy until Jackie realizes to solve the last move and work back from there to control previous turns.


Top