29 Commits

Author SHA1 Message Date
Dan Albert
a2c10f1c7a Check for compatible squadrons when buying planes.
https://github.com/dcs-liberation/dcs_liberation/issues/276
2021-05-27 19:58:45 -07:00
Dan Albert
c5159f8a87 Fix swapped list order for purchase priorities.
We were accidentally iterating over the faction list and checking it
against the priority list rather than the other way around, so the
faction's aircraft list was being used for purchase priority rather than
the actual priority list in the game.
2021-05-18 19:54:39 -07:00
Dan Albert
f4b64370bb Remove fallback for old non-convoy behavior. 2021-05-18 19:21:43 -07:00
Dan Albert
2ca875192a Save budget for filling whole packages.
No sense filling airbases with cheap escorts if we'll never afford the
rest of the package. Filling the airbases with cheap escorts also makes
it impossible to buy the rest of the package when the faction eventually
does have the money since there's nowhere to park the needed aircraft.

https://github.com/dcs-liberation/dcs_liberation/issues/1058
2021-05-07 18:22:52 -07:00
Dan Albert
2cf3b3be2b Fix bug causing overpurchase of aircraft.
After fulfilling a request we were not exiting the loop, so we'd fulfill
the request for the aircraft at _all_ the bases capable of operating it
until either the bases were full or the budget ran out. In factions like
Iraq 1991 this could cause the budget to be spent on tons of cheap
MiG-19s while never buying the more expensive Su-17s or Su-24s that they
need to actually complete a package.

https://github.com/dcs-liberation/dcs_liberation/issues/1058
2021-05-07 17:25:14 -07:00
Khopa
977845e2f4 Fixed links to github in the repo to account for the transfer to the new github organization. 2021-05-07 13:08:39 +02:00
Dan Albert
f69450e2ae Add auto-procurment for airlift assets.
https://github.com/Khopa/dcs_liberation/issues/825
2021-04-23 23:24:25 -07:00
Dan Albert
56fc2986e9 Automate transfers from factories.
The purchase system will seek out a source for its units when the
purchase is completed. If no source is available the order will be
refunded. Orders with no source available are prevented, so this only
happens when the source was cut off from the destination during the
turn.

There's still some funkiness going on with the first turn (but possibly
only when the first turn includes a cheat to capture) where the AI buys
a ton of units somewhere other than the front line. First turn behavior
should probably be different anyway, with the first turn allowing
purchases anywhere to avoid empty front lines while troops reinforce if
the front line isn't a factory.

https://github.com/Khopa/dcs_liberation/issues/986
2021-04-18 23:22:30 -07:00
Dan Albert
a47bef1f13 Blacken. 2021-02-12 20:10:45 -08:00
Dan Albert
fa1166d014 Limit reserve ground units to 10.
Allowing these to grow infinitely leads to some really weird behaviors
when the enemy has been buying reserves long enough, where capturing a
base might result in 80 enemy vehicles suddenly at the gates.

This is just an interim fix. Ideally these units would be reinforcing
the front line as needed
(https://github.com/Khopa/dcs_liberation/issues/382), and a CP could be
lost without needing to completely destroy the defender.
2021-01-09 13:10:21 -08:00
Dan Albert
6cbc2b707a Fix type of Game.budget.
This *is* a float, since the income multiplier is a float. The type
annotations were wrong.
2021-01-01 13:56:33 -08:00
Dan Albert
9671542bdf Decouple unit deliveries and conflict events.
Fixes https://github.com/Khopa/dcs_liberation/issues/692 and lets us
clean up the interface quite a bit.
2021-01-01 13:48:23 -08:00
Dan Albert
5734c29312 Remove wrong precondition in aircraft procurement.
Those task types aren't correct here (that whole dict probably serves
little purpose now), and the actual unit pool is handled in
_affordable_aircraft_of_types.
2020-12-28 16:06:54 -08:00
Dan Albert
3a9f585b6b Plan multiple CAP rounds per turn.
On station time for CAP is only 30 minutes, so plan three cycles to give
~90 minutes of CAP coverage.

Default starting budget has increased significantly to account for the
greatly increased aircraft needs on turn 1.

