Livl-Corporation / livl-pacman

Insane Pac-Man clone from © Livl Corporation 🕹️
MIT License
0 stars 1 forks source link

SCATTER MODE #86

Closed FranckG28 closed 1 year ago

FranckG28 commented 1 year ago

See #91 for pathfinding details

Scatter Targets

As mentioned before, each ghost has a fixed target tile it is trying to reach in scatter mode. The picture below shows the actual tile used by each ghost. Notice each target tile is in dead space on either the top or bottom edge of the screen. As such, the ghosts will never be able to reach them.

Luckily, a ghost does not care if its goal is attainable or not-the A.I. routines are very short-sighted. All a ghost cares about is following the pathfinding logic described above to make the best choice it can on which way to turn at the next tile.

As a result, it will simply make circles in the area of the maze nearest its target tile until the target is set to some other location. That's all scatter mode really is. The only reason a ghost has a "favorite corner" of the maze at all is due to the location of a target tile it will never reach.

Image