def _see_ghost()

in reagent/gym/envs/pomdp/pocman.py [0:0]


    def _see_ghost(self, action):
        distances = []
        agent_pos = self.internal_state.agent_pos
        for ghost in self.internal_state.ghosts:
            if agent_pos.x != ghost.pos.x and agent_pos.y != ghost.pos.y:
                continue
            if agent_pos == ghost.pos:
                distances.append(0)
                break
            if (
                (
                    action == Action.UP
                    and ghost.pos.x < agent_pos.x
                    and ghost.pos.y == agent_pos.y
                )
                or (
                    action == Action.DOWN
                    and ghost.pos.x > agent_pos.x
                    and ghost.pos.y == agent_pos.y
                )
                or (
                    action == Action.LEFT
                    and ghost.pos.y < agent_pos.y
                    and ghost.pos.x == agent_pos.x
                )
                or (
                    action == Action.RIGHT
                    and ghost.pos.y > agent_pos.y
                    and ghost.pos.x == agent_pos.x
                )
            ) and not self._wall_between(agent_pos, ghost.pos):
                distances.append(manhattan_distance(agent_pos, ghost.pos))
        if not distances:
            return -1
        return 1