예제 #1
0
    def test_export(self):
        game_map = MapFactory().create(DefaultConfiguration())
        game = Game(game_map)

        self.assertCountEqual(
            game.export(0),
            dict(
                map=game_map.export(),
                bots=game._export_bots(0),
                map_width=game_map.width,
                map_height=game_map.height,
                map_resolutions=(game_map.width, game_map.height)
            )
        )
예제 #2
0
    def test_export_bots(self):
        class Conf(DefaultConfiguration):
            map_width = 2
            map_height = 1
            bots = 2
            treasures = 0
            blocks = 0

        game = Game(MapFactory().create(Conf()))
        my_bot_id = 0
        bots_export = game._export_bots(my_bot_id)

        my_bot_on_first_field = game.get_bot_position(my_bot_id) == (0, 0)
        self.assertListEqual(
            bots_export,
            [
                dict(x=0, y=0, position=(0, 0), orientation=Orientation.NORTH, your_bot=not my_bot_on_first_field),
                dict(x=1, y=0, position=(1, 0), orientation=Orientation.NORTH, your_bot=my_bot_on_first_field)
            ]
        )