From bf1e613bdd09a5f5381a05f0d1374512c0409775 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 9 Jan 2023 18:45:55 +0200 Subject: [PATCH] Resolve #7869 - limit the number of workers an AI creates --- .../unciv/logic/automation/city/ConstructionAutomation.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/city/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/city/ConstructionAutomation.kt index bb6e61ab8c..ab395fd1ca 100644 --- a/core/src/com/unciv/logic/automation/city/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/city/ConstructionAutomation.kt @@ -171,8 +171,11 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ }.isBuildable() if (workerEquivalents.none()) return // for mods with no worker units - if (workers < cities) { - var modifier = cities / (workers + 0.1f) // The worse our worker to city ratio is, the more desperate we are + // For the first 3 cities, dedicate a worker, from then on only build another worker if you have 12 cities. + val numberOfWorkersWeWant = if (cities < 4) cities else max(3, cities/3) + + if (workers < numberOfWorkersWeWant) { + var modifier = numberOfWorkersWeWant / (workers + 0.1f) // The worse our worker to city ratio is, the more desperate we are if (!cityIsOverAverageProduction) modifier /= 5 // higher production cities will deal with this addChoice(relativeCostEffectiveness, workerEquivalents.minByOrNull { it.cost }!!.name, modifier) }