4

I am making RTS game and whole terrain is like grid ( cells with x and y coordinates). I have couple soldiers in group (military unit) and I want to send them from point A to point B ( between points A and B is obstacles ). I can solve for one soldier using A* algorithm and that is not problem. How to achieve that my group of soldiers always going together ? (I notice couple corner cases when they split and go with different ways to the same destination point, I can choose leader of group but I don't need that soldiers going on same cells but by leader, for example couple at right side, couple at left side if it is possible). Was anyone solving similar problem in past ? Any idea for algorithm modification ?

4

2 回答 2

5

您需要一个集群算法,其中您让包的领导者遵循 A* 方向,而另一个则跟随领导者的编队。

如果您有非常大的编队,您将遇到诸如“如何让所有士兵通过这个小洞”之类的问题,这就是您需要变得聪明的地方。

一个例子可能是在狭窄的地方强制执行单线阵型,其他的可能是将小组分解成更小的班。

于 2012-07-03T11:50:40.677 回答
2

如果你没有太多士兵,一个直接的修改是将问题视为多维问题,每个士兵代表 2 个维度。您可以将约束添加到这个多维空间,以确保您的士兵彼此靠近。然而,这可能在计算上变得昂贵。

人工势场通常成本较低且易于实施。它们可以扩展到合作战略。如果结合图形搜索技术,您就不会陷入局部最小值。谷歌给出了很多起点:http ://www.google.com/search?ie=UTF-8&oe=utf-8&q=motion+planning+potential+fields

于 2012-07-03T12:27:46.593 回答