def test_constructor(self):
     board_size = (3, 4)
     agent_pos = (3, 3)
     tiles_pos = {'A': (0, 3), 'B': (1, 3), 'C': (2, 3)}
     board = BoardState(agent_pos, tiles_pos, board_size)
     self.assertEqual(board.get_tile_pos('A'), tiles_pos['A'])
     self.assertEqual(board.get_tile_pos('B'), tiles_pos['B'])
     self.assertEqual(board.get_tile_pos('C'), tiles_pos['C'])
Пример #2
0
 def estimate_cost_to_goal(self, state: BoardState, goal: BoardState):
     total_dist = abs(state.agent_pos[0] -
                      goal.agent_pos[0]) + abs(state.agent_pos[1] -
                                               goal.agent_pos[1])
     for tile, goal_pos in goal.tiles_pos.items():
         new_pos = state.get_tile_pos(tile)
         total_dist += abs(new_pos[0] - goal_pos[0]) + abs(new_pos[1] -
                                                           goal_pos[1])
     return total_dist