The simple game theory takes the Stone

Source: Internet
Author: User
Tags bitwise

There is a very interesting game, that is, there are several piles of objects, can be a match stick or go son, etc. can be. Two took turns to take objects from the heap, stipulating that the last person to take the light would win. This is a very ancient Chinese folk game, although the game is extremely simple, but contains a profound mathematical principles. Let's examine how we can win.

(i) Ba Shi game (Bash game, congruence theory): only a bunch of n items, two people take turns from this pile of goods, the provision of at least one at a time, a maximum of M. Finally the light winner wins.

Obviously, if the n=m+1, then because a maximum of only m at a time, so, regardless of the number of first take away, the latter can take the remaining items at once, which wins. So we found the law of how to win: if N= (m+1) R+s, (R is any natural number, s≤m), then the first pick to take the S items, if the latter take away the K (≤m), then the first take the m+1-k, the result is left (m+1) (r-1), and later to maintain such a way, Then the first pick-up is sure to win. In short, to keep a multiple of the opponent left (m+1), you can win the final. This game can also have a disguised play: Two people turn off, at least one at a time, up to 10, who can report 100 wins.

(ii) Witzov game (Wythoff game, golden section): There are two piles of various items, two people take turns from a heap or at the same time from the two piles of the same number of items, the provisions of at least one at a time, more than unlimited, the last to win the light.

In this case it is quite complicated. We use (AK,BK) (AK≤BK, k=0,1,2,...,n) to indicate the number of items and call it the situation, if a face (0,0), then A has been lost, this situation we call the singular situation. The first few strange situations are: (0,0), (3,5), (4,7), (6,10), (8,13), (9,15), (11,18), (12,20). As can be seen, A0=b0=0,ak is not in front of the smallest natural number, and bk= AK + K, the singular situation has the following three properties:

1. Any natural number is contained in one and only one singular situation. Since AK is the smallest natural number not appearing before, there are AK > ak-1, and bk= AK + k > ak-1 + k-1 = bk-1> ak-1. So the nature of 1. Was founded.

2. Any operation can transform the singular situation into a non-singular situation.

In fact, if only one component of the singular situation (AK,BK) is changed, then the other component cannot be in other singular situations, so it must be a non-singular situation. If the two components of the (AK,BK) are reduced at the same time, it is also a non-singular situation because of its difference and the impossibility of being the difference between other singular situations.

3. The non-singular situation could be transformed into a singular situation by appropriate means. Assuming that the situation is (a, a), if B = A, then take a object from both piles at the same time, it becomes a singular situation (0,0);

If a = AK, B > BK, then take the B-bk object, which becomes the singular situation; if a = AK, b < BK, then take the Ak-ab-ak object from both piles and turn it into a singular situation (Ab-ak, ab-a K + B-ak); If a > AK,b= AK + K, take the excess quantity A-ak from the first heap;

If a < AK, b= AK + K, in two cases, the first, A=aj (J < K), take b-bj from the second heap, and the second, A=BJ (J < K), take B-aj from the second heap.

According to the nature of the above, two people if all use the correct operation, then face the non-singular situation, the first to win the winner;

So let's give a situation (a, B), how do you judge if it is a singular situation? We have the following formula: AK =[k (1+√5)/2],bk= AK + k (k=0,1,2,...,n square brackets represent the rounding function) The wonderful thing is that the Golden Section (1+√5)/2 = 1 appears. 618...,

Therefore, the rectangle composed of AK,BK is approximately the golden rectangle, because 2/(1+√5) = (√5-1)/2, you can first find J=[a (√5-1)/2], if A=[J (1+√5)/2], then A = aj,bj= AJ + j, if not equal, then a = Aj+1,bj+1 = aj+1+ J + 1, if not, then it is not a singular situation. Then according to the above-mentioned law, we will encounter strange situation.

(iii) NIM game (Nim game, xor theory): There are three piles of various items, two people take turns from a heap of any number of items, the provisions of at least one at a time, more than a few, the last person to win the light.

This is the most interesting situation, it is closely related to the binary system, we use (a,b,c) to denote a situation, first (0,0,0) is clearly a singular situation, no matter who face the singular situation, will inevitably fail.

The second singular situation is (0,n,n), as long as the opponent takes away as many items as the final result (0,0,0). A careful analysis is also a singular situation, and no matter how the opponent takes it, the next thing can be changed (0,n,n). There is a computer algorithm called bitwise modulo 2 Plus, also called XOR, we use the symbol (+) to denote this operation. The difference between this operation and the general addition is 1+1=0. First look at the results of the bitwise modulo 2 plus:

1 = Binary 01
2 = binary 10
3 = Binary 11 (+)
———————
0 = binary 00 (Note no rounding)

As for the singular situation (0,n,n), the result is also 0.

Any singular situation (a,b,c) has a (+) b (+) c = 0. If we are faced with a non-singular situation (a,b,c), how to become a singular situation? Suppose a < b< C, we just change C to a (+) B, because we have the following results: A (+) b (+) (A (+) b) = (A (+) a) (+) (b (+) b) =0 (+) 0=0. To change C to a (+) b, simply subtract C-(a (+) b).

Example 1. (14,21,39), 14 (+) 21=27,39-27=12, so it takes 12 objects from 39 to achieve a singular situation (21,27).

Example 2. (55,81,121), 55 (+) 81=102,121-102=19, so take 19 items from 121 to form a singular situation (55,81,102).

Example 3. (29,45,58), 29 (+) 45=48,58-48=10, removed 10 from 58, changed to (29,45,48).

Example 4. Let's actually take a game to see:
A : (7,8,9) (1,8,9) Strange Situation
B: (1,8,9) (1,8,4)
A : (1,8,4) (1,5,4) Strange Situation
B: (1,5,4) (1,4,4)
A : (1,4,4) (0,4,4) Strange Situation
B: (0,4,4) (0,4,2)
A : (0.4,2) (0,2,2) Strange Situation
B: (0,2,2) (0,2,1)
A : (0,2,1) (0,1,1) Strange Situation
B: (0,1,1) (0,1,0)
A : (0,1,0) (0,0,0) Strange Situation
Jia Sheng.

The simple game theory takes the Stone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.