From ed1f0af308ca589c1c6157135738b07705d6a982 Mon Sep 17 00:00:00 2001 From: EmperorPinguin <99119424+EmperorPinguin@users.noreply.github.com> Date: Fri, 22 Aug 2025 13:32:41 +0200 Subject: [PATCH 1/2] Update EspionageAutomation.kt --- .../automation/unit/EspionageAutomation.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt b/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt index 50055c602f..17d6edf514 100644 --- a/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt @@ -4,6 +4,7 @@ import com.unciv.logic.civilization.Civilization import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.models.Spy import com.unciv.models.SpyAction +import com.unciv.ui.screens.victoryscreen.RankingType import kotlin.random.Random class EspionageAutomation(val civInfo: Civilization) { @@ -26,23 +27,23 @@ class EspionageAutomation(val civInfo: Civilization) { val spies = civInfo.espionageManager.spyList val spiesToMove = spies.filter { it.isAlive() && !it.isDoingWork() } for (spy in spiesToMove) { - val randomSeed = spies.size + spies.indexOf(spy) + civInfo.gameInfo.turns - val randomAction = Random(randomSeed).nextInt(10) + val spyIsMaxPromoted = spy.rank == civInfo.gameInfo.ruleset.modOptions.constants.maxSpyRank + val techRank = civInfo.gameInfo.getAliveMajorCivs().sortedByDescending { it.getStatForRanking(RankingType.Technologies) }.indexOf(civInfo) // Try each operation based on the random value and the success rate // If an operation was not successfull try the next one val capital = civInfo.getCapital() when { + spyIsMaxPromoted && automateSpyRigElection(spy) -> continue // Other spies can still be ranked up via stealing or counterspying + techRank != 0 && automateSpyStealTech(spy) -> continue // If we're tech leadeer, we'll soon run out of stealable techs, if we haven't already capital != null && spies.none { it.getCityOrNull() == capital } -> { - spy.moveTo(capital) + spy.moveTo(capital) // Place in capital before choosing based on science output, as capital is visible via embassies continue } - randomAction <= 7 && automateSpyStealTech(spy) -> continue - randomAction <= 9 && automateSpyRigElection(spy) -> continue - automateSpyCounterInteligence(spy) -> continue + automateSpyCounterIntelligence(spy) -> continue // We might have been doing counter intelligence and wanted to look for something better spy.isDoingWork() -> continue - // Retry initial operations one more time, without the randomAction check + // Retry initial operations one more time, without the check automateSpyStealTech(spy) -> continue automateSpyRigElection(spy) -> continue } @@ -78,13 +79,11 @@ class EspionageAutomation(val civInfo: Civilization) { spy.moveTo(cityToMoveTo) return cityToMoveTo != null } - - /** * Moves the spy to a random city of ours */ - private fun automateSpyCounterInteligence(spy: Spy): Boolean { + private fun automateSpyCounterIntelligence(spy: Spy): Boolean { val cityToMoveTo = civInfo.cities.filter { spy.canMoveTo(it) } .maxByOrNull { it.cityStats.currentCityStats.science } if (cityToMoveTo == null) return false From 469e1ce2983c8bad3463ea3f226e1670eb3f5236 Mon Sep 17 00:00:00 2001 From: EmperorPinguin <99119424+EmperorPinguin@users.noreply.github.com> Date: Fri, 22 Aug 2025 13:34:51 +0200 Subject: [PATCH 2/2] Update EspionageAutomation.kt --- core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt b/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt index 17d6edf514..ef79a0b213 100644 --- a/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/EspionageAutomation.kt @@ -35,7 +35,7 @@ class EspionageAutomation(val civInfo: Civilization) { val capital = civInfo.getCapital() when { spyIsMaxPromoted && automateSpyRigElection(spy) -> continue // Other spies can still be ranked up via stealing or counterspying - techRank != 0 && automateSpyStealTech(spy) -> continue // If we're tech leadeer, we'll soon run out of stealable techs, if we haven't already + techRank != 0 && automateSpyStealTech(spy) -> continue // If we're tech leader, we'll soon run out of stealable techs, if we haven't already capital != null && spies.none { it.getCityOrNull() == capital } -> { spy.moveTo(capital) // Place in capital before choosing based on science output, as capital is visible via embassies continue