diff --git a/docs/dev.md b/docs/dev.md index 1918c92ec4..5504d6a1ab 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -42,9 +42,6 @@ One-time setup: experience, so they're hidden for now. - `cargo run -- --tutorial=12` starts somewhere in the tutorial - Adding `--edits='name of edits'` starts with edits applied to the map. -- If you're testing anything related to prebaked results (used for comparisons - against a baseline in challenge mode), make sure to set `--rng_seed=42`. The - `--dev` flag does by default. - All code is automatically formatted using https://github.com/rust-lang/rustfmt; please run `cargo +nightly fmt` before sending a PR. (You have to install the nightly toolchain just for fmt) diff --git a/game/src/abtest/setup.rs b/game/src/abtest/setup.rs index d75a917b15..b1b54632b6 100644 --- a/game/src/abtest/setup.rs +++ b/game/src/abtest/setup.rs @@ -111,9 +111,6 @@ fn launch_test(test: &ABTest, app: &mut App, ctx: &mut EventCtx) -> ABTestMode { { timer.start("load primary"); - if app.primary.current_flags.sim_flags.rng_seed.is_none() { - app.primary.current_flags.sim_flags.rng_seed = Some(42); - } app.primary.current_flags.sim_flags.opts.run_name = format!("{} with {}", test.test_name, test.edits1_name); app.primary.current_flags.sim_flags.opts.savestate_every = None; diff --git a/game/src/main.rs b/game/src/main.rs index adc2feae3c..d5fcd0b0c6 100644 --- a/game/src/main.rs +++ b/game/src/main.rs @@ -36,16 +36,7 @@ fn main() { num_agents: args.optional_parse("--num_agents", |s| s.parse()), }; let mut opts = options::Options::default(); - if args.enabled("--dev") { - opts.dev = true; - flags.sim_flags.rng_seed = Some(42); - } - - // No random in wasm - #[cfg(target_arch = "wasm32")] - { - flags.sim_flags.rng_seed = Some(42); - } + opts.dev = args.enabled("--dev"); if let Some(x) = args.optional("--color_scheme") { let mut ok = false; diff --git a/game/src/sandbox/gameplay/tutorial.rs b/game/src/sandbox/gameplay/tutorial.rs index a70558ace1..cbacd4a0be 100644 --- a/game/src/sandbox/gameplay/tutorial.rs +++ b/game/src/sandbox/gameplay/tutorial.rs @@ -790,10 +790,7 @@ impl TutorialState { // TODO Should some of this always happen? app.primary.clear_sim(); if let Some(ref cb) = self.stage().spawn { - let old = app.primary.current_flags.sim_flags.rng_seed; - app.primary.current_flags.sim_flags.rng_seed = Some(42); (cb)(app); - app.primary.current_flags.sim_flags.rng_seed = old; app.primary .sim .normal_step(&app.primary.map, Duration::seconds(0.1)); diff --git a/headless/src/main.rs b/headless/src/main.rs index eb3ebaec0d..1cb233b7c5 100644 --- a/headless/src/main.rs +++ b/headless/src/main.rs @@ -15,7 +15,7 @@ fn main() { args.done(); let mut sim_flags = SimFlags::synthetic_test("montlake", "pandemic"); - sim_flags.opts.enable_pandemic_model = Some(XorShiftRng::from_seed([42; 16])); + sim_flags.opts.enable_pandemic_model = Some(XorShiftRng::from_seed([sim_flags.rng_seed; 16])); let mut timer = Timer::new("setup headless"); let (map, mut sim, mut rng) = sim_flags.load(&mut timer); diff --git a/release/play_abstreet.bat b/release/play_abstreet.bat index 894494fe58..7dfb6a6a53 100755 --- a/release/play_abstreet.bat +++ b/release/play_abstreet.bat @@ -1,3 +1,3 @@ cd game set RUST_BACKTRACE=1 -game.exe --rng_seed=42 1> ..\\output.txt 2>&1 +game.exe 1> ..\\output.txt 2>&1 diff --git a/release/play_abstreet.sh b/release/play_abstreet.sh index eab7694571..92409908dc 100755 --- a/release/play_abstreet.sh +++ b/release/play_abstreet.sh @@ -1,4 +1,4 @@ #!/bin/bash cd game -RUST_BACKTRACE=1 ./game --rng_seed=42 +RUST_BACKTRACE=1 ./game diff --git a/sim/src/make/load.rs b/sim/src/make/load.rs index 2a584ff85c..5ea3ab8ad6 100644 --- a/sim/src/make/load.rs +++ b/sim/src/make/load.rs @@ -5,17 +5,21 @@ use map_model::{Map, MapEdits}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; +const RNG_SEED: u8 = 42; + #[derive(Clone)] pub struct SimFlags { pub load: String, pub use_map_fixes: bool, - pub rng_seed: Option, + pub rng_seed: u8, pub opts: SimOptions, } impl SimFlags { pub fn from_args(args: &mut CmdArgs) -> SimFlags { - let rng_seed = args.optional_parse("--rng_seed", |s| s.parse()); + let rng_seed = args + .optional_parse("--rng_seed", |s| s.parse()) + .unwrap_or(RNG_SEED); SimFlags { load: args @@ -33,11 +37,7 @@ impl SimFlags { recalc_lanechanging: !args.enabled("--dont_recalc_lc"), break_turn_conflict_cycles: args.enabled("--break_turn_conflict_cycles"), enable_pandemic_model: if args.enabled("--pandemic") { - if let Some(seed) = rng_seed { - Some(XorShiftRng::from_seed([seed; 16])) - } else { - Some(XorShiftRng::from_entropy()) - } + Some(XorShiftRng::from_seed([rng_seed; 16])) } else { None }, @@ -63,17 +63,13 @@ impl SimFlags { SimFlags { load: abstutil::path_map(map), use_map_fixes: true, - rng_seed: Some(42), + rng_seed: RNG_SEED, opts: SimOptions::new(run_name), } } pub fn make_rng(&self) -> XorShiftRng { - if let Some(seed) = self.rng_seed { - XorShiftRng::from_seed([seed; 16]) - } else { - XorShiftRng::from_entropy() - } + XorShiftRng::from_seed([self.rng_seed; 16]) } // Convenience method to setup everything.