# Pathfinding with multiple actors moving in sync

I am trying to implement a path-finding routine involving the following:

• Multiple agents
• Multiple Goals
• Obstacles
• Both agents move in sync, i.e. they both move in the same direction unless one is stopped by an Obstacle. See explanation below in the edit section.

See the following image for illustration:

A1 and A2 represent the starting position of two agents. The dark squares marked with "X" represent obstacles. "G1" and "G2" represent the final goal.

I played around with A* path finding algorithm, and it works great with 1 actor with one goal. However, I couldn't get it to work with more than one actor and goal.

Edit: Synchronized movement explained

If for instance, A1 is stopped by the obstacle but A2 can move, it is a valid option. A1 would stay in place but A2 will move.

Example:

1. Move Right: A1 moves to (2,1) and A2 moves to (2,7)
2. Move Right: A1 stays in place but A2 moves to (3,7)
3. Move Up: A1 moves to (2,0) and A2 moves to (3,6)
4. Move Up: A1 stays at (2,0) and A2 moves to (3,5)
• Can you be more specific on "move in sync"? How would a correct path look for provided example? In case one is stopped by an obstacle, what happen to the other? – wondra Jan 28 '17 at 11:59
• Sorry for the lack of clarity. If for instance, A1 is stopped by the obstacle but A2 can move, it is a valid option. A1 would stay in place but A2 will move. I will add the info to the question. – Puneet Jan 28 '17 at 12:16
• What's the big picture here? Are you creating this AI to validate that a level can be finished and/or count the minimum amount of required moves? – Vaillancourt Jan 28 '17 at 12:48
• Its as you said. I am creating this for three fold use: 1) In-game hint, 2) Validate that level can be completed, and 3) Minimum moves needed to complete the game to provide feedback at the end of the level. – Puneet Jan 28 '17 at 12:54