In my mind, the ghosts can track Pac-Man through his scent. There are four different ghosts, each with different personalities. This affects the way in which they chase after Pac-Man. The red ghost chases after Pac-Man in the most direct manner possible. The blue ghost will chase him down by circling around in front of him. The pink ghost will always aim to be 32 dots or so in front of whichever direction Pac-Man's mouth is pointing. The orange ghost is a wild card, he just moves around randomly. Each ghost chases Pac-Man in their own way and thus end up surrounding him. So there is a base algorithm there at work.