Fixes https://github.com/Khopa/dcs_liberation/issues/673
2020-12-26 17:26:07 -08:00
Dan Albert
c7f9bfbb43 Sell off incomplete opfor squadrons.
Short term fix for https://github.com/Khopa/dcs_liberation/issues/41.
2020-12-25 18:45:58 -08:00
Dan Albert
b5f8e6925b Rank aircraft purchase preferences.
Rather than randomly selecting compatible aircraft for missions, perfer
the *best* aircraft for the job. This removes the "preferred" lists in
favor of sorting the capable lists in priority order. To maintain some
amount of variety the procurer has a 50/50 chance of buying when it
finds a match.

Fixes https://github.com/Khopa/dcs_liberation/issues/510
2020-12-25 18:22:50 -08:00
Dan Albert
993e59413a Add pretty-print for AircraftProcurementRequest. 2020-12-25 17:31:26 -08:00
Dan Albert
6aa1f1cca0 Prefer buying aircraft at safe airbases.
Fixes https://github.com/Khopa/dcs_liberation/issues/652
2020-12-23 22:25:47 -08:00
Khopa
66149bb591 Fixed error in merge 2020-12-22 23:34:08 +01:00
Khopa
b0ad664ece Merge branch 'develop_2_3_x' into develop
# Conflicts:
#	changelog.md
#	game/procurement.py
#	resources/factions/iraq_1991.json
2020-12-22 23:32:06 +01:00
Khopa
12bf26223d Added shorad units on frontline 2020-12-22 23:23:32 +01:00
Khopa
60f837d0b9 Fixed : AI wouldn't buy artillery units 2020-12-21 13:34:56 +01:00
Dan Albert
2ac818dcdd Convert to new unit APIs, remove old APIs.
There are probably plenty of raw ints around that never used the old
conversion APIs, but we'll just need to fix those when we see them.

Fixes https://github.com/Khopa/dcs_liberation/issues/558
2020-12-19 22:08:57 -08:00
Dan Albert
8f30e60e1b Use unplanned missions to guide aircraft purchase.
AI aircraft purchase decisions are now driven by the missions that the
flight planner was unable to fulfill. This way we're buying the aircraft
we actually need instead of buying them at random, in the locations we
need them, in the order they're needed.

There's a bit more that could be improved here:

* Unused aircraft could be ferried to where they would be more useful.
* Partial squadrons could be completed rather than buying a whole flight
  at a time.
* Aircraft could be ranked by their usefulness so we're not buying so
  many Hueys when a Hornet would do better.
* Purchase a buffer of CAP capable aircraft in case too many are shot
  down and they are not available next turn.

https://github.com/Khopa/dcs_liberation/issues/361
2020-12-06 00:59:04 -08:00
Dan Albert
ce977ac937 Remove the enemy forces multiplier option.
This didn't do what it claimed to (it actually just determines the
threshold for whether a control point shoudl be a *preferred* canidate
for purchasing ground units), and the income multipliers offer the
intended behavior.
2020-12-05 23:55:33 -08:00
Dan Albert
aa9ffa0855 Obey parking limits when auto-buying aircraft.
Fixes https://github.com/Khopa/dcs_liberation/issues/137
2020-12-05 23:36:51 -08:00
Dan Albert
d519aa1dad Move the AI to the normal procurement system.
The procurement AI now uses the same system as the players. Orders are
placed and take a turn to fulfill.

This has a few advantages:

* We no longer need special case purchase logic for the turn 0
  population of opfor airbases.
* Players using auto-purchase can cancel orders they don't like.
2020-12-05 22:41:05 -08:00
Dan Albert
7226359e64 Avoid negative AI produrement budgets.
This also fixes the double charging that the AI was suffering from, so
they have a much better chance of actually affording planes now.

Fixes https://github.com/Khopa/dcs_liberation/issues/504
2020-12-05 21:50:30 -08:00
Dan Albert
1adee0af17 Factor AI purchases out of Game.
For now this is mostly behavior preserving. I slightly improved the
ability to buy units when multiple front lines exist by removing full
bases as candidates, but it should be a minor change at best. A larger
improvement will come later.

This is also written such that it will work for the player as well. The
procurer currently runs for the player but with all the options off, so
it does nothing. The next patch allows adds options for the player to
use auto-procurement.
2020-12-05 20:42:02 -08:00