现在的位置: 首页 > 综合 > 正文

acm应用——博弈论Sprague–Grundy theorem

2019年11月06日 ⁄ 综合 ⁄ 共 2809字 ⁄ 字号 评论关闭

在百度百科找了一下关于 Sprague–Grundy theorem,发现是从维基百科上面直接用软件翻译的(呵呵,百度是没人了吗?)。于是,在维基上面看了看,找了两段话,大概翻译了一下。网址分别是

http://en.wikipedia.org/wiki/Sprague%E2%80%93Grundy_theorem

http://en.wikipedia.org/wiki/Nimber

原文:

In combinatorial game theory, the Sprague–Grundy theorem states that every impartial game under the normal play convention is equivalent to a nimber. The Grundy value or nim-value of an impartial game is then defined as the unique nimber that the game is equivalent
to. In the case of a game whose positions (or summands of positions) are indexed by the natural numbers (for example the possible heap sizes in nim-like games), the sequence of nimbers for successive heap sizes is called the nim-sequence of the game.

The theorem was discovered independently by R. P. Sprague (1935) and P. M. Grundy (1939).

翻译:
在组合数学理论中,有一个Sprague–Grundy定理:有一定游戏规则的公平游戏是可以等价成一个nimber的。一个公平游戏的Grundy数(也叫做nim数)是可以很明确地等价成一个唯一的nimber。

原文:
In mathematics, the nimbers, also called Grundy numbers, are introduced in combinatorial game theory, where they are defined as the values of nim heaps. They arise in a much larger class of games because of the Sprague–Grundy theorem. The nimbers are the ordinal
numbers endowed with a new nimber addition and nimber multiplication, which are distinct from ordinal addition and ordinal multiplication.

翻译:

在数学中,nimbers也被叫做Grundy数,这是一个在组合数学里的概念,在组合数学中,他们被定义成 “nim堆”的值。由于Sprague–Grundy定理,它们出现在许多游戏的例子中。

具体证明,由于英语能力有限,就木有看下去了。反正大概就是说,只要是公平游戏,就可以转换成博弈论中的nim情况来处理。

公平游戏:即无偏博弈,下面引自维基的说法

在组合博弈论里,无偏博弈是一类任意局势对于游戏双方都是平等的回合制双人游戏。这里平等的意思是所有可行的走法仅仅依赖于当前的局势,而与现在正要行动的是那一方无关。换句话说,两个游戏者除了先后手之外毫无区别。此外,它们还要满足一些组合游戏的基本条件:

    完全信息,所有游戏者都能看到整个局势。这排除了类似桥牌一类的游戏。
    无随机行动。所有行动都确定性地将目前局势转变到下一个局势。
    在有限步行动之后按照规则游戏必将终止,此时有唯一的一方成为赢家。

nim:以下引自维基原文(http://en.wikipedia.org/wiki/Nim)

Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object,
and may remove any number of objects provided they all come from the same heap.

大概是这个意思:

Nim是一个数学策略游戏,在这个游戏里,两个玩家在不同的状态下轮流移动物体。在每回合中,一个玩家至少能移动一个物体,并且他们改变后的状态都能够从相似的某个状态变换得到。

下面贴个实例,来自杭电oj(http://acm.hdu.edu.cn/showproblem.php?pid=1848):

Problem Description
任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:
F(1)=1;
F(2)=2;
F(n)=F(n-1)+F(n-2)(n>=3);
所以,1,2,3,5,8,13……就是菲波那契数列。
在HDOJ上有不少相关的题目,比如1005 Fibonacci again就是曾经的浙江省赛题。
今天,又一个关于Fibonacci的题目出现了,它是一个小游戏,定义如下:
1、  这是一个二人游戏;
2、  一共有3堆石子,数量分别是m, n, p个;
3、  两人轮流走;
4、  每走一步可以选择任意一堆石子,然后取走f个;
5、  f只能是菲波那契数列中的元素(即每次只能取1,2,3,5,8…等数量);
6、  最先取光所有石子的人为胜者;

假设双方都使用最优策略,请判断先手的人会赢还是后手的人会赢。

 

Input
输入数据包含多个测试用例,每个测试用例占一行,包含3个整数m,n,p(1<=m,n,p<=1000)。
m=n=p=0则表示输入结束。
 

Output
如果先手的人能赢,请输出“Fibo”,否则请输出“Nacci”,每个实例的输出占一行。
 

Sample Input
1 1 1 1 4 1 0 0 0
 

Sample Output
Fibo Nacci

为了转换成nim游戏,分别找出m,n,p的类似数。比如说,对于数4,分别减去比它小的fibonacci数,得到1,2,3,然后再用1,2,3重复上述4的操作。

比如说,1,减去比它小的fibonacci数,得到0,那么0就不是它的类似数,只有1没出现,1的类似数就是1。

再比如说,2,减去它小的fibonacci数,得到1和0,因为0的类似数就是它本身,1的类似数就是1,只有2没出现,所以2的类似数就是2.

以此类推,得到3的类似数恰好也是3。

注意,类似数并不一定数的本身,推下去即可知道,4的类似数是0,因为最小没出现的数是0。

很容易,得到这道题的解题思路。至于为何这样去做,就需要深入了解上述的几个数学概念。因为我不会,所以,也就不证明了。

抱歉!评论已关闭.