Exemple #1
0
    def test_empty_observation(self):
        robot = GripperRobot(10, Heading.NORTH, (5, 5))
        game = self.default_game10x10()
        game.grid = np.zeros((10, 10))
        observation = robot.get_observation(game)

        self.assertEqual(17, len(observation))
        for i in range(len(observation)):
            self.assertEqual(0, observation[i])
Exemple #2
0
    def test_robot_observation_1(self):
        robot = GripperRobot(10, Heading.NORTH, (5, 5))
        game = self.default_game10x10()
        game.grid = np.zeros((10, 10))
        game.robots.append(GripperRobot(11, location=(6, 5)))
        observation = robot.get_observation(game)

        for i in range(16):
            self.assertEqual(0, observation[i])
        self.assertEqual(1, observation[16])
Exemple #3
0
    def test_robot_observation_5(self):
        robot = GripperRobot(10, Heading.NORTH, (5, 5))
        game = self.default_game10x10()
        game.grid = np.zeros((10, 10))
        game.robots.append(GripperRobot(11, location=(4, 4)))
        observation = robot.get_observation(game)

        self.assertEqual(1, observation[7])

        for i in [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16]:
            self.assertEqual(0, observation[i])
Exemple #4
0
    def test_border_observation_3(self):
        robot = GripperRobot(10, Heading.EAST, (9, 0))
        game = self.default_game10x10()
        game.grid = np.zeros((10, 10))
        observation = robot.get_observation(game)

        for i in [0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 15, 16]:
            self.assertEqual(0, observation[i])

        for i in [2, 5, 8, 11]:
            self.assertEqual(1, observation[i])
Exemple #5
0
    def test_tile_everywhere(self):
        robot = GripperRobot(10, Heading.NORTH, (5, 5))
        game = self.default_game10x10()
        game.grid = np.zeros((10, 10))
        game.grid[4][5] = 1
        game.grid[6][5] = 1
        game.grid[4][4] = 1
        game.grid[5][4] = 1
        game.grid[6][4] = 1
        observation = robot.get_observation(game)

        for i in [3, 6, 9, 12, 15]:
            self.assertEqual(1, observation[i])

        for i in [0, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16]:
            self.assertEqual(0, observation[i])
Exemple #6
0
    def test_robot_everywhere(self):
        robot = GripperRobot(10, Heading.SOUTH, (5, 5))
        game = self.default_game10x10()
        game.grid = np.zeros((10, 10))
        game.robots.append(GripperRobot(11, location=(4, 5)))
        game.robots.append(GripperRobot(12, location=(6, 5)))
        game.robots.append(GripperRobot(13, location=(4, 6)))
        game.robots.append(GripperRobot(14, location=(5, 6)))
        game.robots.append(GripperRobot(15, location=(6, 6)))
        observation = robot.get_observation(game)

        for i in [4, 7, 10, 13, 16]:
            self.assertEqual(1, observation[i])

        for i in [0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15]:
            self.assertEqual(0, observation[i])