Example #1
0
 def __init__(self, x, y, i, frames, player, t):
     self.x = x
     self.y = y
     self.index = i
     self.path = []
     self.algorithm = AStar(self, player)
     self.time = t
     self.frames = frames
def initGhostAlgorithm(ghost, player, algorithm):
    if algorithm == 'A*':
        ghost.setAlgorithm(AStar(ghost, player))

    # elif algorithm == 'DFS':
    #     ghost.setAlgorithm(Dfs(ghost, player))

    elif algorithm == 'GeneticAlgorithm':
        ghost.setAlgorithm(GeneticAlgorithm(ghost, player))

    elif algorithm == 'Frightened':
        ghost.setAlgorithm(Frightened(ghost))
Example #3
0
 def test_3x3_no_obstacles(self):
     a = AStar(board=[[2, 0, 0], [0, 0, 0], [0, 0, 3]])
     while not a.path_found:
         a.algorithm_loop()
     self.assertEqual(a.board_to_2d_list(),
                      [[2, 0, 0], [0, 4, 0], [0, 0, 3]])