Nim: a row of rock games

Source: Internet
Author: User

Nim (1): A row of stone games

N stones are arranged in a row, each of which has a fixed position. Two players take stones in sequence. Each player can take any one of the stones or two adjacent stones each time. The stones cannot be one in the game (that is, the number will not change ), in the end, players who are able to win the remaining stones at a time.

The winning strategy of the first accessors: assume that the number of stones is N, and the first accessors take one (N is an odd number) in the middle or two (N is an even number) in the middle ), in short, make sure that the number of stones on both sides is the same after the first extraction, and then the first accessors only need to take the initial center as the axis of symmetry each time, take the same number of stones in the place corresponding to the stone position of the latter, you can not get the whole stone every time, and will get the final stone to win the game!

Nim (2) Game Analysis

There are n stones and two players A and B. Player A first splits the stones into several heaps and then follows bababa ...... The order of the remaining stones continues to take turns to win the players who can take the remaining stones once. Each time a player picks up a rock, each player can only choose one of several stones and take any number (greater than 0) of the stones.

If the number of stones is an even number, they are divided into two heaps, each of which has the same number. In this way, no matter how the opponent gets it, you only need to ensure that the security situation (x, x) will be followed by your victory;

If the number of stones is odd, no matter how the heap is divided, it will always win first.

Nim (3) Two-heap stone game

Assuming there are two piles of stones, two players will take turns to take the stones according to the following rules:

Each person can take the same number of stones from two piles of stones each time, or just take any number of stones from the pile of stones:

In the end, the only one who gets the remaining stones will win.

For example, if the number of stones is 1 and 2, the first player to take the stones will surely lose the 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.