Step 1. 甘地的原侵略指数1被保存为无符号(只表示非负数)整数类型,即二进制的00000001(这里用8位表示,16位,32位也一样)。
Step 2. 当进入民主政体时需要减去2,编译器会将减2转换成加-2,那么-2被保存为有符号(可以表示负数和正数)整数类型11111110(-2=-2∧7+2∧6+2∧5+2∧4+2∧3+2∧2+2∧1)。
Step 3. 当无符号数和有符号数做运算时,有符号数会被转化为无符号数,即-2的二进制11111110会被看成是无符号整型,但是每个二进制比特本身的值不会改变,运算结果也会被看成是无符号整型。
Step 4. 最后就是二进制加法了,00000001+11111110=11111111。由于结果被看成是无符号整型,因此结果为2∧7+2∧6+2∧5+2∧4+2∧3+2∧2+2∧1+2∧0=255。 ianhua 3小时前 0条评论
在文明1里面,印度是最和平的文明,但问题是有个设计上的疏漏。每个文明都有自己的“侵略性”这一隐藏属性,数值是1到10。民主政体能让侵略性降低2点。而印度本身的侵略性是1点。这个数值用的是一个无符号单字节整形变量存储。其结果就是一旦印度进入民主政体,侵略性就爆表了,变为255点。印度就忽然变成了全世界最疯狂的战争贩子。
而更加糟糕的是,民主和核武器的研发靠得很近。基本上印度进入民主以后没几个回合就研发出了核弹……然后凶残爆表的印度就开始疯狂造核弹并到处扔了。
谢谢 @李秋林提供原文。
What to expect when Facing Gandhi (Civ V) : gaming
For those wondering what the hell this is all about:
Every AI leader in Civ has different inherent values for how they act. Genghis Khan is warlike and aggressive, Gandhi is peaceful and defensive, with most leaders being in between.
There was a bug in Civ I. Gandhi's aggressiveness was set to 1 by the game (on a 1-10 scale). If an AI adopts Democracy as a government, the game notches their aggressiveness down 2. As a result, if Gandhi adopted Democracy, you got a rollover error that led to his aggressiveness being set at 255/10.
Needless to say, he very rapidly turns from peaceful to murderous, and will them attempt to acquire and build nukes at all costs. He'll then nuke whatever he damn well feels like, because he's Gandhi.
The Civ team loved this bug so much, they deliberately programmed similar AI into every game. In Civ V, for example, every leader has a 'Use of Nukes' stat, that is, again, on a scale of 1 to 10. Gandhi's is hard-coded at 12 - even with the +/- 2 random modifiers assigned at game start, Gandhi's use of nukes will always be rounded to 10/10 would nuke again.
冷哲 3小时前 0条评论- 上一个:同一秋宝宝肠胃不好,凭着了饭不怕拉粑粑,该怎样调理?
- 下一个:男说学校来黑幕,说好的自由报社团,最后都是先生为内定了。?