【小学数学】NIM游戏相关
标签:
nim游戏策略 |
分类: 数学世界 |
李新社编著2006版《离散数学》认为:Nim游戏,中国称之为“抓三堆”或“拧法”,国外称之为“Chinese Game of Nim”或者 “Simple Game of Nim”。
(美)加德纳著2012《悖论与谬误》认为:所有二人数学游戏里,最古老、最有魅力的一种是现在叫做尼姆(Nim)的游戏;它可能发源于中国,有时候孩子们用纸片玩,而成人则在吧台上用硬币玩。美国布鲁迪著2012版《组合数学》则认为Nim游戏名称来自德语Nimm(意为拿取)。
檀越主编2009版《数学的秘密》认为:“关于NIM游戏源于中国的说法,见于国内多本介绍数学游戏的小册子。但迄今未发现我国古代文献中有关于它的记载。对此的解释是,按我国古代的传统,数学作为‘奇技淫巧’不足以登大雅之堂,难以在经史中占一席之地:在我国民间,确实流传着这种游戏,北方叫作‘抓三堆’,南方叫‘拧法’、‘翻摊’。”
1.对于一堆轮流取子系列的NIM游戏
(I) 规定取最后的一个赢:比如取牌游戏或者爬台阶游戏
每次可取数目在1到m之间时,
(a)初始总数不是(m+1)的倍数,先手第一步让剩下的数目为(m+1)*n,之后若对手取子k就取m+1-k,则先手必胜。
(b)初始总数是(m+1)的倍数,若对手取子k就取m+1-k,则后手必胜。
(II)规定取最后的一个输:比如下面的flash游戏
每次可取数目在1到m之间时,
(a)初始总数不是(m+1)*n+1,先手第一步让剩下的数目为(m+1)*n+1,之后若对手取子k就取m+1-k,则先手必胜。
(b)初始总数是(m+1)*n+1,若对手取子k就取m+1-k,则后手必胜。

Count the matchsticks in
each row... And convert them mentally in multiples of 4, 2 and 1.
Then, CANCEL pairs of equal multiples, and add what is left. So,
when starting, the “Nim sum” of the rows is:
| Row1 = 1 | = 1 x 1 = 1 | = | |
|
| Row2 = 3 | = 1 x 2 + 1 x 1 | = | ||
| Row3 = 5 | = 1 x 4 + 1 x 1 | = |
||
| Row4 = 7 | = 1 x 4 + 1 x 2 + 1 x 1 | = |
||
| Total of UNPAIRED multiples | = 0 | 0 | 0 | |
As you can see, there are currently TWO 4’s, TWO 2’s, and FOUR 1’s (= TWO + TWO + FOUR = 8). You have then an EVEN number of multiples, the remainder after dividing this number (8) by 2 gives 0.
To win at Nim-game, always make a move, whenever possible, that leaves a configuration with a ZERO “Nim sum”, that is with ZERO unpaired multiple(s) of 4, 2 or 1. Otherwise, your opponent has the advantage, and you have to depend on his/her committing an error in order to win.
How to leave a zero
“Nim sum”:
Your opponent moves and leaves you the following
configuration:
| Row1 = 1 | = 1 x 1 | = | |
|
| Row2 = 3 | = 1 x 2 + 1 x 1 | = | ||
| Row3 = 5 | = 1 x 4 + 1 x 1 | = |
||
| Row4 = 5 | = 1 x 4 + 1 x 1 | = |
||
| Total of unpaired multiples | = 0 | 1 | 0 | |
Get rid of ONE 2, by taking 2 matchsticks from the 2nd row. That leaves your opponent at 1, 1, 5, 5 which is, for him, a losing configuration...
| Row1 = 1 | = 1 x 1 | = | |
|
| Row2 = 1 | = 1 x 1 | = | |
|
| Row3 = 5 | = 1 x 4 + 1 x 1 | = |
||
| Row4 = 5 | = 1 x 4 + 1 x 1 | = |
||
| Total of unpaired multiples | = 0 | 0 | 0 | |
Every time you leave your opponent a zero “Nim sum” configuration, you increase your chances to win! Here below are listed all the possible zero “Nim sum” configurations (sometimes, the order has no importance, for example: 3, 3, 1, 1 or 3, 1, 3, 1 has the same result). You can print the table and use it as a cheat sheet... But you can also improve your concentration skills by practicing “Nim sums” mentally!
| four rows | three rows | two rows |
| 7, 4, 2, 1 6, 5, 2, 1 6, 4, 3, 1 5, 5, 1, 1 4, 4, 1, 1 3, 3, 1, 1 2, 2, 1, 1 |
7, 5, 2 7, 4, 3 6, 5, 3 6, 4, 2 5, 4, 1 3, 2, 1 1, 1, 1 |
5, 5 4, 4 3, 3 2, 2 |
| Source: © G. Sarcone, www.archimedes-lab.org | ||

加载中…