|
Nim is a two-player mathematical game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap. Nim can refer to either of the following: Nim, a mathematical two player game. ...
Mathematical games include many topics which are a part of recreational mathematics, but can also cover topics such as the mathematics of games, and playing games with mathematics. ...
A game of strategy is a game where the outcome is influenced through interaction with the environment and other players. ...
Variants of Nim have been played since ancient times. The game is said to have originated in China (it closely resembles the Chinese game of "Jianshizi", or "picking stones"), but the origin is uncertain; the earliest European references to Nim are from the beginning of the 16th century. Its current name was coined by Charles L. Bouton of Harvard University, who also developed the complete theory of the game in 1901, but the origins of the name were never fully explained. The name is probably derived from German nimm! meaning "take!", or the obsolete English verb nim of the same meaning. Some people have noted that turning the word NIM upside-down and backwards results in WIN. Harvard University (incorporated as The President and Fellows of Harvard College) is a private university in Cambridge, Massachusetts, USA and a member of the Ivy League. ...
An animation of a rotationally symmetric ambigram for the word ambigram A mirror-image ambigram for the word Wiki A rotational ambigram for the word Wikipedia A 3-Dimensional ambigram of the letters A, B and C. A rotational ambigram for the word Vegas Gödel, Escher, Bach cover An...
Nim is usually played as a misère game, in which the player to take the last object loses. Nim can also be played as a normal play game, which means that the person who makes the last move (i.e., who takes the last object) wins. This is called normal play because most games follow this convention, even though Nim usually does not. Look up misère in Wiktionary, the free dictionary. ...
A misère version of a game is a game that is played according to its conventional rules, except that it is played to lose; that is, the winner is the one who loses according to the normal game rules. ...
Normal play Nim (or more precisely the system of nimbers) is fundamental to the Sprague-Grundy theorem, which essentially says that in normal play every impartial game is equivalent to a Nim heap that yields the same outcome when played in parallel with other normal play impartial games. In mathematics, the proper class of nimbers is introduced in combinatorial game theory, where they arise as the sizes of nim heaps. ...
In combinatorial game theory, the SpragueâGrundy theorem states that every impartial game is equivalent to a nimber. ...
In combinatorial game theory, an impartial game is a game in which the allowable moves depend only on the position and not on which of the two players is currently moving, and where the payoffs are symmetric. ...
The disjunctive sum of two games is a game in which the two games are played in parallel, with each player being allowed to move in just one of the games per turn. ...
A version of Nim is played--and has symbolic importance--in the French New Wave film Last Year at Marienbad (1961). François Truffauts New Wave film Jules et Jim The New Wave (French: la Nouvelle Vague) was a blanket term coined by critics for a group of French filmmakers of the late 1950s and 1960s, influenced (in part) by Italian Neorealism. ...
Still from Lannée dernière à Marienbad Lannée dernière à Marienbad (translated as Last Year in Marienbad in the UK and Last Year at Marienbad in North America) is a 1961 French movie directed by Alain Resnais, starring Delphine Seyrig, Giorgio Albertazzi, Sacha Pitoëff. ...
Year 1961 (MCMLXI) was a common year starting on Sunday (link will display full calendar) of the Gregorian calendar. ...
Illustration
A normal play game may start with heaps of 3, 4 and 5 objects: In order to win always leave an even number of 1's, 2's, and 4's. Sizes of heaps Moves A B C 3 4 5 I take 2 from A leaving two 4's and two 1's. 1 4 5 You take 3 from C 1 4 2 I take 1 from B leaving two 2's and two 1's. 1 3 2 You take 1 from B 1 2 2 I take entire A heap leaving two 2's. 0 2 2 You take 1 from B 0 1 2 I take 1 from C leaving two 1's. (In misère play I would take 2 from C leaving (0, 1, 0).) 0 1 1 You take 1 from B 0 0 1 I take entire C heap and win. Mathematical theory Nim has been mathematically solved for any number of initial heaps and objects; that is, there is an easily-calculated way to determine which player will win and what winning moves are open to that player. In a game that starts with heaps of 3, 4, and 5, the first player will win with optimal play, whether the misère or normal play convention is followed. The key to the theory of the game is the binary digital sum of the heap sizes, that is, the sum (in binary) neglecting all carries from one digit to another. This operation is also known as exclusive or (xor) or vector addition over GF(2). Within combinatorial game theory it is usually called the nim-sum, as will be done here. The nim-sum of x and y is written x ⊕ y to distinguish it from the ordinary sum, x + y. An example of the calculation with heaps of size 3, 4, and 5 is as follows: The binary numeral system, or base-2 number system, is a numeral system that represents numeric values using two symbols, usually 0 and 1. ...
The digital sum in base b of a set of natural numbers is calculated as follows: express each of the numbers in base b, then take the sum of corresponding digits and discard all carry overs. ...
Exclusive disjunction (usual symbol xor) is a logical operator that results in true if one of the operands (not both) is true. ...
In abstract algebra, a finite field or Galois field (so named in honor of Ãvariste Galois) is a field that contains only finitely many elements. ...
Mathematicians playing Konane at a Combinatorial game theory workshop (for technical content, see external link) This article is on the theory of combinatorial games. ...
Binary Decimal 0112 310 Heap A 1002 410 Heap B 1012 510 Heap C --- 0102 210 The nim-sum of heaps A, B, and C, 3 ⊕ 4 ⊕ 5 = 2 An equivalent procedure, which is often easier to perform mentally, is to express the heap sizes as sums of distinct powers of 2, cancel pairs of equal powers, and then add what's left: The binary numeral system, or base-2 number system, is a numeral system that represents numeric values using two symbols, usually 0 and 1. ...
The decimal (base ten or occasionally denary) numeral system has ten as its base. ...
Exponentiation is a mathematical operation, written an, involving two numbers, the base a and the exponent n. ...
3 = 2 + 1 = 2 + 1 Heap A 4 = 4 = 4 Heap B 5 = 4 + 1 = 4 + 1 Heap C --- 2 = 2 What's left after cancelling 1s and 4s In normal play, the winning strategy is to finish every move with a Nim-sum of 0, which is always possible if the Nim-sum is not zero before the move. If the Nim-sum is zero, then the next player will lose if the other player does not make a mistake. To find out which move to make, let X be the Nim-sum of all the heap sizes. Take the Nim-sum of each of the heap sizes with X, and find a heap whose size decreases. The winning strategy is to play in such a heap, reducing that heap to the Nim-sum of its original size with X. In the example above, taking the Nim-sum of the sizes is X = 3 ⊕ 4 ⊕ 5 = 2. The Nim-sums of the heap sizes A=3, B=4, and C=5 with X=2 are - A ⊕ X = 3 ⊕ 2 = 1
- B ⊕ X = 4 ⊕ 2 = 6
- C ⊕ X = 5 ⊕ 2 = 7
The only heap that is reduced is heap A, so the winning move is to reduce the size of heap A to 1 (by removing two objects). As a particular simple case, if there are only two heaps left, the strategy is to reduce the number of objects in the bigger heap to make the heaps equal. After that, no matter what move your opponent makes, you can make the same move on the other heap, guaranteeing that you take the last object. When played as a misère game, Nim strategy is different only when the normal play move would leave no heap of size 2 or larger. In that case, the correct move is to leave an odd number of heaps of size 1 (in normal play, the correct move would be to leave an even number of such heaps). In a misère game with heaps of sizes 3, 4 and 5, the strategy would be applied like this: A B C Nim-sum 3 4 5 0102=210 I take 2 from A, leaving a sum of 000, so I will win. 1 4 5 0002=010 You take 2 from C 1 4 3 1102=610 I take 2 from B 1 2 3 0002=010 You take 1 from C 1 2 2 0012=110 I take 1 from A 0 2 2 0002=010 You take 1 from C 0 2 1 0112=310 The normal play strategy would be to take 1 from B, leaving an even number (2) heaps of size 1. For misère play, I take the entire B heap, to leave an odd number (1) of heaps of size 1. 0 0 1 0012=110 You take 1 from C, and lose. Proof of the winning formula The soundness of the optimal strategy described above was demonstrated by C. Bouton. Theorem. In a normal Nim game, the first player has a winning strategy if and only if the nim-sum of the sizes of the heaps is nonzero. Otherwise, the second player has a winning strategy. Proof: Notice that the nim-sum (⊕) obeys the usual associative and commutative laws of addition (+), and also satisfies an additional property, x ⊕ x = 0 (technically speaking, the nonnegative integers under ⊕ form an Abelian group of exponent 2). In mathematics, associativity is a property that a binary operation can have. ...
A map or binary operation from a set to a set is said to be commutative if, (A common example in school-math is the + function: , thus the + function is commutative) Otherwise, the operation is noncommutative. ...
In mathematics, an abelian group, also called a commutative group, is a group such that for all a and b in G. In other words, the order of elements in a product doesnt matter. ...
In group theory in mathematics, a periodic group is a group in which each element has finite order. ...
Let x1, ..., xn be the sizes of the heaps before a move, and y1, ..., yn the corresponding sizes after a move. Let s = x1 ⊕ ... ⊕ xn and t = y1 ⊕ ... ⊕ yn. If the move was in heap k, we have xi = yi for all i ≠ k, and xk > yk. By the properties of ⊕ mentioned above, we have t = 0 ⊕ t = s ⊕ s ⊕ t = s ⊕ (x1 ⊕ ... ⊕ xn) ⊕ (y1 ⊕ ... ⊕ yn) = s ⊕ (x1 ⊕ y1) ⊕ ... ⊕ (xn ⊕ yn) = s ⊕ 0 ⊕ ... ⊕ 0 ⊕ (xk ⊕ yk) ⊕ 0 ⊕ ... ⊕ 0 = s ⊕ xk ⊕ yk (*) t = s ⊕ xk ⊕ yk. The theorem follows by induction on the length of the game from these two lemmata. Lemma 1. If s = 0, then t ≠ 0 no matter what move is made. Proof: If there is no possible move, then the lemma is vacuously true (and the first player loses the normal play game by definition). Otherwise, any move in heap k will produce t = xk ⊕ yk from (*). This number is nonzero, since xk ≠ yk. Vacuous truth is a special topic of first-order logic. ...
Lemma 2. If s ≠ 0, it is possible to make a move so that t = 0. Proof: Let d be the position of the leftmost (most significant) nonzero bit in the binary representation of s, and choose k such that the dth bit of xk is also nonzero. (Such a k must exist, since otherwise the dth bit of s would be 0.) Then letting yk = s ⊕ xk, we claim that yk < xk: all bits to the left of d are the same in xk and yk, bit d decreases from 1 to 0 (decreasing the value by 2k), and any change in the remaining bits will amount to at most 2k−1. The first player can thus make a move by taking xk − yk objects from heap k, then t = s ⊕ xk ⊕ yk (by (*)) = s ⊕ xk ⊕ (s ⊕ xk) = 0. The modification for misère play is demonstrated by noting that the modification first arises in a position that has only one heap of size 2 or more. The normal play strategy is for the player to reduce this to size 0 or 1, leaving an even number of heaps with size 1, and the misère strategy is to do the opposite. From that point on, all moves are forced.
Other variations of the game In another game which is commonly known as Nim (but is better called the subtraction game S(1,2,...,k)), an upper bound is imposed on the number of stones that can be removed in a turn. Instead of removing arbitrarily many stones, a player can only remove 1 or 2 or ... or k at a time. This game is commonly played in practice with only one heap (for instance with k = 3 in the game Thai 21 on Survivor: Thailand, where it appeared as an Immunity Challenge). Survivor: Thailand was the fifth installment of the popular United States reality show Survivor. ...
Bouton's analysis carries over easily to the general multiple-heap version of this game. The only difference is that as a first step, before computing the Nim-sums, we must reduce the sizes of the heaps modulo k + 1. If this makes all the heaps of size zero (in misère play), the winning move is to take k objects from one of the heaps. In particular, in a play from a single heap of n stones, the second player can win iff Modular arithmetic (sometimes called modulo arithmetic, or clock arithmetic because of its use in the 24-hour clock system) is a system of arithmetic for integers, where numbers wrap around after they reach a certain value â the modulus. ...
It has been suggested that this article or section be merged into Logical biconditional. ...
- n ≡ 0 (mod k+1) (in normal play), or
- n ≡ 1 (mod k+1) (in misère play).
This follows from calculating the nim-sequence of S(1,2,...,k), ...
, from which the strategy above follows by the Sprague-Grundy theorem. In combinatorial game theory, the SpragueâGrundy theorem states that every impartial game is equivalent to a nimber. ...
In misère play with the game "21", where loss is achieved through speaking 21, only 1, 2 or 3 can be taken at once. Counting starts from 1 and switches from one player to another, and any amount of players can take part, within reason. With two players, by the above rules the way to win is to leave a multiple of k+1 (k being 3), +1 - that is, leave a multiple of 4, plus 1. Indeed any number may be chosen to start. A further variation of Nim is 'Circular Nim' where any number of pieces are placed in a circle, and 1, 2 or 3 are taken alternately between 2 players. These pieces must be touching each other in the circle, i.e. in a circle of 10: . . . . . . . . . . 3 can first be taken _ . . . . . . . _ _ then another 3 _ . _ _ _ . . . _ _ then 1 _ . _ _ _ . . _ _ _ but now three counters cannot be taken out at once.
See also In combinatorial game theory, the zero game is the game where neither player has any legal options. ...
In combinatorial game theory, star, written as or , is the value given to the game where both players have only the option of moving to the zero game. ...
This article may be too technical for most readers to understand. ...
A two-player game can be solved on several levels. ...
Subtract-a-square (also referred to as take-a-square) is a two-player mathematical game of strategy starting with a positive integer and both players taking turns subtracting a non-zero square number not larger than the current value. ...
Image:DRNIM 1. ...
References - W. W. Rouse Ball: Mathematical Recreations and Essays, The Macmillan Company, 1947.
- John D. Beasley: The Mathematics of Games, Oxford University Press, 1989.
- Elwyn R. Berlekamp, John H. Conway, and Richard K. Guy: Winning Ways for Your Mathematical Plays, Academic Press, Inc., 1982.
- C. L. Bouton: Nim, a game with a complete mathematical theory, Annals of Mathematics 3 (1901-02), 35-39.
- Manfred Eigen and Ruthild Winkler: Laws of the Game, Princeton University Press, 1981.
- Walter R. Fuchs: Computers: Information Theory and Cybernetics, Rupert Hart-Davis Educational Publications, 1971.
- G. H. Hardy and E. M. Wright: An Introduction to the Theory of Numbers, Oxford University Press, 1979.
- Edward Kasner and James Newman: Mathematics and the Imagination, Simon and Schuster, 1940.
- M. Kaitchik: Mathematical Recreations, W. W. Norton, 1942.
- Donal D. Spencer: Game Playing with Computers, Hayden Book Company, Inc., 1968.
External links |