Original link Click to open the link
It focuses on three of the more common game of chance
Bash Game, Nim Game and Wythoff Game, more lead people wonder is that they are the perfect solution by the last number theory or the nature of natural numbers:
Bash Game: congruence theory
Nim Game: XOR theory
Wythoff Game: Golden
(1) Bash Game: a stack of n items, they take turns, take 1 to m, finally taking complete wins
For example the article 10, can only take 1-5, the upper hand side will win
1. face [1 ... m] a situation, win2 m + 1 th face situation, would lose
3. If opponent face losing situation, it will win situation is
4. If it is not an opponent facing losing situation, it is a losing situation
base: 1, 2, ..., m will win situation is, m + 1 is a losing situation
recursion: m + 2, m + 3 , ..., 2m + 1 is a situation will win, 2m + 2 is a losing situation
...
k (m + 1) is a losing situation should be allowed to k = 0, since 0 is apparently losing situation
In Board and will losing a win, the winning party policy is: removed portion of the article, so that the other face k (m + 1) the situation
For example, in the example above 10 items, only take 1-5 upper hand side can take four, take no matter how many opponents, always next time you could get finished
Thinking this problem from another perspective, if the random number of items, the probability of the winning side upper hand is m / (m + 1), FLAC Fang Shengli probability is 1 / (m + 1)
(2) Nim Game: m n number of stack items, take turns, each taking a stack of not less than 1, and finally taking complete wins
Detailed analysis, see: POJ-2234: the Matches Game
The number of items all binary XOR to zero, the upper hand will loseall binary XOR number of items is not 0, then flip to lose
thinking about the problem from another angle, if the number of random items, then the number of each every 0 or 1 with equal probability,
if there is an odd number of stacks, the number 1 is the probability of the same even or odd,
if the stack has an even number, then the probability of an even number of 1s slightly larger 1 / (m + 1),
That XOR result is every probability of 0 or 1 are almost the same, but will lose the upper hand requires an exclusive-oR each bit is 0, in fact, the probability of losing is very small
(3) Wythoff Game: piles (ak, bk) (ak <= bk) th items, they take turns, each taken from a stack 2 from the stack of k or k - simultaneous, facing the last ( 0,0) input situation (provided ak <= bk is to ignore the effects of the order)
1. face (0,0) must lose situation
2. face (1,1) (2,2) ... ( n, n) the situation will win(0,1) (0,2) ... ( 0, n) must win situation
3. If you can opponent face losing situation, it will win situation is
4. If the opponent does not face losing situation, it is a losing situation
base: (0,0) is a losing situation; (0,1) (0, 2) ... (0, n) is the situation will win,
recursive: (1,2) is a losing situation; (1,1) will win situation is
(1,3) (1, 4) ... (1 , n) is a must win situation
(2,2), (2,3) ... (2, n) will win situation is the
(3,5) is a losing situation; (3,3) (3,4) will win situation is
(3,6) (3,7) ... ( 3, n) will win situation is
(5,5) (5,6) ... ( 5, n) is the situation will win
(4 , 7) is a losing situation; (4,4) (4,5) (4,6) will win situation is
(4,8) (4,8) (4,9 ) ... (4, n) It is a must win situation
(7,7) (7,8) (7,9 ) ... (7, n) is the situation will win
(6, 10) is a losing situation; (6,6) (6,7) (6, 8) (6,9) will win situation is
(6,11) (6,12) (6,13 ) ... (6, n) is the situation will win
(10,10) (10,11) (10 , 12) ... (10, n ) will win situation is
first found :( law law losing situation relatively easy to find)
AK is the number of innings to lose the foregoing appears smallest,
BK = AK + K (K = 0,1,2,3, ... n)
Here are the most important properties of losing Bureau (Bureau singular) of:
1,2, ..., n are each a natural number, it appears once and only in one singular bureau.Derivation: 1 ak always selected because the number does not appear, so that each can be present in the total number of the singular Bureau
and ak is not selected to the number of repeating
2.bk = ak + k, bk is always so than the previous all singular innings appear are large,
so bk will not choose to repeat the number
Will win the party's strategy is: always let the opponents face losing Bureau (singular Bureau)
Given any situation (a, b), the determination (a, b) whether the method is losing Board is:
k = 0,1 ... n记黄金比例是φ = 1.618033AK = [k * φ], BK = AK + k = [k * φ * φ]
如k = 0, a = 0, BK = 0
K = 1, a = 1, BK = 2
k = 2, a = 3, BK = 5 k = 3, a = 4, BK = 7
A better strategy is to determine k = bk-ak, such as ak = k * φ, the current situation is singular Bureau
From the perspective of the probability of the outcome, if the number of random heap, just get one of the big advantages
(Corresponding classical entitled POJ-1067)
Three games are very similar, but the difference between winning strategy and determine the situation has been enormous, and yet both from the nature of numbers, have to say this is an amazing thing.
![](http://avatar.csdn.net/9/E/C/3_weixin_38960774.jpg)