获取任意骰子组的所有组合
dicetables的Python项目详细描述
骰子表v2.6.0
计算任意一组骰子的组合
你有没有想过杀死这个25马力的生物的几率是多少? 用你的5级火球?当然有(3.24%)。祝你好运)。 如果你能使用你的骰子,那你的掷骰次数是原来的两倍。 我们已经为你投保了(仍然只有10%的可能性)。想确认一下 你会在一个袋子里随机抽取的DND骰子的价差上打赌吗? 没问题(“我打赌你不能在7D4,4D8,5D12和4D20上掷150-200”…… 因为这是0.3%的机会)。有没有想过如果你把一个 投币一千次?(你的摇头次数超过600次 是0.00000000 9%。
给你的朋友留下深刻印象。哇你选择的性别- 用….骰子!!!
开始
此模块没有依赖项和要求。因此,要开始,只需:
$ pip install dicetables
或:
$ git clone https://github.com/eric-s-s/dice-tables.git
$ cd dice-tables
$ python setup.py install
要使用的基本对象是dicetable或detailedicetable以及任何dice类。它们是:
- 模具
- 模式
- 重量die
- modweighteddie
- 修饰语
- strong模具
- 爆炸
- 爆炸
- 最佳冰池
- worstofdicepool
- 冰池上中段
- 低水位池
有关骰子的详细信息,请参见The Dice。 有关骰子表的详细信息,请参见 DiceTable and DetailedDiceTable
这些都是不可变的对象。当您向骰子表中添加骰子时,它将返回一个新对象并
不会改变原稿。使用DiceTable.new()
类方法创建空的骰子表。
>>> import dicetables as dt >>> empty = dt.DiceTable.new() >>> empty <DiceTable containing []> >>> empty.add_die(dt.Die(6), times=10) <DiceTable containing [10D6]> >>> empty <DiceTable containing []> >>> table = empty.add_die(dt.Die(4), times=3) >>> table = table.add_die(dt.Die(10), times=5) >>> table.get_list() [(Die(4), 3), (Die(10), 5)] >>> print(table.get_dict()) # This is each roll and how many times it occurs. {8: 1, 9: 8, 10: 36, 11: 120, 12: 327, ... ... 55: 3072, 56: 1608, 57: 768, 58: 327, 59: 120, 60: 36, 61: 8, 62: 1}
要获取更详细的信息,请使用 EventsCalculations。 它可以得到平均值,stddev,一个很好的字符串 用于绘图的组合、点和轴,以及任何一组滚动的统计信息。
>>> calculator = dt.EventsCalculations(table) >>> calculator.mean() 35.0 >>> calculator.stddev(decimal_place=8) 6.70820393 >>> calculator.stats_strings(list(range(8, 20)) + [35] + list(range(50, 63))) StatsStrings(query_values='8-19, 35, 50-62', query_occurrences='515,778', total_occurrences='6,400,000', one_in_chance='12.41', pct_chance='8.059') >>> calculator.percentage_points() [(8, 1.5624999999999997e-05), (9, 0.00012499999999999998), (10, 0.0005625), ... (59, 0.001875), (60, 0.0005625), (61, 0.00012499999999999998), (62, 1.5624999999999997e-05)] >>> big_table = dt.DetailedDiceTable.new().add_die(dt.Die(6), 1000) >>> print(big_table.calc.full_table_string()) # DetailedDiceTable owns an EventsCalculations 1000: 1 1001: 1,000 1002: 500,500 1003: 1.672e+8 1004: 4.192e+10 1005: 8.417e+12 ... 3513: 1.016e+776 3514: 1.012e+776 3515: 1.007e+776 3516: 1.001e+776 3517: 9.957e+775 3518: 9.898e+775 ... 5998: 500,500 5999: 1,000 6000: 1
现在您可以使用滚动条滚动活动
>>> events = dt.DiceTable.new().add_die(dt.Die(6)) >>> roller = dt.Roller(events) >>> roller.roll() in [1, 2, 3, 4, 5, 6] True
这应该让你开始。有关详细信息,请参见 http://dice-tables.readthedocs.io/en/latest/
以及位于https://github.com/eric-s-s/dice-tables
的github存储库更改日志
从v2.1.0开始
- 事件计算添加了函数log10u点和log10u轴
- 新骰子:爆炸(其他骰子,爆炸=2),爆炸(其他骰子,爆炸=2)
- 见The Dice。和 Events info了解详细信息
- 新对象:Parser- 它将字符串转换为骰子对象。
从v2.2.0开始
- 提高了爆炸速度。
- 在解析器中添加了parse_die_within_limits函数。还添加了限制值。已将getter更改为属性。
从v2.4.0到v2.4.4
- 修正了当使用骰子的默认值时,在极限范围内解析骰子失败的错误。
- 解析器可以分析带有前导和尾随空白的字符串。
- 在限制范围内分析数据现在提高限制错误
- 添加了max_power_for_commaed选项以事件计算。full_table_string。
- 添加了max_power_for_commaed和min_power_for_fixed_pt到事件计算。stats_strings。
2.5.0版
- 添加了DicePool模具对象:
- 最佳冰库
- worstofdicepool
- 冰池上游
- 低水位池
- parser()。add_die_size_limit_kwarg和parser()。add_explosions_limit_kwarg被删除。使用 parser()。添加限制
2.6.0版
- 增加了滚轮