mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-03 13:30:51 +07:00
Better simulation automation
This commit is contained in:
parent
698b7db255
commit
e397c52f4c
@ -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()
|
||||
}
|
||||
|
@ -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)")
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user