So they shouldn’t seach for a random direction every step they take. It was a bit tricky at my first approach, since every time HTML gets redraw using canvas, the ghosts don’t move from 1 block to another block but 1/4 block to make game smooth. Ghosts chase randomly among Pacman and Cherries.Ghosts chase Pacman with different paths.Ghosts chase Pacman with the shortest path.I am telling about that road, it can be splitted into 4 bullets: It had been gone through a painful road to reach this beautiful destination. This is how my pacman game looks like (checkout the demo or source):