From c3db8ba9712d4462825218c54e30bc197378afc8 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 14 Jun 2023 09:58:02 +0300 Subject: [PATCH] AI prioritizes its path to buying highly desirable tiles --- .../unciv/logic/automation/city/ConstructionAutomation.kt | 2 +- .../logic/automation/civilization/NextTurnAutomation.kt | 5 ++++- 2 files 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 91d2a41012..5812ed725c 100644 --- a/core/src/com/unciv/logic/automation/city/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/city/ConstructionAutomation.kt @@ -161,7 +161,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ val bfs = BFS(cityInfo.getCenterTile()) { (it.isWater || it.isCityCenter()) && (it.getOwner() == null || it.isFriendlyTerritory(civInfo)) } - repeat(20) { bfs.nextStep() } // + repeat(20) { bfs.nextStep() } if (!bfs.getReachedTiles() .any { tile -> diff --git a/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt index 89445cd9b4..5e7a741ffd 100644 --- a/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt @@ -384,7 +384,10 @@ object NextTurnAutomation { val cityWithLeastCostToBuy = highlyDesirableTile.value.minBy { it.getCenterTile().aerialDistanceTo(highlyDesirableTile.key) } - val bfs = BFS(cityWithLeastCostToBuy.getCenterTile()) { + val bfs = BFS(cityWithLeastCostToBuy.getCenterTile(), + // Give higher priority on the way to intermediate tiles with higher ranking stats + { Automation.rankStatsValue(it.stats.getTileStats(cityWithLeastCostToBuy, civInfo), civInfo).toInt() }) + { it.getOwner() == null || it.getOwner() == civInfo } bfs.stepUntilDestination(highlyDesirableTile.key)