mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 05:09:25 +07:00
AI no longer uses all its aluminum on units and leaves some for spaceship construction
This commit is contained in:
@ -63,6 +63,10 @@ object Automation {
|
||||
if (militaryUnits.map { it.name }.contains(city.cityConstructions.currentConstructionFromQueue))
|
||||
return city.cityConstructions.currentConstructionFromQueue
|
||||
|
||||
// This is so that the AI doesn't use all its aluminum on units and have none left for spaceship parts
|
||||
if (city.civInfo.getCivResourcesByName()["Aluminum"]!! < 2)
|
||||
militaryUnits.filter { it.requiredResource != "Aluminum" }
|
||||
|
||||
val findWaterConnectedCitiesAndEnemies = BFS(city.getCenterTile()) { it.isWater || it.isCityCenter() }
|
||||
findWaterConnectedCitiesAndEnemies.stepToEnd()
|
||||
if (findWaterConnectedCitiesAndEnemies.tilesReached.keys.none {
|
||||
@ -75,7 +79,6 @@ object Automation {
|
||||
if (!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit == null }
|
||||
&& militaryUnits.any { it.unitType == UnitType.Ranged }) // this is for city defence so get an archery unit if we can
|
||||
chosenUnit = militaryUnits.filter { it.unitType == UnitType.Ranged }.maxBy { it.cost }!!
|
||||
|
||||
else { // randomize type of unit and take the most expensive of its kind
|
||||
val chosenUnitType = militaryUnits.map { it.unitType }.distinct().filterNot { it == UnitType.Scout }.toList().random()
|
||||
chosenUnit = militaryUnits.filter { it.unitType == chosenUnitType }.maxBy { it.cost }!!
|
||||
|
Reference in New Issue
Block a user