筛子类和筛子测试类(翻译转贴)
来源:互联网 发布:4g内存吃鸡优化 编辑:程序博客网 时间:2024/06/11 22:25
AS3 Dice Class & Dice Tester
In game development randomness is often necessary for certain tasks, be it the random distribution of graphic tiles, a random factor in NPC AI or random stats in a roleplaying game. Especially for the latter purpose the static Dice class provides a set of methods to roll dice as it is common in a RPG, to be exact four-, six-, eight-, ten-, twelve-, twenty-sided and percentile dice.
在游戏开发环节中,随机的应用对于某些任务来说总是必要的,象随机的布局,NPC角色的随机表现,特别是想骰子这样的类,提供一系列的投掷方法。
The Dice class (and it’s supporting classes) are rather elaborated, using for example the Linear Congruential algorithm in the process of generating ‘true’ random numbers so it might not be the most speed-optimized method for calculating random numbers. For absolute performance the LCA and rounding routines can be removed to speed up calculations.
筛子类(以及它的一些支撑类)经过了一系列的提炼,我们采用了线性算法来产生真正的随机数,因此也许这是速度最优化的随机数产生算法了。为了获得更好的性能,可以将一些圆整的过程去掉来加快计算速度
Using the Dice class is very simple! For example rolling two ten-sided dice can be done with the following call …
使用骰子类非常简单,例如投掷两个十面的骰子只要这样:
var result:int = Dice.tenSided(2);
… rolling the percentile die is even simpler as it does not need any arguments. It always returns a value between 1 and 100 …
var result:int = Dice.percentile();
… the class also provides the roll method with that any x-sided die could be rolled, 3 sixteen-sided dice for instance …这个类还提供了N面的骰子投掷
var result:int = Dice.roll(16, 3);
The following application uses the Dice class and can be used to test dice throw probability according to the bell curve (the more dice are used the lower the probability to roll boundary results).
下面的应用程序采用了骰子类,并且给出了概率测试(根据贝尔曲线)
DOWNLOAD
The Dice class and Dice Tester sources can be downloaded from here.
可以从以上给出的链接去下载这个应用的哦源代码。
本文转自
http://labs.hexagonstar.com/diceclass/
- 筛子类和筛子测试类(翻译转贴)
- 筛子及类筛子题号
- 筛子
- (筛子法)hdu1286 & hdu1999
- 筛子游戏
- 埃拉托色尼筛子
- 投掷筛子
- 埃拉托色尼筛子
- 筛子抽奖
- 【灵修】三个筛子(真实、善意、重要)
- 给空白筛子涂色,保证两个筛子投掷数字每一个和的概率相等
- 随机数例子 筛子点数
- 求质数的筛子
- 无形的筛子
- 抛筛子问题
- 筛子法求质数
- 掷筛子问题
- 实现“挨拉托色尼的筛子”
- 反转控制, 即插件行为来控制宿主程序
- 结果值在int类型内的排列组合计算
- 关于继承,属性,析构!
- 编写一个子程序嵌套结构的程序模块,分别从键盘输入姓名及8个字符的电话号码,并以一定的格式显示出来
- printf语句也可以给变量赋值
- 筛子类和筛子测试类(翻译转贴)
- 自己动手打造嵌入式Linux软硬件开发环境
- ClsDBOperation
- 字符编码的奥秘(转帖)
- CommonClass
- 如何得知动态分配内存的长度(VC下)
- Products_DS
- Small Business解读
- 美国正在故伎重演地搞中国-象二十年前巧算日本一样