From 811ed5a7a2bb60c075582bde7e6934b773bb8290 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 20 Jan 2019 23:05:08 +0200 Subject: [PATCH] Better AI build order for #416 --- core/src/com/unciv/logic/automation/Automation.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/automation/Automation.kt b/core/src/com/unciv/logic/automation/Automation.kt index 8445f316de..6280e90cea 100644 --- a/core/src/com/unciv/logic/automation/Automation.kt +++ b/core/src/com/unciv/logic/automation/Automation.kt @@ -63,9 +63,6 @@ class Automation { fun chooseNextConstruction(cityConstructions: CityConstructions) { cityConstructions.run { - //currentConstruction="" // This is so that if we're currently in the middle of building a wonder, - // buildableWonders will still contain it - val buildableNotWonders = getBuildableBuildings().filterNot { it.isWonder } val buildableWonders = getBuildableBuildings().filter { it.isWonder } @@ -81,6 +78,7 @@ class Automation { val goldBuildings = buildableNotWonders.filter { it.gold>0 } val wartimeBuildings = buildableNotWonders.filter { it.xpForNewUnits>0 || it.cityStrength>0 }.sortedBy { it.maintenance } val zeroMaintenanceBuildings = buildableNotWonders.filter { it.maintenance == 0 && it !in wartimeBuildings } + val productionBuildings = buildableNotWonders.filter { it.production>0 } val isAtWar = cityInfo.civInfo.isAtWar() when { @@ -95,14 +93,15 @@ class Automation { buildableNotWonders.any { it.name=="Market"} -> currentConstruction = "Market" militaryUnits==0 -> trainCombatUnit(cityInfo) workers==0 -> currentConstruction = CityConstructions.Worker - zeroMaintenanceBuildings.isNotEmpty() -> currentConstruction = zeroMaintenanceBuildings.getRandom().name + productionBuildings.isNotEmpty() -> currentConstruction = productionBuildings.minBy { it.cost }!!.name + zeroMaintenanceBuildings.isNotEmpty() -> currentConstruction = zeroMaintenanceBuildings.minBy { it.cost }!!.name isAtWar && militaryUnits trainCombatUnit(cityInfo) - isAtWar && wartimeBuildings.isNotEmpty() -> currentConstruction = wartimeBuildings.getRandom().name + isAtWar && wartimeBuildings.isNotEmpty() -> currentConstruction = wartimeBuildings.minBy { it.cost }!!.name needWorkboat -> currentConstruction = "Work Boats" workers currentConstruction = CityConstructions.Worker militaryUnits trainCombatUnit(cityInfo) buildableNotWonders.isNotEmpty() -> currentConstruction = buildableNotWonders.minBy { it.maintenance }!!.name - buildableWonders.isNotEmpty() -> currentConstruction = buildableWonders.getRandom().name + buildableWonders.isNotEmpty() -> currentConstruction = buildableWonders.minBy { it.cost }!!.name else -> trainCombatUnit(cityInfo) }