I'm trying to program an AI for a Pac-Man-like game, where I would be the Pac-Man and move according to two simple rules:
- move towards bonuses
- avoid monsters and being killed
I read that one can create a "fake AI" with Dijkstra maps (a.k.a. heat maps) such as the ones described in the very good article Flow Field Pathfinding for Tower Defense.
So, for each turn in my game, I have implemented these heat maps according to the aforementioned rules:
- Flee map
- Add each monster as a source, and compute the Dijkstra map
- Multiply by a negative factor (-1.2) to make repulsive instead of attracting sources
- Rescan the cells and compute a new Dijkstra map (avoid being cornered)
- Bonuses
- Add each bonus pill to the sources, and compute a Dijkstra map
The two maps seem fairly correct, however I can't manage to combine them together because this generates cases where the player (Pac-Man) is either stuck or not going in the right direction. I have tried for example to do such, but the results are not very good:
movement_map = 0.9 * flee_map + 0.1 * bonus_map
I also tried a single map with positive and negative weights for monsters and pills, but this does not seem to work either.
So my questions are:
- Are Dijkstra maps appropriate when trying to respect opposites rules (go to bonus pills, AND avoid monsters)?
- If not, which algorithm should be used? Otherwise, how can I combine, or at least, make these Dijkstra maps work together?

