That's my first question here.
Please advice me. Even little help is relevant for me. I'm having trouble thinking of an algorithm about pathfinding. But not normal. There are plenty of algorithms for single units trying to find each other.
But what about formations? Here are some rules about the formation concept.
- They are rigid in shape.
- Consists troops (each troop occupies one cell)
- Formations are always rectangular
- Minimum size enclosing all troops within
- Can shrink when casualties causes its size to be too big
A collaborative pathfinding. Long story short, formation cannot proceed further even when single cell is not able to move due to obstacle or something. Then new path is calculated.
What I came up recently was fruitless:
- temp grid with size of the formation: wouldn't work, formations vary in size, can shrink due to casualties, and most importantly: i would be able to create a path only from complete stay to complete move; no in-between cells.
- in the direction of possible movement, pick one center unit and do the pathfinding. In each step of calculations check if the cell has enough free space from left and right (width/height of a formation).
- pathfinding for only one commander unit, everyone would just overlap during the travelling to the commander. But that is a cheat and unfair to player, when computer does such a tricks and he can't.
Don't require any code, mates. Even advice helps me a lot. Or pseudo-code algorithm, described.
Regards, Paul.