mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 01:13:53 +03:00
Add a tool to generate a random proletariat robot scenario given an RNG seed, for the forecasting group. #313
This commit is contained in:
parent
65e07d9cc7
commit
4367c03a7d
@ -69,6 +69,14 @@ in the meantime.
|
||||
There's no API yet to create trips. Instead, you can
|
||||
[import trips from your own data](https://dabreegster.github.io/abstreet/trafficsim/travel_demand.html#custom-import).
|
||||
|
||||
You can also generate different variations of one of the
|
||||
[demand models](https://dabreegster.github.io/abstreet/trafficsim/travel_demand.html#proletariat-robot)
|
||||
by specifying an RNG seed:
|
||||
|
||||
```
|
||||
cargo run --bin random_scenario -- --rng=123 --map=data/system/maps/montlake.bin > data/system/scenarios/montlake/home_to_work.json
|
||||
```
|
||||
|
||||
You can also dump Scenarios (the file that defines all of the people and trips)
|
||||
to JSON:
|
||||
|
||||
|
16
importer/src/bin/random_scenario.rs
Normal file
16
importer/src/bin/random_scenario.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use abstutil::{CmdArgs, Timer};
|
||||
use map_model::Map;
|
||||
use rand::SeedableRng;
|
||||
use rand_xorshift::XorShiftRng;
|
||||
use sim::ScenarioGenerator;
|
||||
|
||||
fn main() {
|
||||
let mut args = CmdArgs::new();
|
||||
let seed: u8 = args.required("--rng").parse().unwrap();
|
||||
let mut rng = XorShiftRng::from_seed([seed; 16]);
|
||||
let map = Map::new(args.required("--map"), &mut Timer::throwaway());
|
||||
args.done();
|
||||
|
||||
let scenario = ScenarioGenerator::proletariat_robot(&map, &mut rng, &mut Timer::throwaway());
|
||||
println!("{}", abstutil::to_json(&scenario));
|
||||
}
|
Loading…
Reference in New Issue
Block a user