mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Fixed RNG: Maps reproducibility (#4112)
* The RNG for picking resources locations and rivers starting points was not seeded properly. Maps are now fully reproducible by passing the same set of MapParameters RNG Seed in Map Editor * Creating a new map from MapEditorMenuPopup reseeds automatically the RNG * Added Seed on top of MapEditorMenuPopup * Added Copy to clipboard button on top of MapEditorMenuPopup to copy the currently used RNG Seed * UI FIX: Buttons in MapEditorMenuPopup have all the same width Fixed RNG Seed in NewGameScreen * When clicking on "Start new game" from VictoryScreen, a new seed is generated * When clicking on "Start new game" from WorldScreenMenuPopup, a new seed is generated
This commit is contained in:
parent
e1c6cef111
commit
09f1deaee0
@ -140,8 +140,12 @@ class MapParameters {
|
|||||||
var resourceRichness = 0.1f
|
var resourceRichness = 0.1f
|
||||||
var waterThreshold = 0f
|
var waterThreshold = 0f
|
||||||
|
|
||||||
fun resetAdvancedSettings() {
|
fun reseed() {
|
||||||
seed = System.currentTimeMillis()
|
seed = System.currentTimeMillis()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resetAdvancedSettings() {
|
||||||
|
reseed()
|
||||||
tilesPerBiomeArea = 6
|
tilesPerBiomeArea = 6
|
||||||
maxCoastExtension = 2
|
maxCoastExtension = 2
|
||||||
elevationExponent = 0.7f
|
elevationExponent = 0.7f
|
||||||
|
@ -348,7 +348,7 @@ class MapGenerationRandomness{
|
|||||||
.sortedBy { it.value }.map { it.key }
|
.sortedBy { it.value }.map { it.key }
|
||||||
val firstKeyWithTilesLeft = orderedKeys
|
val firstKeyWithTilesLeft = orderedKeys
|
||||||
.first { availableTiles.any { tile -> tile.baseTerrain== it} }
|
.first { availableTiles.any { tile -> tile.baseTerrain== it} }
|
||||||
val chosenTile = availableTiles.filter { it.baseTerrain==firstKeyWithTilesLeft }.random()
|
val chosenTile = availableTiles.filter { it.baseTerrain==firstKeyWithTilesLeft }.random(RNG)
|
||||||
availableTiles = availableTiles.filter { it.aerialDistanceTo(chosenTile) > distanceBetweenResources }
|
availableTiles = availableTiles.filter { it.aerialDistanceTo(chosenTile) > distanceBetweenResources }
|
||||||
chosenTiles.add(chosenTile)
|
chosenTiles.add(chosenTile)
|
||||||
baseTerrainsToChosenTiles[firstKeyWithTilesLeft] = baseTerrainsToChosenTiles[firstKeyWithTilesLeft]!!+1
|
baseTerrainsToChosenTiles[firstKeyWithTilesLeft] = baseTerrainsToChosenTiles[firstKeyWithTilesLeft]!!+1
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.ui.mapeditor
|
package com.unciv.ui.mapeditor
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.MainMenuScreen
|
import com.unciv.MainMenuScreen
|
||||||
@ -12,9 +13,15 @@ class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorS
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
defaults().fillX()
|
defaults().fillX()
|
||||||
addButton("New map", 'n') { UncivGame.Current.setScreen(NewMapScreen(mapEditorScreen.tileMap.mapParameters)) }
|
add(("{RNG Seed} " + mapEditorScreen.tileMap.mapParameters.seed.toString()).toLabel()).row()
|
||||||
addButton("Save map", 's') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, true, mapEditorScreen)); this.close() }
|
addButton("Copy to clipboard") { Gdx.app.clipboard.contents = mapEditorScreen.tileMap.mapParameters.seed.toString() }
|
||||||
addButton("Load map", 'l') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, false, mapEditorScreen)); this.close() }
|
addSeparator()
|
||||||
|
addButton("New map", 'n') {
|
||||||
|
mapEditorScreen.tileMap.mapParameters.reseed()
|
||||||
|
UncivGame.Current.setScreen(NewMapScreen(mapEditorScreen.tileMap.mapParameters))
|
||||||
|
}
|
||||||
|
addButton("Save map", 's') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, true, mapEditorScreen)); close() }
|
||||||
|
addButton("Load map", 'l') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, false, mapEditorScreen)); close() }
|
||||||
addButton("Exit map editor", 'x') { mapEditorScreen.game.setScreen(MainMenuScreen()); mapEditorScreen.dispose() }
|
addButton("Exit map editor", 'x') { mapEditorScreen.game.setScreen(MainMenuScreen()); mapEditorScreen.dispose() }
|
||||||
addButton("Change ruleset", 'c') { MapEditorRulesetPopup(mapEditorScreen).open(); close() }
|
addButton("Change ruleset", 'c') { MapEditorRulesetPopup(mapEditorScreen).open(); close() }
|
||||||
addCloseButton()
|
addCloseButton()
|
||||||
|
@ -100,7 +100,9 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||||||
rightSideButton.isVisible = true
|
rightSideButton.isVisible = true
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
rightSideButton.onClick {
|
rightSideButton.onClick {
|
||||||
game.setScreen(NewGameScreen(this, GameSetupInfo(gameInfo)))
|
val newGameSetupInfo = GameSetupInfo(gameInfo)
|
||||||
|
newGameSetupInfo.mapParameters.reseed()
|
||||||
|
game.setScreen(NewGameScreen(this, newGameSetupInfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
closeButton.setText("One more turn...!".tr())
|
closeButton.setText("One more turn...!".tr())
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package com.unciv.ui.worldscreen.mainmenu
|
package com.unciv.ui.worldscreen.mainmenu
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|
||||||
import com.unciv.Constants
|
|
||||||
import com.unciv.MainMenuScreen
|
import com.unciv.MainMenuScreen
|
||||||
import com.unciv.ui.civilopedia.CivilopediaScreen
|
import com.unciv.ui.civilopedia.CivilopediaScreen
|
||||||
import com.unciv.ui.newgamescreen.GameSetupInfo
|
import com.unciv.ui.newgamescreen.GameSetupInfo
|
||||||
@ -12,9 +8,6 @@ import com.unciv.ui.newgamescreen.NewGameScreen
|
|||||||
import com.unciv.ui.saves.LoadGameScreen
|
import com.unciv.ui.saves.LoadGameScreen
|
||||||
import com.unciv.ui.saves.SaveGameScreen
|
import com.unciv.ui.saves.SaveGameScreen
|
||||||
import com.unciv.ui.utils.Popup
|
import com.unciv.ui.utils.Popup
|
||||||
import com.unciv.ui.utils.addSeparator
|
|
||||||
import com.unciv.ui.utils.onClick
|
|
||||||
import com.unciv.ui.utils.toLabel
|
|
||||||
import com.unciv.ui.victoryscreen.VictoryScreen
|
import com.unciv.ui.victoryscreen.VictoryScreen
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
|
||||||
@ -27,7 +20,9 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
|||||||
addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
||||||
|
|
||||||
addButton("Start new game") {
|
addButton("Start new game") {
|
||||||
val newGameScreen = NewGameScreen(worldScreen, GameSetupInfo(worldScreen.gameInfo))
|
val newGameSetupInfo = GameSetupInfo(worldScreen.gameInfo)
|
||||||
|
newGameSetupInfo.mapParameters.reseed()
|
||||||
|
val newGameScreen = NewGameScreen(worldScreen, newGameSetupInfo)
|
||||||
worldScreen.game.setScreen(newGameScreen)
|
worldScreen.game.setScreen(newGameScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user