transfer simulateUntilWin from UncivGame to GameInfo class. (#2849)
* transfer simulateUntilWin from UncivGame to GameInfo class. * update tests * Update description comments
This commit is contained in:
parent
6309bc2fba
commit
e74f7608d1
5 changed files with 13 additions and 16 deletions
|
@ -47,14 +47,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||
*/
|
||||
val simulateUntilTurnForDebug: Int = 0
|
||||
|
||||
/** Simulate until any player wins,
|
||||
* or turns exceeds indicated number
|
||||
* Does not update World View changes until finished.
|
||||
* Set false to disable.
|
||||
*/
|
||||
var simulateMaxTurns: Int = 1500
|
||||
var simulateUntilWin = false
|
||||
|
||||
/** Console log battles
|
||||
*/
|
||||
val alertBattle = false
|
||||
|
|
|
@ -35,8 +35,13 @@ class GameInfo {
|
|||
var oneMoreTurnMode=false
|
||||
var currentPlayer=""
|
||||
var gameId = UUID.randomUUID().toString() // random string
|
||||
// can't be taken directly from Unciv.Current.SimulateUntilWin because this causes problems with downloading multiplayer games.,
|
||||
// should probably be either 'manually set' upon creation
|
||||
|
||||
/** Simulate until any player wins,
|
||||
* or turns exceeds indicated number
|
||||
* Does not update World View until finished.
|
||||
* Should be set manually on each new game start.
|
||||
*/
|
||||
var simulateMaxTurns: Int = 1000
|
||||
var simulateUntilWin = false
|
||||
|
||||
//region pure functions
|
||||
|
@ -87,7 +92,7 @@ class GameInfo {
|
|||
|
||||
while (thisPlayer.playerType == PlayerType.AI
|
||||
|| turns < UncivGame.Current.simulateUntilTurnForDebug
|
||||
|| (turns < UncivGame.Current.simulateMaxTurns && simulateUntilWin)
|
||||
|| (turns < simulateMaxTurns && simulateUntilWin)
|
||||
// For multiplayer, if there are 3+ players and one is defeated,
|
||||
// we'll want to skip over their turn
|
||||
|| (thisPlayer.isDefeated() && gameParameters.isOnlineMultiplayer)
|
||||
|
|
|
@ -10,7 +10,8 @@ import kotlin.concurrent.thread
|
|||
|
||||
class Simulation(val newGameInfo: GameInfo,
|
||||
val simulationsPerThread: Int = 5,
|
||||
val threadsNumber: Int = 1
|
||||
val threadsNumber: Int = 1,
|
||||
val maxTurns: Int = 1000
|
||||
) {
|
||||
val maxSimulations = threadsNumber * simulationsPerThread
|
||||
val civilizations = newGameInfo.civilizations.filter { it.civName != "Spectator" }.map { it.civName }
|
||||
|
@ -43,6 +44,8 @@ class Simulation(val newGameInfo: GameInfo,
|
|||
threads.add(thread {
|
||||
for (i in 1..simulationsPerThread) {
|
||||
val gameInfo = GameStarter.startNewGame(GameSetupInfo(newGameInfo))
|
||||
gameInfo.simulateMaxTurns = maxTurns
|
||||
gameInfo.simulateUntilWin = true
|
||||
gameInfo.nextTurn()
|
||||
|
||||
var step = SimulationStep(gameInfo)
|
||||
|
|
|
@ -36,8 +36,6 @@ internal object ConsoleLauncher {
|
|||
|
||||
UncivGame.Current = game
|
||||
UncivGame.Current.settings = GameSettings().apply { showTutorials = false }
|
||||
UncivGame.Current.simulateMaxTurns = 1000
|
||||
UncivGame.Current.simulateUntilWin = true
|
||||
|
||||
RulesetCache.loadRulesets(true)
|
||||
|
||||
|
@ -47,7 +45,7 @@ internal object ConsoleLauncher {
|
|||
val newGame = GameStarter.startNewGame(gameSetupInfo)
|
||||
UncivGame.Current.gameInfo = newGame
|
||||
|
||||
var simulation = Simulation(newGame,25,4)
|
||||
var simulation = Simulation(newGame,10,4)
|
||||
|
||||
simulation.start()
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ class BasicTests {
|
|||
!game.superchargedForDebug
|
||||
&& !game.viewEntireMapForDebug
|
||||
&& game.simulateUntilTurnForDebug <= 0
|
||||
&& !game.simulateUntilWin
|
||||
&& !game.consoleMode
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue