CDN加速镜像 | 设为首页 | 加入收藏夹
当前位置: 首页 资源下载 源码下载 Windows编程

文件名称:Nim

  • 所属分类:
  • 标签属性:
  • 上传时间:
    2012-11-16
  • 文件大小:
    260.59kb
  • 已下载:
    0次
  • 提 供 者:
  • 相关连接:
  • 下载说明:
    别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容来自于网络,使用问题请自行百度

Nim游戏(The game of Nim)是一个很著名而且有很多版本的游戏.下面这个版本有一个有趣的获胜策略.两名参与者交替从一堆石子中取出若干数目,其个数由参与者自已决定.但是要求参与者每次至少取出一个,至多取出一半,然后另一名参与者继续.拿到最后一个石子的参与者将输掉该游戏.

编写一个程序,让计算机和人较量.在10到100之间生成一个随机数作为初始的石子数目.然后,随机产生0或1,以决定是计算机先玩还是人先玩.然后,再随机产生0或1,以决定计算机采用"聪明"还是"愚蠢"模式.在愚蠢模式中,在轮到计算机时,简单地取走随机数目(介于1到n/2之间)的石子 在聪明模式中,计算机每次取走一定数目的石子,使得剩下的石子数目是2的某次幂减1,例如3,7,15,31,63.这总是可行的,除非当前的石子数正好是2的某次幂减1.在这种情况下,计算机取走随机数目的石子.

你将会发现,当计算机在聪明模式下且是先下手时,它总是不可击败的,除非原始石子数目很偶然的是2的某次幂减1.例如15,31,63.当然,如果人是先手而且知道获胜策略时,也是可以战胜计算机的.

-Nim game (The game of Nim) is a well-known and there are many versions of the game. Here is an interesting version of a winning strategy. Two players alternately remove stones from the pile of a certain number, the number of the participants own decision. but requires participants to take out at least one time, up to remove the half, and then the other participants to continue. get the last stone of the participants will lose the game.

Write a program that allows computers and the throne. 10 to 100 generate a random number as the initial number of pebbles. And then, randomly generated 0 or 1, to determine whether to play or people get the computer to play first. Then, again randomly produce 0 or 1, to determine the computer using "smart" or "stupid" mode. in stupid mode, the turn of the computer, simply pick random number (from 1 to n/2 between) the stones in smart mode, the computer each time you pick a certain number of stones, making the number of remaining stones is a power of 2
相关搜索: nim The Game of Nim

(系统自动生成,下载前可以参看下载内容)

下载文件列表

Nim/Debug/Main.obj
Nim/Debug/Nim.exe
Nim/Debug/Nim.ilk
Nim/Debug/Nim.obj
Nim/Debug/Nim.pch
Nim/Debug/Nim.pdb
Nim/Debug/vc60.idb
Nim/Debug/vc60.pdb
Nim/Main.cpp
Nim/Nim.cpp
Nim/Nim.dsp
Nim/Nim.dsw
Nim/Nim.h
Nim/Nim.ncb
Nim/Nim.opt
Nim/Nim.plg
Nim/nim游戏的说明.txt
Nim/Debug
Nim

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 搜珍网是交换下载平台,只提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。更多...
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或换浏览器;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*快速评论: 推荐 一般 有密码 和说明不符 不是源码或资料 文件不全 不能解压 纯粹是垃圾
*内  容:
*验 证 码:
搜珍网 www.dssz.com