How do the ghosts in PacMan decide where to go?

Just one example:

The Pink ghost, known as Pinky, is programmed to try and land on the space 16 pixels (or two tiles in front) of Pac-Man to ambush him. However, due to “overflow error” in the game’s code, if Pac-Man is facing upwards, Pinky will instead attempted to land on the space 4 tiles in front of him and 4 tiles to the left. Interestingly, because Pinky is programmed to always be ahead of Pac-Man, you can usually make her stop chasing you by heading straight for her.

Loved every bit of this.