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


Python Game.score方法代码示例

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


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

示例1: TestBoard

# 需要导入模块: from game.game import Game [as 别名]
# 或者: from game.game.Game import score [as 别名]
class TestBoard(unittest.TestCase):
    def setUp(self):
        self.basic_game = Game(board=None, rnd=random.Random(1))

    def test_constructor(self):
        self.assertEqual(self.basic_game.score(), 0)
        game = Game(rnd=random.Random(1))
        self.assertEqual(game.board(), self.basic_game.board())

    def test_smash(self):
        # This doesn't comprehensively test smashing because
        # the tests for Board mostly did that already.
        for direction in DIRECTIONS:
            board = Board()
            board = board.update((1, 1), 2)
            game = Game(rnd=random.Random(1), board=board)
            self.assertTrue(game.smash(direction))
            self.assertEqual(game.board()[1, 1], 0)
        for direction in DIRECTIONS:
            board = Board()
            board = board.update((0, 0), 2)
            game = Game(rnd=random.Random(1), board=board)
            if direction in {UP, LEFT}:
                self.assertFalse(game.smash(direction))
            else:
                self.assertTrue(game.smash(direction))
                self.assertEqual(game.board()[0, 0], 0)
开发者ID:ggould256,项目名称:twentyfortyeight,代码行数:29,代码来源:test_game.py

示例2: SpinnyStrategy

# 需要导入模块: from game.game import Game [as 别名]
# 或者: from game.game.Game import score [as 别名]
    strategy = None
    if args.strategy == "spinny":
        strategy = SpinnyStrategy()
    elif args.strategy == "random":
        strategy = RandomStrategy()
    else:
        from strategy.nn.nn_strategy import ModelStrategy
        strategy = ModelStrategy(args.strategy, verbose_period=5000)

    total = 0
    for i in range(args.number_of_games):
        game = Game()
        running = True
        while running:
            turn_outcome = game.do_turn(
                strategy.get_move(game.board(), game.score()))
            if args.verbose:
                game.pretty_print()
            running = (turn_outcome != GAMEOVER)
        strategy.notify_outcome(game.board(), game.score())
        if not args.summary:
            print(game.score())
        total += game.score()
        if not (i % 25):
            print("...", i, "/", args.number_of_games)
    if args.summary:
        print("Strategy %s had average score %f after %d games" %
              (args.strategy,
               (total / args.number_of_games), args.number_of_games))
开发者ID:ggould256,项目名称:twentyfortyeight,代码行数:31,代码来源:demo.py


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