Combined mathematics-nim sub-game

Source: Internet
Author: User

Combined mathematics-nim sub-game

<>

Nim play is a game where two people face several coins (or stones. With K> = 1 heap of coins, each heap contains N1, N2 ,...... NK coins. The goal of the game is to choose the last remaining coin. The rules of the game are as follows: 1. two gamers play the game in turn (game player I and game player II); 2. when it is the turn of every player to fetch, select a heap of these stacks and take at least one coin from the selected heap (the player can take all the coins from the heap he selected); 3. when all the heap changes to an empty heap, the winner is the final gamer. The variables in this game are heap K and heap coin N1, N2 ,...... NK. The corresponding combination problem is: Determine whether the player I wins or the player II wins and how the two players should take the child to ensure that they can win (the winning strategy ). To further understand the NIM sub-game, we examine some special cases. If the game starts with only a pile of coins, player I wins by taking all the coins away. There are now 2 heaps of coins, and the number of coins is N1 and N2, respectively. A player's victory does not depend on the exact values of N1 and N2, but on their equality. Set N1! = N2: the number of coins that the gamer I took from the heap is equal to that of the two heap coins. As a result, the number of sub-Coins obtained by the gamer I is equal to that of player II and eventually wins. However, If n1 = n2, game player II only needs to take the same number of coins in the other heap according to the number of game player I, and the final winner will be game player II. In this way, the two heap sub-winning strategies have been found. How can we extend the two-heap sub-policy to any heap number? First, let's recall that each positive integer has a corresponding binary number, for example: 57 (10) à 111001 (2), that is: 57 (10) = 25 + 24 + 23 + 20. Therefore, we can think that each heap of coins is composed of two power sub-heaps. In this way, the heap containing 57 coins can be considered as a sub-heap consisting of 25, 24, 23, and 20 respectively. The size of each heap is N1, N2 ,...... The general Nim sub-game of NK. Represent each number Ni as its binary number (the number of digits is equal, and 0 is added before unequal values): n1 =... A1a0n2 = BS... B1b0 ...... Nk = Ms... M1m0 if the number of sub-heaps of every size is an even number, we will say that the NIM sub-game is balanced, and the sum of the corresponding bits is an even number, otherwise, it is called an unbalanced bit. Therefore, the NIM sub-game is balanced when and only when:

As + BS +... + The MS is an even number

......

A1 + B1 +... + M1 is an even number.

A0 + b0 +... + M0 is an even number.

So we can get a winning strategy: player I can win in a non-balanced sub-game, while player II can win in a balanced sub-game. We used a two-heap coin Nim sub-game as an experiment. When the game starts, the game is in an unbalanced state. In this way, the gamer I can use a sub-Fetch method so that the sub-fetch is left to the gamer II as a balanced game, and then no matter how the gamer II gets the sub-play, the player I must be a non-balanced game. After the player II obtains the sub-state in the last balanced state, game Player I can take all the coins at a time to win. If the game is in a balanced status at the beginning of the game, take the sub-account in the above method and final player II will win. The following uses this winning strategy to consider 4-heap Nim sub-game. The heap size is 7, 9, 12, and 15 coins respectively. In binary format, the numbers are 0111,1001, 1100, and 1111 respectively. The following table is displayed:
 

23 = 8

22 = 4

21 = 2

20 = 1

Heap with a size of 7 0 1 1 1
Heap with a size of 9 1 0 0 1
Heap with a size of 12 1 1 0 0
Heap with a size of 15 1 1 1 1
It can be seen from the balancing condition of the NIM sub-game that this game is a non-balanced sub-game. Therefore, the gamer I will surely win the final victory in a sub-game based on the winning strategy. There are many specific practices. Game Player I can take 11 coins from the heap of 12 to balance the game (as shown in the following table ),
 

23 = 8

22 = 4

21 = 2

20 = 1

Heap with a size of 7 0 1 1 1
Heap with a size of 9 1 0 0 1
Heap with a size of 12 0 0 0 1
Heap with a size of 15 1 1 1 1
Then, no matter how game player II gets the child, game player I still balances the game after the child is obtained. In the same way, game player I can also choose a heap of 9 and take 5 coins while 4 are left, or, game Player I removed 13 from the heap of 15 and left 2. In the final analysis, the key to a nim sub-game is the status (balanced or unbalanced) of the game at the beginning and whether the first player can play the game based on the winning strategy of the sub-game.

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.