Exemplo n.º 1
0
    def test_finish_game(self):
        provider = ConfigurationProvider()
        provider.actual = CustomConfiguration(map_height=2, map_width=1, treasures=1, bots=1, blocks=0)
        controller = GameController(provider)
        bot_id = 0
        with self.assertRaises(GameFinished):
            try:
                controller.action(bot_id, Action.STEP)
            except MovementError:
                pass

            controller.action(bot_id, Action.TURN_RIGHT)
            controller.action(bot_id, Action.TURN_RIGHT)
            controller.action(bot_id, Action.STEP)
Exemplo n.º 2
0
    def test_action_simple(self):
        provider = ConfigurationProvider()
        provider.actual = CustomConfiguration(map_height=2, map_width=2, treasures=0, blocks=0, bots=1)
        controller = GameController(provider)
        bot_id = 0
        with self.assertRaises(MovementError):
            for _ in range(controller.get(bot_id).map.height):
                controller.action(bot_id, Action.STEP)

        bot_id = 1
        with self.assertRaises(MovementError):
            controller.action(bot_id, Action.TURN_LEFT)
            for _ in range(controller.get(bot_id).map.width):
                controller.action(bot_id, Action.STEP)
Exemplo n.º 3
0
    def test_finish_game(self):
        provider = ConfigurationProvider()
        provider.actual = CustomConfiguration(map_height=2,
                                              map_width=1,
                                              treasures=1,
                                              bots=1,
                                              blocks=0)
        controller = GameController(provider)
        bot_id = 0
        with self.assertRaises(GameFinished):
            try:
                controller.action(bot_id, Action.STEP)
            except MovementError:
                pass

            controller.action(bot_id, Action.TURN_RIGHT)
            controller.action(bot_id, Action.TURN_RIGHT)
            controller.action(bot_id, Action.STEP)
Exemplo n.º 4
0
    def test_action_simple(self):
        provider = ConfigurationProvider()
        provider.actual = CustomConfiguration(map_height=2,
                                              map_width=2,
                                              treasures=0,
                                              blocks=0,
                                              bots=1)
        controller = GameController(provider)
        bot_id = 0
        with self.assertRaises(MovementError):
            for _ in range(controller.get(bot_id).map.height):
                controller.action(bot_id, Action.STEP)

        bot_id = 1
        with self.assertRaises(MovementError):
            controller.action(bot_id, Action.TURN_LEFT)
            for _ in range(controller.get(bot_id).map.width):
                controller.action(bot_id, Action.STEP)