dcs-liberation / dcs_liberation

DCS World dynamic campaign.
GNU Lesser General Public License v3.0
718 stars 184 forks source link

Improve AI aircraft purchase behavior #1058

Closed Schneefl0cke closed 3 years ago

Schneefl0cke commented 3 years ago

The enemy commander seldomly make sead/strike/oca missions, even if outnumbering the player faction by a large margin. It would be nice, if the enemy commander is more aggressive

A possible solution would be to add a "aircraft stance", like frontline stances that prioritizes certain missions. They should be bound to the statistics, e.g. in which category the ai thinks its stronger than the enemy.

DanAlbert commented 3 years ago

Most of the cases I see the problem is actually not having the right aircraft available, or out of range. The log will show red's planning failures on each new turn, but some new debugging tools would probably help.

DanAlbert commented 3 years ago

I think this is more generally a problem that occurs when the faction has access to cheap, pure CAP aircraft. When they start trying to buy for missions, they spend their budget well at first but eventually they're not able to afford any ground attack aircraft, but can afford MiG-19s. They end up buying MiG-19s to fill the escorts for multiple missions but are unable to afford the other aircraft for the mission. After a few rounds, the airfield is full of unused MiG-19s and no amount of money will solve the problem.

The trivial fix would be to stop purchasing aircraft as soon as the purchaser is unable to fill a mission because of cost (it might also not be able to fill a mission because of distance, and I haven't dug enough to know the implications of that yet). This is probably fine, but we should probably start earmarking the leftover budget for aircraft if we do that, because otherwise half of the leftover aircraft budget will end up being spent on ground units next turn.

Another problem, specific to CAS, is that we limit CAS missions to airbases within 50 nm of the target. IIRC this is because it's the only real mission type for helicopters and we don't currently handle ranges differently per-aircraft. That probably needs to be fixed.

A good way to demo the problem is to start a new campaign on Battle of Abu Dhabi with opfor as Iraq 1991 (or invert the map and have the player be Iraq). That faction has a limited selection of ground attack aircraft but does have access to the super cheap MiG-19P.

DanAlbert commented 3 years ago

I also found a bug where we were missing a stop condition on the purchase loop, so each purchase request was being fulfilled at every airfield that could support it until the budget was empty. Pushed a fix for that case. That alone actually largely solved this problem for everything but the CAS range problem for that particular campaign set up. It's still over-purchasing air-to-air aircraft, but plenty of opfor strike missions are being planned now.

DanAlbert commented 3 years ago

The trivial fix would be to stop purchasing aircraft as soon as the purchaser is unable to fill a mission because of cost... but we should probably start earmarking the leftover budget for aircraft if we do that

Part 1 is done. Part 2 requires a bit of rework so that budget is an object instead of just a single float. Seems to be working okay as-is though.

DanAlbert commented 3 years ago

Forked the remaining work into https://github.com/dcs-liberation/dcs_liberation/issues/1064 since it's not really related to the purchase AI.