From 4357d2513a7dff691572f136853b92a9268f2f74 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 2 Jul 2020 19:56:59 +0300 Subject: [PATCH] Resolved #2787 - AIs MUCH more likely to build the Apollo Program and win a scientific victory --- .../automation/ConstructionAutomation.kt | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index 2de58f2357..cf0ef2565b 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -147,8 +147,8 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ val spaceshipPart = buildableNotWonders.firstOrNull { it.uniques.contains("Spaceship part") } if (spaceshipPart != null) { var modifier = 1.5f - if(cityInfo.cityStats.currentCityStats.culture==0f) // It won't grow if we don't help it - modifier=0.8f + if (cityInfo.cityStats.currentCityStats.culture == 0f) // It won't grow if we don't help it + modifier = 0.8f if (preferredVictoryType == VictoryType.Scientific) modifier = 2f addChoice(relativeCostEffectiveness, spaceshipPart.name, modifier) } @@ -162,34 +162,36 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ } } - private fun addWondersChoice() { - if (buildableWonders.any()) { - fun getWonderPriority(wonder: Building): Float { - if (preferredVictoryType == VictoryType.Cultural - && wonder.name in listOf("Sistine Chapel", "Eiffel Tower", "Cristo Redentor", "Neuschwanstein", "Sydney Opera House")) - return 3f - if (wonder.isStatRelated(Stat.Science)) { - if (preferredVictoryType == VictoryType.Scientific) return 1.5f - else return 1.3f - } - if (wonder.name == "Manhattan Project") { - if (preferredVictoryType == VictoryType.Domination) return 2f - else return 1.3f - } - if (wonder.isStatRelated(Stat.Happiness)) return 1.2f - if (wonder.isStatRelated(Stat.Production)) return 1.1f - return 1f - } - - val highestPriorityWonder = buildableWonders - .maxBy { getWonderPriority(it) }!! - val citiesBuildingWonders = civInfo.cities - .count { it.cityConstructions.isBuildingWonder() } - - var modifier = 2f * getWonderPriority(highestPriorityWonder) / (citiesBuildingWonders + 1) - if (!cityIsOverAverageProduction) modifier /= 5 // higher production cities will deal with this - addChoice(relativeCostEffectiveness, highestPriorityWonder.name, modifier) + private fun getWonderPriority(wonder: Building): Float { + if(wonder.uniques.contains("Enables construction of Spaceship parts")) + return 2f + if (preferredVictoryType == VictoryType.Cultural + && wonder.name in listOf("Sistine Chapel", "Eiffel Tower", "Cristo Redentor", "Neuschwanstein", "Sydney Opera House")) + return 3f + if (wonder.isStatRelated(Stat.Science)) { + if (preferredVictoryType == VictoryType.Scientific) return 1.5f + else return 1.3f } + if (wonder.name == "Manhattan Project") { + if (preferredVictoryType == VictoryType.Domination) return 2f + else return 1.3f + } + if (wonder.isStatRelated(Stat.Happiness)) return 1.2f + if (wonder.isStatRelated(Stat.Production)) return 1.1f + return 1f + } + + private fun addWondersChoice() { + if (!buildableWonders.any()) return + + val highestPriorityWonder = buildableWonders + .maxBy { getWonderPriority(it) }!! + val citiesBuildingWonders = civInfo.cities + .count { it.cityConstructions.isBuildingWonder() } + + var modifier = 2f * getWonderPriority(highestPriorityWonder) / (citiesBuildingWonders + 1) + if (!cityIsOverAverageProduction) modifier /= 5 // higher production cities will deal with this + addChoice(relativeCostEffectiveness, highestPriorityWonder.name, modifier) } private fun addUnitTrainingBuildingChoice() {