Group of soldiers moving along a grid map together

I am making an RTS game, and the whole terrain is like a grid (cells with x and y coordinates). I have a couple of soldiers in a group (military unit), and I want to send them from point A to point B (there are obstacles between points A and B). I can solve for one soldier using the A * algorithm, and that is not a problem. How to ensure that my group of soldiers always comes together? (I notice a couple of cases when they break up and go in different ways to the same destination, I can choose the leader of the group, but I do not need the soldiers to go to the same cells, but the leader, for example, a pair with the right side, a pair on the left side, if possible). Has anyone solved a similar problem in the past? Any idea for modifying the algorithm?

+4
source share
2 answers

You need a flocking algorithm where you have the package leader following the directions of A * and the other following the leader.

If you have very large formations, you will encounter problems such as β€œhow to put all these soldiers through this small hole” and that where you need to be smarter.

An example is the compulsory formation of a single line for tight places, others - the division of groups into smaller units.

+5
source

If you do not have too many soldiers, a simple modification will consider the problem as a multidimensional problem with each soldier representing 2 dimensions. You can add constants to this multidimensional space so that your soldiers stay close to each other. However, this can become costly in terms of cost.

Artificial potential fields are usually less expensive and easy to implement. And they can be extended to cooperative strategies. If you mix with search methods in a graph, you cannot get stuck in local lows. Google provides many starting points: http://www.google.com/search?ie=UTF-8&oe=utf-8&q=motion+planning+potential+fields

+2
source

All Articles