I suspect you might be asking a bit more than you realise. However, most of your needs can be met via a system that allows ghosts to move to any designated* tile - be it the one Pac-Man occupies or their "home corner" (for scattering). Personally I would ping the map: Consider a fresh "ping map" of the play tiles with all entries set to zero. Now you set the target tile to a value of one, and each pass you increment the ping value of each free adjacent tile to the ones you just filled in. Eventually you end up with a completed ping value map upon which you can trace back to the target tile from any other tile simply by looking for an adjacent entry with a lower ping value than the one you are currently on.
"Home Corner" ping maps can be pre-calculated for each ghost, obviously, and the realtime one (for tracking Pac-Man) shared between all ghosts and built up over several loops to keep the speed up. A ghost that can actually see the player doesn't even need to refer to the ping map, naturally.
That would be my approach, anyway.
*How exactly you designate a tile would depend on the personality of the ghost in question.
"Home Corner" ping maps can be pre-calculated for each ghost, obviously, and the realtime one (for tracking Pac-Man) shared between all ghosts and built up over several loops to keep the speed up. A ghost that can actually see the player doesn't even need to refer to the ping map, naturally.
That would be my approach, anyway.
*How exactly you designate a tile would depend on the personality of the ghost in question.