There are many times I find myself with a large army that is very far from where it needs to be. For instance, I have just finished off one enemy, but my next enemy is across the map. In these cases, I would like to have my army be able to move intelligently over long distances without me having to worry about them, so I can focus on other areas of the map.
However, I have noticed a couple problems with the current pathing implementation:
I) There does not appear to be a logical order in which the computer will move your units. I do not know how it is currently decided now, but it is not optimal by any means. Oftentimes I will have a unit way in the back move a couple hexes until it hits someone in front of it - then the person in front will move afterwards, and the rear unit is left with unused unit points (even though its crystal ball shows up as red) while it still has many free hexes to go. A similar problem crops up when units with 6 move get stuck behind units with 5 move forever, for example. Every turn the 6-move unit wastes one move, while the 5-move unit could waste one move for one turn and never impede the 6-move unit again.
II) The units select the most efficient possible line from point A to B, and refuse to deviate from this path. This becomes a problem when you are moving any significant number of units. They begin to form a single-column line - and given the above problem, this results in it being unable to move very quickly at all. If they would instead be able to consider a slightly-less-efficient path, and branch out into two or three columns, the whole army could move more quickly.
Right now, the pathing is so bad that I have given up trying to let the computer move my units. I take so long double-checking and correcting the computer that I save time moving them myself.
Is there any particular reason why it works the way it does now? I know that we want to keep the AI simple enough that it does not begin to bog down the computer, and I have not programmed in years and never in Python, but it should not be too taxing on the computer. Here is my general idea for some heuristics that I do not believe would be too taxing:
1) First, units with the highest movement move before slower ones - this means that quick units will rapidly get in front of the slower units causing the roadblocks, and reach their objective the fastest. If you want your army to move as one block, you can always slow down the fast units, you can't speed up the slow ones.
2) Second, units closer to their objective move before distant ones - this prevents a lot of wasted movement points, when the rear units only move a couple of spaces, before the vanguard gets to move at all. With this in place, the whole column would be able to move intelligently instead of the current stutter-step.
Pitfall: With higher movement units coming before closer units, you can wind up where a high-move unit in the back of the column will not be able to advance as much as it could otherwise hypothetically move, wasting movement points. The third step below partially mitigates this, although I think something creative could be done beforehand... The computer could check and see if any other unit were standing on the current unit's eventual destination and move that unit first, but I think that is beginning to increase the complexity since that would necessitate an entire movement tree.
3) Travel along the most efficient path as already defined - until you hit another unit cluster, and you still have movement points left. At this point, search adjacent hexes for alternative routes (this does not have to be extremely intelligent or complicated, just enough to make the units file into multiple columns). Even if you only have a single movement point left, you can still move to the side and allow the unit behind that one to move one space closer to its destination. This will always help the entire column's movement, even if it will sometimes break even for individual units.
I think that this could greatly improve the capacity for the computer to move large armies across long distances. Any thoughts/suggestions/improvements? Any obvious flaw I am missing that completely destroys the idea? Do the coders out there think that this could be reasonably implemented?
