AI and Pathfinding

Moderators: Balthagor, Moderators

Post Reply
User avatar
Uriens
Brigadier Gen.
Posts: 588
Joined: Oct 05 2005

AI and Pathfinding

Post by Uriens »

I have a suggestion on how to improve AI and its pathfinding with least amount of effort mostly using the resources already included in the game. I don't think it will be easy or effortless but it will give you most 'bang for the buck' effect.

From what i understand game uses A* pathfinding which means that it assigns 'points of value' to each hex and then, based on it, it calculates best route to target. Units, territory ownership, supply value, terrain, roads, etc all work as modifiers of hex value. AI will prefer hexes with high value hexes over low ones.
Most of the problems i have seen so far with AI is poor pathfinding that often leads units like out of supply or badly damaged and going for repairs right through enemy territory, cities or units trying to get there. I've seen pathfinding of units that had repair order lead them straight through enemy capitol bc there was road there ... horrible. I'd go as far to say that most AI losses can be attributed to bad pathfinding.
How to fix that?
My suggestion is using different already existing route and speed parameters but changing the way they are used by AI. Example, retreating damaged unit should AVOID enemy territory, units, fortifications and cities while traveling fast to their destination, attacking units should not care that much about roads (tracked units not at all) and should try to capture enemy cities, and fortifications while going slow or normal speed (supply reasons).
Basically, AI would choose different route and speed based on unit ORDERS. Retreating units - cautious route, fast speed. Attacking units normal or direct (based on wheeled or tracked), normal or slow speed (slow if there are no neighboring hexes with supplies). Also, Units SHOULD NEVER stop when out of ammo but still having fuel in very low or no supply hexes.

Here is a list of orders and route/speed parameters that i suggest. It's just a draft ofc. Actual values will need testing and tweaking.
Just a reference - in SRU there are 4 speed and 4 route settings. Route settings are quickest, direct, normal and cautious. Speed can be Fastest, Fast, Normal and Slow.

1) Attacking - Tracked units Speed: slow/normal, Route: direct. Wheeled units Speed: slow/normal, Route: normal
2) Defending - Speed: fast, Route: normal or direct (direct if close to enemy units/territory).
3) Patrolling borders - Speed: normal, Route: normal
4) Repairs - Speed: fast in low supply/close to enemy and fastest when in safe area. Route: cautious.
5) Out of fuel supplies Speed: slow, Route: cautious.
6) Out of military supplies(ammo) Speed: fast, Route: cautious
7) Artillery on attack or defense orders - Speed: slow (they need to stay behind other troops), Route: cautious.
8) Units in transit - going to their assigned locations but not going to combat yet (not on attack or defend orders) Speed: fastest, Route: quickest.
9) Supply support (trucks that follow units to resupply them) - Speed: normal, Route: cautious.

Now for this to work Route pathfinding will need tweaking:
Cautious - Should have much lower score on enemy territory hexes or at the borders (1 hex from enemy territory) so that AI will try to avoid those if possible. Enemy cities and units should also lower 'hex score' a lot. Road/rail tiles should have much less effect on units using this route parameter as it often leads them to their deaths.
Normal - Close to what we have now in SRU (don't know what is difference between SRU and SR2030 pathfinding yet). With important tweak to have tracked units not care much about road hexes unlike wheeled ones.
Direct - Usually for attack defend units. Those units won't care much about enemy borders or roads/rails, they will pick best direct route to the target. Wheeled units will have somewhat higher road preference but not much.
Quickest - High road/rail preference. Used for safe areas outside combat zone. Mostly for units in transit.

So when attacking unit that was on slow/direct gets repair orders its speed/route settings would change to fast/cautious in order to get to the location fast and as safe as possible.
From what i understand -> higher speed = higher fuel consumption so low fuel supply units should use slow speed to conserve fuel and go to the supplied hexes while low ammo units should go fast speed to get to those high supply hexes faster.

Hopefully you will find my suggestion at least partially useful to improve unit pathfinding.
Post Reply

Return to “Suggestions - 2030”