Add tracing support for layouting
This commit is contained in:
parent
b53d1e87bc
commit
cebdee4ec7
8 changed files with 254 additions and 53 deletions
|
|
@ -13,3 +13,5 @@ serde_json = "1.0.135"
|
|||
serde_yaml = "0.9.34"
|
||||
clap = { version = "4.5.26", features = ["derive"] }
|
||||
rand = { version = "0.9.0", features = ["small_rng"] }
|
||||
tracing = "0.1.41"
|
||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use factorio_core::prelude::*;
|
|||
use factorio_layout::{genetic_algorithm_v1::GeneticAlgorithm, valid_layout::ValidLayout};
|
||||
use factorio_pathfinding::belt_finding::ConflictAvoidance;
|
||||
use rand::{SeedableRng, rngs::SmallRng};
|
||||
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
|
|
@ -21,6 +22,11 @@ struct Args {
|
|||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
tracing_subscriber::fmt::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
|
||||
.init();
|
||||
|
||||
let text = std::fs::File::open(&args.path).unwrap();
|
||||
let factory_graph: FactoryGraph = serde_yaml::from_reader(text).unwrap();
|
||||
|
||||
|
|
@ -35,10 +41,10 @@ fn main() {
|
|||
|
||||
let l = GeneticAlgorithm {
|
||||
mutation_retries: 20,
|
||||
population_size: 5,
|
||||
population_keep: 8,
|
||||
population_new: 2,
|
||||
generations: 5,
|
||||
population_size: 20,
|
||||
population_keep: 4,
|
||||
population_new: 4,
|
||||
generations: 40,
|
||||
valid_layout: l,
|
||||
};
|
||||
let p = ConflictAvoidance {
|
||||
|
|
@ -55,5 +61,5 @@ fn main() {
|
|||
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||
}
|
||||
|
||||
println!("{}", encode(&serde_json::to_string(&b).unwrap()));
|
||||
let _ = std::fs::write("out.bp", encode(&serde_json::to_string(&b).unwrap()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue