Have a way to change the PacMan to the "path" mode. The plan is that you discover certain circumstances, compute a pre-drawn path for PacMan tracking, and then develop early exit conditions for that path. You can use this for several circumstances.
When PacMan is surrounded by ghosts in three of four directions at a certain distance, create an exit path that either leads PacMan away from the ghosts or to a power source. The exit situation would be when he eats energy or ceases to be surrounded.
When PacMan is energized, create a path to eat some nearby ghosts. The output situation will be when there are no ghosts on the path, recount the path. Or, if there are no ghosts nearby, completely exit the mode.
When less than half of the remaining points are left or there are no points nearby, enter the path to go eat some points, avoiding ghosts. Recount the way when the ghost appears nearby, or leave the whole if there are several ghosts nearby.
If there are no situations that require a path, then you can return to the previously set AI by default.
source share