I'm building a bot that plays a simplified version of Pac-Man. The bot does a pretty good job, but sometimes it chooses a path where it ends up surrounded by enemies.
Here is an example:
XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX Legend: xxxxO1 E1 xxxxPE1 XXXX XXXXXXXXXXX ---> XXXX XXXXXXXXXXX O Objective E2 P O2 E2 E3 O2 P Player XXXXXXXX XXXXXXX XXXXXXXX XXXXXXX E Enemy XXXXXXXX XXXXXXX XXXXXXXX XXXXXXX X Wall XXXXXXXXE3XXXXXX XXXXXXXX XXXXXXX x Wall In this situation, my bot is at the point of no return. It will choose to move to and pick up objective one (O1), as it is the closest objective in sight, and in theory is still a safe path. However, in doing so, enemies will surround him and he will die. (Map on the right).
I'm trying to come up with ideas on how to make my bot avoid that path, and go for a safer one. The bot should determine if completing the current path (to O1) is a good idea or not, in advance, and make a decision.
How would I go about this? I'm using a simple A* for path finding over a grid.