I'm building a bot that plays a simplified version of Pac-manPac-Man. The The bot does a pretty good job, but sometimes it chooses a path where it ends up surrounded by enemies. EX
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).
Legend: O are objectives, P is the player, E1, E2 and E3 are enemies that are chasing the player, X and x are walls. (Map on the left)
In this situation, my bot is at the point of no return and it will choose to go and pick up O1, because is the closest objective in sight, and in theory is still a safe path, but doing so, enemies will surround him and 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 thea safer one. The The bot should determine in advance if completing the current path (to O1O1) is a good idea or not, in advance, and make a decision.
BTWHow would I go about this? I'm using a simple A* for pathfindingpath finding over a grid. Any pointers, ideas or comments are very welcome.
Thanks in advance!