1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I think one easy way to handle this is to change up the AI between different enemies (this is what pacman does). One enemy can follow the optimal path, the other can take the second best/ higher cost paths, other enemies could move randomly, etc \$\endgroup\$ – CobaltHex Feb 3 '17 at 22:48
  • \$\begingroup\$ Perhaps you could show an example via screenshots of what you already have? ASCII Character diagrams look so bad. \$\endgroup\$ – Gnemlock Feb 4 '17 at 0:05
  • \$\begingroup\$ Maybe I didn't explain myself correctly, I'm not developing a game, I'm programming a bot to play a Pacman-like game. I'm trying to make the player character not put himself in the situation I just described. Obviously i cannot change the enemy behavior \$\endgroup\$ – GenderBender Feb 4 '17 at 1:50
2
\$\begingroup\$

Here is something I would try.

First, map out all the possible objectives.

Second, for each objective, use A* to map the path there, avoiding the Enemies. But every step of the way, don't just move the player, move also the enemies, based on what you know of their behaviour.

Third, pick the path that will allow the player to survive the longest.

So basically, you have to integrate the behaviour of the enemies in your prediction.

\$\endgroup\$
  • 1
    \$\begingroup\$ Yes, I'm trying to achieve something similar. Predicting enemy movement depending on the number of steps my bot is from the objective. Let's see how it goes. \$\endgroup\$ – GenderBender Feb 6 '17 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.