Nim
X X X
X X X X X
X X X X X X X
Opening position utilizing rows of three, five, and seven counters.
Alternate Names
Nim, occasionally spelled Nimm, is also known as The X-Game (usually when played on a chalkboard or with paper and pencil), Matchsticks (when played utilizing matchsticks as the counters), The Marienbad Game (in reference to its appearance in a French film, L'année dernière à Marienbad or Last Year at Marienbad ), or 3-5-7 (when played with these numbers of counters in the rows). The name Nim is probably derived from German nimm meaning "take [imperative]", or the obsolete English verb nim of the same meaning. Nim is closely related to a Chinese game called Tsianshidsi, Tsyan-shizi or Tsyanshidzi (Picking Stones or Picking Stones Game).
No. of Players
Two
Equipment
Nim games and their variations can be played with just about any kind of tangible object or visual representation of one. It is probably best that the tangible objects are somewhat uniform or resemble each other to some degree and are small and easily managed manually, thus small stones are often used when outdoors and matchsticks or coins have been used frequently when played in pubs, cafés, or just inside. The game also lends itself easily to be played with paper and pencil or on a chalkboard, as I was first taught it by my seventh grade math teacher. A game board may be utilized and many variations have certainly been marketed and sold for the play of this game but, in truth, a board is not required at all. It is only the objects (stones, coins, matchsticks, X's) themselves which are required. For uniformity, I will always call the objects used to play the game "counters" from this point on.
History
Nim is one of the most simplistic games ever devised, but should never be overlooked as a simplistic children's game. Although the basic rules and premise of the many variations of the game certainly share a common theme, it is a folk game and there are an enormous amount of variations concerning the number of counters used, the number of rows they are placed in and the method of winning or losing (see below).
Its origins lie in antiquity and it is certainly possible that the game was devised, at least in some form, in many different places and cultures of the world independently. It is usually said that the game is believed to have originated in China, where it was Tsyanshidzi or Jian-shizi (picking stones game), but the origin remains uncertain and the current name of this game is a loan word from the Old English or Germanic verb nimm (meaning "take!"). Nim-type games have existed for centuries around the world, and the first European references date from the 15th century. The name "Nim" was coined by Charles L. Bouton of Harvard University, who studeid it extensively and developed a a complete theory for the play of it in 1901.
An electromechanical machine called the Nimatron that could play Nim was on display at the Westinghouse Pavilion at the World's Fair in New York in 1940 and is sometimes considered one of the world's first computers or computerized games.
Winning Ways, is a two-volume work by three eminent mathematicians that analyzes virtually all known games in terms of Nim. Nim and variations of it have been extensively studied by mathematicians and game theorists for years. Curiously enough, Alain Resnais featured Nim in the movie L'année dernière à Marienbad (Last Year in Marienbad) in 1962.
Objective
Nim is typically played as a misère game. This means that the player who is forced to remove the last counter loses. The exact opposite of this is also utilized where the player who is able remove the last counter is pronounced the winner. Despite being less common, this is called a normal play game. Most of the mathematical analyses for the strategy of Nim concern the normal play game.
Play
Players should first decide how many counters to use and how many rows they are to be placed in. Next decide if the misère or normal play game rules will apply. Two players take turns removing one or more counters (or marking off X's). A player may remove as many counters per turn as they wish, so long as they are all in one horizontal row. If you are left with the last counter, you win or lose the game depending on which version you chose to play.
Strategy
The strategy of Nim games is the subject of much study and mathematical analyses. To keep matters simple here, I will just state that to win the standard misère version, leave your opponent with rows of these amounts:
1; 1-1-1; 2-2; 1-2-3; 3-3; 4-4; 5-5; 1-4-5; 2-4-6; 2-5-7; or 3-4-7
This means the best opening move is to remove one from the middle or one from the shortest row. A player who goes first should always be able to win by following this formula.
Variations
The normal play game of Nim variation says that the winner removes the last counter. This is opposed to the more common misère game where the winner forces their opponent to remove the last counter.
Any number of counters and rows may be utilized for the play of this game. I will here refer to the game I was originally taught utilizing rows of three, five and seven counters as “3-5-7”. Using that nomenclature, we may call other games I have encountered in print and on the web as "1-3-5-7", "3-5-7-9", "4-5-6-7-8", etc.
One-Line Nim is played with a single row of fifteen counters. Each player takes turns removing any one, two, or three counters. The counters being removed need not be adjacent to one another. It is commonly played with misère rules where the winner is the player who forces his opponent to pick up the last match but may also use normal play rules. It can also be played with a row of thirteen, twenty-one, or twenty-five matches.
Kayles was invented by Henry Dudeney, an English author and mathematician and is much akin to One-Line Nim. It may be played with any number of counters, said to represent bowling pins. Here, only one counter or two counters, adjacent to one another, may be removed per turn. Some versions of Kayles have the initial arrangement of counters placed in a circle, rather than a straight line. This may be called Circular Nim. Normal play or misère rules may apply.
Kurna reports a variation from Afghanistan called Tahir. It is played the same as the standard version listed here but has two additional lines from which counters can be removed.
Any number of counters can be removed along any one line in Tahir, and the diagonal lines add another dimension of play Nim.
Greedy Nim is a variation where players are restricted to removing counters from the largest row (or pile).
Building Nim has players first build the piles of objects before removing them. Both players decide how many piles they wish to create and then are given an equal number of counters with which they alternate turns placing, one at a time, into a pile of their choosing. Once all of the counters are in piles, the Nim game begins.
Sources
Pentagames. Compiled by Pentagram. 1990. Fireside, Simon & Schuster Inc. ISBN 0-671-72529-7.