AI: Better rules to not build unit-carrying units

This commit is contained in:
yairm210
2024-10-13 22:56:23 +03:00
parent 8d10ca881e
commit e5b4793d58

View File

@ -159,7 +159,9 @@ object Automation {
val totalCarriableUnits =
civInfo.units.getCivUnits().count { it.matchesFilter(carryFilter) }
val totalCarryingSlots = civInfo.units.getCivUnits().sumOf { getCarryAmount(it) }
return totalCarriableUnits < totalCarryingSlots
val currentUnitCarryingSlots = carryUnique.params[0].toInt()
return totalCarriableUnits < totalCarryingSlots + currentUnitCarryingSlots
}
fun chooseMilitaryUnit(city: City, availableUnits: Sequence<BaseUnit>): String? {
@ -197,7 +199,7 @@ object Automation {
.filter { allowSpendingResource(city.civ, it) }
.filterNot {
// filter out carrier-type units that can't attack if we don't need them
(it.hasUnique(UniqueType.CarryAirUnits) && it.hasUnique(UniqueType.CannotAttack))
it.hasUnique(UniqueType.CarryAirUnits)
&& providesUnneededCarryingSlots(it, city.civ)
}
// Only now do we filter out the constructable units because that's a heavier check