Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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