蔡文能 cc++ 程式設計

蔡文能 cc++ 程式設計

ID:26791914

大小:1012.16 KB

页数:58页

时间:2018-11-29

蔡文能 cc++ 程式設計_第1页
蔡文能 cc++ 程式設計_第2页
蔡文能 cc++ 程式設計_第3页
蔡文能 cc++ 程式設計_第4页
蔡文能 cc++ 程式設計_第5页
资源描述:

《蔡文能 cc++ 程式設計》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Games,RandomNumbersandIntroductiontosimplestatisticsPRNGPseudoRandomNumberGenerator蔡文能tsaiwn@csie.nctu.edu.tw蔡文能C/C++程式設計1AgendaWhatisrandomnumber(亂數)?Howtherandomnumbersgenerated?rand()inClanguages:LinearCongruentialWhycall“Pseudorandom”?(P不發音)Howtodo“truerandom”?ApplicationofRrandomnum

2、ber?OthertopicsrelatedtoRandomnumbersIntroductiontosimplestatistics(統計簡介)蔡文能C/C++程式設計2BATNUMgamehttp://www.atariarchives.org/basicgames/showpage.php?page=14AnancientgameoftwoplayersOnepileofmatchsticks(orstones)Takesturntoremove[1,maxTake](至少拿1,至多拿maxTake)可規定拿到最後一個贏或輸!Winningstrategy??Ga

3、mes須用到RandomNumber!Why?蔡文能C/C++程式設計3BullsandCowsGamehttp://5ko.free.fr/en/bk.htmlhttp://en.wikipedia.org/wiki/Bulls_and_cowshttp://zh.wikipedia.org/zh-hant/%E7%8C%9C%E6%95%B0%E5%AD%97http://boardgames.about.com/od/paperpencil/a/bulls_and_cows.htmhttp://pyva.net/eng/play/bk.htmlhttp://www

4、.bullscows.com/index.phphttp://www.funmin.com/online-games/bulls-and-cows/index.phpGames須用到RandomNumber!Why?蔡文能C/C++程式設計4NIMGamehttp://en.wikipedia.org/wiki/NimNimisatwo-playermathematicalgameofstrategyinwhichplayerstaketurnsremovingobjectsfromdistinctheaps.Oneachturn,aplayermustremoveat

5、leastoneobject,andmayremoveanynumberofobjectsprovidedtheyallcomefromthesameheap.可規定拿到最後一個贏或輸!Winningstrategy??Games須用到RandomNumber!Why?蔡文能C/C++程式設計5Whatisrandomnumber?Sequenceofindependentrandomnumberswithaspecifieddistributionsuchasuniformdistribution(equallyprobable)Actually,thesequenc

6、egeneratedisnotrandom,butitappearstobe.SequencesgeneratedinadeterministicwayareusuallycalledPseudo-Randomsequences.參考http://www.gnu.org/software/gsl/manual/gsl-ref_19.htmlNormaldistribution?exponential,gamma,Poisson,…蔡文能C/C++程式設計6TurboC++的rand()與srand()#defineRAND_MAX0x7fffustaticunsigne

7、dlongseed=0;intrand(){seed=seed*1103515245+12345;returnseed%(RAND_MAX+1);}voidsrand(intnewseed){seed=newseed;}staticglobal變數請參考K&R課本4.6節Pseudorandomnumber就是15個1的binary注意C語言的rand()生出的不是NormalDistribution!static使其它file裡的function看不見這seed蔡文能C/C++程式設計7Unix上gcc的rand()

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。