def __nearestGhost(self, ghosts): cord = ghosts[0].getCord() minDistance = game.getDistance(self.cord, ghosts[0].getCord()) for ghost in ghosts: dist = game.getDistance(self.cord, ghost.getCord()) if dist < minDistance: minDistance = dist cord = ghost.getCord() return cord
def __moveGreedy(self, cord, maze): moves = self.__getMoves(maze) if len(moves) == 0: return self.cord minDistance = game.getDistance(moves[0], cord) finalMove = moves[0] for move in moves: dist = game.getDistance(move, cord) if dist < minDistance: minDistance = dist finalMove = move return finalMove
def __greadyPill(self, cord, maze): moves = self.getMoves(maze) if len(moves) == 0: return self.cord # no move left, just die there minDistance = game.getDistance(moves[0], cord) finalMove = moves[0] for move in moves: dist = game.getDistance(move, cord) if dist < minDistance: minDistance = dist finalMove = move return finalMove
def __movefromGhost(self, cord, maze): moves = self.getMoves(maze) if len(moves) == 0: return self.cord # no move left, just die there maxDistance = game.getDistance(moves[0], cord) finalMove = moves[0] for move in moves: dist = game.getDistance(move, cord) if dist > maxDistance: maxDistance = dist finalMove = move return finalMove
def __pacmanNearby(self, maze, pacmans): cord = [0, 0] nearby = False minDistance = len(maze) + len( maze[0]) # such distance is even more than real maximum for pacman in pacmans: dist = game.getDistance(self.cord, pacman.getCord()) if dist < self.radius and dist < minDistance: nearby = True minDistance = dist cord = pacman.getCord() return nearby, cord