Add factory generator
This commit is contained in:
parent
295490858b
commit
6fbff67e61
14 changed files with 308 additions and 15 deletions
39
factorio-blueprint-generator/src/bin/generate_factory.rs
Normal file
39
factorio-blueprint-generator/src/bin/generate_factory.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use clap::Parser;
|
||||
use factorio_blueprint::{BlueprintString, encode};
|
||||
use factorio_blueprint_generator::factory::generate_factory;
|
||||
use factorio_core::prelude::*;
|
||||
use factorio_layout::valid_layout::ValidLayout;
|
||||
use factorio_pathfinding::belt_finding::ConflictAvoidance;
|
||||
use rand::{SeedableRng, rngs::SmallRng};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
#[arg(default_value_t = 0)]
|
||||
seed: u64,
|
||||
#[arg(short, long)]
|
||||
json: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let l = ValidLayout {
|
||||
max_tries: 10,
|
||||
retries: 10,
|
||||
start_size: Position::new(100, 100),
|
||||
growth: Position::new(5, 5),
|
||||
};
|
||||
let p = ConflictAvoidance {
|
||||
timeout: Some(std::time::Duration::from_millis(20)),
|
||||
};
|
||||
|
||||
let mut rng = SmallRng::seed_from_u64(args.seed);
|
||||
|
||||
let b = BlueprintString::Blueprint(generate_factory(&l, &p, &mut rng).to_blueprint());
|
||||
|
||||
if args.json {
|
||||
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||
}
|
||||
|
||||
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue