def test_lose_5_timeouts(self):
        # 0 must move back and forth because of random steps
        test_start = (
            """ ######
                #0 #.#
                ###  #
                ##. 1#
                ###### """
        )
        # players do nothing
        class TimeOutPlayer(AbstractPlayer):
            def get_move(self):
                raise PlayerTimeout

        teams = [
            SimpleTeam(TimeOutPlayer()),
            SimpleTeam(StoppingPlayer())
        ]
        # the game lasts one round, and then draws
        gm = GameMaster(test_start, teams, 2, 100, max_timeouts=5)

        # this test viewer caches all events lists seen through observe
        class TestViewer(AbstractViewer):
            def __init__(self):
                self.cache = list()
            def observe(self, universe, game_state):
                self.cache.append(game_state)

        # run the game
        tv = TestViewer()
        gm.register_viewer(tv)
        gm.set_initial()

        self.assertEqual(gm.universe.bots[0].current_pos, (1,1))

        gm.play()

        # check
        self.assertEqual(gm.game_state["max_timeouts"], 5)
        self.assertEqual(tv.cache[-1]["round_index"], 1 - gm.game_state["max_timeouts"])
        self.assertEqual(gm.universe.teams[0].score, 0)
        self.assertEqual(gm.universe.teams[1].score, 0)
        # the bot moves four times, so after the fourth time,
        # it is back on its original position
        self.assertEqual(gm.universe.bots[0].current_pos, (1,1))
        self.assertTrue(tv.cache[-1]["team_wins"] is not None)
        self.assertEqual(tv.cache[-1]["team_wins"], 1)
dataset/ETHPy150Open ASPP/pelita/test/test_game_master.py/TestGame.test_lose_5_timeouts/swapped operands of `-`