Quote Originally Posted by iopred
Quote Originally Posted by Squize
If playerXPos<ghostXPos then the ghost's preferred horizontal move is left, and if playerYPos>ghostYPos then the best vertical direction for it is down.

This is basically my implementation of Pacman pathfinding, with 4 enemies, it got really hard to avoid them.

If you feel like sprucing it up a bit, make a couple work like this, and then a couple work simply by going a random direction. Adds some zest
I would only do that if every tile in between pacman and ghost were walkables. Given the fact that they are "walls", the ghost can't see pacman.