From e397c52f4c68d1e73de2d0180eb90b2e47d8d7cd Mon Sep 17 00:00:00 2001 From: yairm210 Date: Wed, 3 Jul 2024 18:04:24 +0300 Subject: [PATCH] Better simulation automation --- core/src/com/unciv/logic/civilization/Civilization.kt | 1 + core/src/com/unciv/logic/simulation/Simulation.kt | 6 +----- core/src/com/unciv/logic/simulation/SimulationStep.kt | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/Civilization.kt b/core/src/com/unciv/logic/civilization/Civilization.kt index 6c869d6146..ae8e2d4a1f 100644 --- a/core/src/com/unciv/logic/civilization/Civilization.kt +++ b/core/src/com/unciv/logic/civilization/Civilization.kt @@ -353,6 +353,7 @@ class Civilization : IsPartOfGameInfoSerialization { fun isAI() = playerType == PlayerType.AI fun isAIOrAutoPlaying(): Boolean { if (playerType == PlayerType.AI) return true + if (gameInfo.isSimulation()) return true val worldScreen = UncivGame.Current.worldScreen ?: return false return worldScreen.viewingCiv == this && worldScreen.autoPlay.isAutoPlaying() } diff --git a/core/src/com/unciv/logic/simulation/Simulation.kt b/core/src/com/unciv/logic/simulation/Simulation.kt index 70e35af82a..4e8803113a 100644 --- a/core/src/com/unciv/logic/simulation/Simulation.kt +++ b/core/src/com/unciv/logic/simulation/Simulation.kt @@ -17,8 +17,7 @@ import kotlin.time.ExperimentalTime @ExperimentalTime class Simulation( private val newGameInfo: GameInfo, - val simulationsPerThread: Int = 1 - , + val simulationsPerThread: Int = 1, private val threadsNumber: Int = 1, private val maxTurns: Int = 500 ) { @@ -67,7 +66,6 @@ class Simulation( } else println("Max simulation ${step.turns} turns reached: Draw") - print(gameInfo) updateCounter(threadId) add(step) } @@ -80,14 +78,12 @@ class Simulation( @Suppress("UNUSED_PARAMETER") // used when activating debug output @Synchronized fun add(step: SimulationStep, threadId: Int = 1) { -// println("Thread $threadId: End simulation ($stepCounter/$maxSimulations)") steps.add(step) } @Suppress("UNUSED_PARAMETER") // used when activating debug output @Synchronized fun updateCounter(threadId: Int = 1) { stepCounter++ -// println("Thread $threadId: Start simulation ($stepCounter/$maxSimulations)") println("Simulation step ($stepCounter/$maxSimulations)") } diff --git a/core/src/com/unciv/logic/simulation/SimulationStep.kt b/core/src/com/unciv/logic/simulation/SimulationStep.kt index 1bb1782527..ac6581ea83 100644 --- a/core/src/com/unciv/logic/simulation/SimulationStep.kt +++ b/core/src/com/unciv/logic/simulation/SimulationStep.kt @@ -7,7 +7,6 @@ class SimulationStep (gameInfo: GameInfo) { var victoryType = gameInfo.getCurrentPlayerCivilization().victoryManager.getVictoryTypeAchieved() var winner: String? = null val currentPlayer = gameInfo.currentPlayer -// val durationString: String = formatDuration(Duration.ofMillis(System.currentTimeMillis() - startTime)) }