Better simulation automation

This commit is contained in:
yairm210 2024-07-03 18:04:24 +03:00
parent 698b7db255
commit e397c52f4c
3 changed files with 2 additions and 6 deletions

View File

@ -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()
}

View File

@ -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)")
}

View File

@ -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))
}