PATHFINDING


A* (A-Star) is a pathfinding algorithm that finds the shortest route between two points by making educated guesses.

Think of it as a person in a maze holding a compass pointing to the exit.

How it works (The 3 Steps)

When a Ghost is at an intersection, A* looks at the available tiles and gives each one a "Score" (F) based on two numbers:

The Formula:

Score = Distance Walked + Distance Left


The Difference

In Pac-Man Terms

When a Ghost asks "Which way should I go?", A* calculates:

The Ghost picks the lowest score and moves that way immediately.