Game Analysis (the mathematical problem of stone game)

Source: Internet
Author: User
Stone Acquisition Problems

Stone Acquisition Problems

There is a very interesting game, that is, there are several heaps of objects, either matchsticks or pawn pieces. The two take several objects from the heap in turn, and the final winner of the light object is required. This is an ancient game in China. Although this game is extremely simple, it contains profound mathematical principles. Next we will analyze how we can win.

(1) bash game: there are only a bunch of N items, two people take things in turn from the pile of items, each time at least one, a maximum of M. The final winner wins.


Obviously, if n = m + 1, a maximum of m items can be taken at a time. Therefore, no matter how many items are taken by the first accessor, the latter can take the remaining items at a time, the latter wins. Therefore, we discovered the rule of How to Win: If n = (m + 1) R + S, (R is an arbitrary natural number, S ≤ m ), the first accessors must take s items. If the second accessors take K (≤ m) items, the first accessors take m + 1-K items, and the result is (m + 1) (r-1), and later to maintain such a method, then the first accessors certainly win. In short, we need to leave a multiple (m + 1) to the opponent to win.

This game can also have a disguised gameplay: two people report at least one message each time, and a maximum of ten messages each time. Who can report to the 100 winner.
(2) wythoff game: There are several items in two stacks. Two people take the same number of items from one or both stacks in turn, it is required to take at least one image at a time. There are no restrictions on the number of images. The winner wins the prize.

In this case, it is quite complicated. We use (AK, BK) (Ak ≤ BK, K = 0, 1, 2 ,..., n) indicates the number of items in two heaps and the situation. If a faces (0, 0), a has lost. This situation is called a strange situation. The first few strange situations are), (12, 20 ).

It can be seen that a0 = b0 = 0, AK is the minimum natural number that has not appeared before, and BK = ak + K, the singular situation has

Three properties are as follows:


1. Any natural number is contained in one and only one singular situation.

Since AK is the minimum natural number that has not appeared before, so there is Ak> ak-1, and BK = ak + k> ak-1 + k-1 = bk-1> ak-1. So the property 1. Yes.

2. Any operation can change a singular situation to a non-singular situation.

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

3. An appropriate method can be used to convert a non-singular situation into a singular situation.


Assume that the situation is (A, B). If B = A, A is taken from both heaps to a strange situation ); if a = ak, B> BK, then the objects B-BK are taken away, which becomes a singular situation. If a = ak, B <BK, the AK-AB-ak objects are taken from the two stacks at the same time to change to a singular situation (AB-ak, AB-ak + B-ak). If a> AK, B = ak + K, then the excess A-ak can be taken from the first heap. If a <AK, B = ak + k, there are two cases: the first, A = AJ (J
<K), just remove B-BJ from the second heap; the second is a = BJ (j <K), and then remove B-AJ from the second heap.


From the above nature, we can see that if both of them adopt the correct operation, the winner will win in the face of non-singular situations. Otherwise, the winner will win.


How can we determine whether a situation (A, B) is a singular situation? We have the following formula:

Ak = [K (1 + √ 5)/2], BK = ak + K (k = 0, 1, 2,..., n square brackets indicate the entire function)

What's amazing is that there is a golden split (1 + √ 5)/2 = 1. 618 ..., therefore, the rectangle composed of AK and BK is approximately a golden rectangle, because 2/(1 + √ 5) = (√ 5-1)/2, you can obtain J = [A (√ 5-1)/2] first. If a = [J (1 + √ 5)/2], then a = AJ, bj = AJ + J. If it is not equal to, a = AJ + 1, BJ + 1 = AJ + 1 + J + 1. If it is none, it is not a strange situation. Then, according to the above rules, there will be a strange situation.

(3) nimm game: There are three stacks of several items, and two people take multiple items from one pile in turn. It is required that at least one item be taken at a time, the final winner wins.


This situation is the most interesting. It is closely related to binary. We use (a, B, c) to represent a situation. First (0, 0, 0) is obviously a strange situation, no matter who faces a strange situation, it will inevitably fail. The second singular situation is (0, n, n). As long as the opponent takes the same number of items, the last result will be (0, 0, 0 ). After careful analysis, (, 3) is also a strange situation. No matter how the opponent gets it, it can be changed to (0, N, N.


In computer algorithms, there is an operation called bitwise modulo 2 plus, or an exclusive or operation. We use the symbol (+) to represent this operation. The difference between this operation and general addition is that 1 + 1 = 0. First, let's look at the result of adding (1, 2, 3) the bitwise modulo 2:


1 = binary 01

2 = binary 10

3 = binary 11 (+)

-------

0 = binary 00 (do not carry)


For singular situations (0, n, n), the result is also 0.


Any singular situation (a, B, c) has a (+) B (+) C = 0.


If we are dealing with a non-singular situation (A, B, C), how can we change it to a singular situation? Assume that a <B <C, we only need to change C to a (+) B, because there are the following calculation results: a (+) B (+) (a (+) b) = (a (+) A) (+) (B (+) B) = 0 (+) 0 = 0. To change C to a (+) B, subtract C-(a (+) B) from C.

 

When judging whether it is a strange situation in the xianzov game, for example, if two numbers A and B are involved, you can first exchange a <B, and then remember I = B-, in a singular situation, M = floor (I * (1 + SQRT (5.0)/2) and B = m + I. Otherwise, it is not a singular situation!

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.