Bash game and Weizuo Fu Game

Game Bash (Bash Game)

Only a pile of n items, two turns from the stack article extract, every predetermined number can take 1 ~ m. Finally, by taking the light win.

Obviously, if n = m + 1, then since a maximum number of m can, therefore, no matter how many first take away persons, who can after taking away a remaining items, which win. So we find that the winning codes: If n = (m + 1) r + s, (r is an arbitrary natural number, s≤m), then the first taker to take a s article, if after taking away by k (≤ m) a, then first taken away from further a m + 1-k, the remaining results (m + 1) (r- 1) th, after maintaining such emulated, then the first taker certainly win. In short, to keep the left multiples (m + 1) to the opponent can finally win .

That is, if n = k * (m + 1), then after taking the win, on the contrary, the presence of first take wins emulated.

n% (m + 1) == 0. taker first losing .
    This game can also be a disguised form of play: Two people reported that the number of turns, each at least a newspaper, reported that up to ten, who can register 100 wins. The equivalent of taking stones from a pile of 100 stones, the last to take complete victory.

1     static boolean f(int n,int m){
2         if(n%(m+1)==0)        return false;
3         else    return true;
4     }

 

Weizuo Fu Game (Wythoff Game)

There are several piles of each article, two turns taken from a pile or simultaneously from as many piles of articles, each at least take a predetermined, limited multi-person, by winning the final light extraction.

    This case is quite complex. We use (ak, bk) (ak ≤ bk, k = 0,1,2, ..., n) represents the number of piles of articles saying that the situation is, if the A face (0,0), then A has been lost, we call this situation strange situation. Singular previous situation is: (0,0), (1,2), (3,5), (4,7), (6,10), (8,13), (9,15), ( 11, 18), (12, 20).
    As can be seen, a0 = b0 = 0, ak is the minimum natural number not appear in front off, and bk = ak + k, singular situation has
the following three properties: 1. Any natural numbers are contained in one and only one bizarre situation.  Since ak is the smallest natural number not appear in front of, therefore they have ak> ak-1, and bk = ak + k> ak- 1 + k-1 = bk-1> ak-1. So nature 1. Established. 2. Any operating situation can become singular non-singular situation.  In fact, change only the strange situation (ak, bk) of one component, the other component is impossible in other bizarre situations, it must be non-singular situation. If so (ak, bk) while reducing the two components, due to its poor unchanged, and the difference can not be other bizarre situation, and therefore non-singular situation. 3. Using appropriate methods, non-singular situation can be turned into bizarre situation.

    
   
    
   
    

    The situation is assumed that the face (a, B), if b = a, are simultaneously removed from a two piles of two objects, the singular situation becomes (0,0); if a = ak, b> bk, then , removed b - bk two objects, i.e., becomes singular situations; if a = ak, b <bk, while the piles away from the ak - ab - ak two objects, the situation becomes singular (ab - ak, ab - ak + b - ak); if a> ak, b = ak + k, from the first stack away the excess amount of a - ak can; If a <ak, b = ak + k, two situations , a first, a = aj (j <k ), b away from the second stack inside - bj can; second, a = bj (j <k ), b away from the second stack inside - aj It can be.

    As can be seen from nature, if two people are using the correct operation, then the face of non-singular situation, those who acquire a win; on the contrary, the latter who took to win.

    So given any situation (a, b), how to judge it is not strange situation do? We have the following formula:
    AK = [K (+ √5. 1) / 2], AK + BK = K (K = 0,1,2, ..., n-brackets indicate rounding function)
marvelous arise in which golden division number (1 + √5) / 2 = 1.618 ..., and therefore, the rectangular ak, bk consisting of gold approximately rectangular, since 2 / (1 + √5) = (√5-1) / 2 may be determined to 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 strange situation. Then follow the above rules were, will encounter strange situation.

1   static boolean f(int a,int b){
2         double r = (Math.sqrt(5.0)+1)/2;
3         double d = Math.abs(a-b)*r;
4         if(d != Math.min(a, b))        return true;
5         else    return false;
6     }

Recommended article: https: //www.cnblogs.com/Tunix/p/4297944.html

Guess you like

Origin www.cnblogs.com/AIchangetheworld/p/12185308.html