2

I am currently working on a Pacman AI heuristic, and have run into some trouble which involves Pacman becoming "trapped" between two ghosts.

I need some way, given a board state with any useful information provided (coordinates + direction of all agents, wall locations, food location, etc.), to tell if Pacman is trapped between two oncoming ghosts and is guaranteed to die within some n moves, i.e. this board state is unwinnable. (This is assuming ghosts can only turn 90 degrees- so if going North, a ghost's possible moves are either North, East or West providing no walls are in the way)

An example image:

Unwinnable pacman state

Fraser Price
  • 899
  • 6
  • 15
  • 36
  • Your pacman can be trapped at some point but he can escape afterwards based on how the ghosts move. Do the ghosts move optimally? – Vlad Tarniceru Nov 08 '16 at 17:34
  • @VladTarniceru No, by trapped I mean a situation like this where the game is completely unwinnable. Doesn't really matter which algorithm ghosts use, just bear in mind they can only turn up to 45 degrees- meaning in the above case game is lost – Fraser Price Nov 08 '16 at 17:41
  • 2
    The ghosts can start moving to opposite direction, if they move randomly, right? – halfo Nov 08 '16 at 17:44
  • My point is that you can be trapped but not lose the game if the ghosts move randomly on the map and change the direction and give you more space. – Vlad Tarniceru Nov 08 '16 at 17:45
  • @halfo no, ghosts can only turn up to 90 degrees, see edits. – Fraser Price Nov 08 '16 at 17:45
  • What do you mean by 45 degrees? I believe you have only 4 directions for the movements in the classic pacman (up, down, left, right), not 8. – Vlad Tarniceru Nov 08 '16 at 17:46
  • @VladTarniceru I don't think you understand. Their movements are not random, they can only turn UP TO 90 DEGREES. This means in the above case both ghost's only option for the current turn is to go South, as North would be a 180 degrees and East and West are Blocked. Once they have moved down, only possible moves are East and West respectively, meaning pacman will get killed within 4 moves. – Fraser Price Nov 08 '16 at 17:47
  • @VladTarniceru im dumb sorry, 90 degrees. Its been a long day... – Fraser Price Nov 08 '16 at 17:48
  • A very unrefined thought: one way would be if you can detect the ghost that can move in only one direction, lets call them bounded ghosts. Now, for each cell it is possible to calculate the minimum number of step the nearest bounded ghost need to reach that cell. It can be done in linear time. Now you need to find a path to flee from the ghost using bfs (or dfs). – halfo Nov 08 '16 at 18:08

0 Answers0