当前位置: 首页>>代码示例>>Python>>正文


Python Simulator.gather方法代码示例

本文整理汇总了Python中simulator.Simulator.gather方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.gather方法的具体用法?Python Simulator.gather怎么用?Python Simulator.gather使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simulator.Simulator的用法示例。


在下文中一共展示了Simulator.gather方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import gather [as 别名]
def main():

    # create NonRandom instance with seed
    nr = NonRandom()
    nr.set_seed(1)

    # create game and player
    wheel = Wheel(nr)
    table = Table()
    game = Game(wheel, table)
    player = Martingale(table)

    # assign default values to prevent future changes on them
    player.BASE_AMOUNT = 1
    player.BASE_BET = "Black"

    # create simulator instance
    simulator = Simulator(game, player)
    simulator.SAMPLES = 3

    # execute simulator
    simulator.gather()

    # print results
    print "\n"
    print "Maxima", simulator.maxima, "\n"
    print "Final", simulator.final, "\n"
    print "Durations", simulator.durations, "\n"
开发者ID:abenassi,项目名称:casino,代码行数:30,代码来源:demo_simulator.py

示例2: SimulatorTestCase

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import gather [as 别名]
class SimulatorTestCase(unittest.TestCase):
    """Test Simulator class."""

    def setUp(self):

        # create NonRandom instance with seed
        nr = NonRandom()
        nr.set_seed(1)

        # create game and player
        wheel = Wheel(nr)
        table = Table()
        game = Game(wheel, table)
        player = Martingale(table)

        # assign default values to prevent future changes on them
        player.BASE_AMOUNT = 1
        player.BASE_BET = "Black"

        # create simulator instance
        self.simulator = Simulator(game, player)
        self.simulator.SAMPLES = 3

    def test_session(self):

        # execute one session
        stakes = self.simulator.session()

        # gather stats
        max_value = max(stakes)
        final_value = stakes[-1]
        duration = len(stakes)

        # check values derived from non-random generator
        self.assertEqual(max_value, 213)
        self.assertEqual(final_value, 213)
        self.assertEqual(duration, 250)

    def test_gather(self):

        # execute all sessions
        self.simulator.gather()

        # check gathered stats
        self.assertEqual(self.simulator.maxima, [213, 149, 223])
        self.assertEqual(self.simulator.final, [213, 22, 208])
        self.assertEqual(self.simulator.durations, [250, 105, 250])
开发者ID:abenassi,项目名称:casino,代码行数:49,代码来源:test_simulator.py


注:本文中的simulator.Simulator.gather方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。