diff --git a/.gitignore b/.gitignore index 661c5d3..458a18e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ flamegraph.svg perf.data* out proptest-regressions -out.* diff --git a/Cargo.lock b/Cargo.lock index 91b1153..563efef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,9 +90,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.96" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arbitrary" @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.7" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" +checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" [[package]] name = "bumpalo" @@ -270,12 +270,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" -[[package]] -name = "bytes" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" - [[package]] name = "cast" version = "0.3.0" @@ -284,9 +278,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.14" +version = "1.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" +checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" dependencies = [ "jobserver", "libc", @@ -338,9 +332,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.30" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" +checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" dependencies = [ "clap_builder", "clap_derive", @@ -348,9 +342,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.30" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" +checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" dependencies = [ "anstream", "anstyle", @@ -507,9 +501,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "equivalent" -version = "1.0.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" @@ -563,7 +557,6 @@ dependencies = [ "serde_json", "serde_yaml", "tracing", - "tracing-perfetto", "tracing-subscriber", ] @@ -591,7 +584,6 @@ dependencies = [ "image", "miette", "rand 0.9.0", - "rayon", "serde", "serde_json", "serde_yaml", @@ -635,12 +627,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - [[package]] name = "flate2" version = "1.0.35" @@ -831,15 +817,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.14" @@ -984,20 +961,14 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", "simd-adler32", ] -[[package]] -name = "multimap" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" - [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -1091,9 +1062,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -1119,16 +1090,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset", - "indexmap", -] - [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1260,58 +1221,6 @@ dependencies = [ "syn", ] -[[package]] -name = "prost" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" -dependencies = [ - "heck", - "itertools 0.14.0", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" -dependencies = [ - "anyhow", - "itertools 0.14.0", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" -dependencies = [ - "prost", -] - [[package]] name = "qoi" version = "0.4.1" @@ -1360,8 +1269,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.1", - "zerocopy 0.8.20", + "rand_core 0.9.0", + "zerocopy 0.8.17", ] [[package]] @@ -1381,7 +1290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.1", + "rand_core 0.9.0", ] [[package]] @@ -1395,12 +1304,12 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3" +checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.20", + "zerocopy 0.8.17", ] [[package]] @@ -1586,18 +1495,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.218" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -1606,9 +1515,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -1670,9 +1579,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.14.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "strsim" @@ -1733,9 +1642,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.17.1" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" dependencies = [ "cfg-if", "fastrand", @@ -1848,9 +1757,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" dependencies = [ "indexmap", "serde", @@ -1902,17 +1811,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-perfetto" -version = "0.1.0" -source = "git+https://git.he-li.dev/hal8174/tracing-perfetto.git#349c0e688c5701dd89f95819e05b1552615d747b" -dependencies = [ - "prost", - "prost-build", - "prost-types", - "tracing", -] - [[package]] name = "tracing-subscriber" version = "0.3.19" @@ -1939,9 +1837,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.17" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-linebreak" @@ -2204,9 +2102,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" +checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" dependencies = [ "memchr", ] @@ -2232,11 +2130,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.20" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c" +checksum = "aa91407dacce3a68c56de03abe2760159582b846c6a4acd2f456618087f12713" dependencies = [ - "zerocopy-derive 0.8.20", + "zerocopy-derive 0.8.17", ] [[package]] @@ -2252,9 +2150,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.20" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700" +checksum = "06718a168365cad3d5ff0bb133aad346959a2074bd4a85c121255a11304a8626" dependencies = [ "proc-macro2", "quote", diff --git a/factorio-blueprint-generator/Cargo.toml b/factorio-blueprint-generator/Cargo.toml index 5a25722..ec65a98 100644 --- a/factorio-blueprint-generator/Cargo.toml +++ b/factorio-blueprint-generator/Cargo.toml @@ -15,4 +15,3 @@ 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"] } -tracing-perfetto = { git = "https://git.he-li.dev/hal8174/tracing-perfetto.git" } diff --git a/factorio-blueprint-generator/src/bin/assembly.rs b/factorio-blueprint-generator/src/bin/assembly.rs index 29ffb55..6cc4553 100644 --- a/factorio-blueprint-generator/src/bin/assembly.rs +++ b/factorio-blueprint-generator/src/bin/assembly.rs @@ -1,6 +1,6 @@ use clap::Parser; use factorio_blueprint::{BlueprintString, encode}; -use factorio_blueprint_generator::assembly::assembly_line_2_input; +use factorio_blueprint_generator::assembly::{assembly_line, assembly_line_2_input}; use factorio_core::beltoptions::Beltspeed; #[derive(Parser)] diff --git a/factorio-blueprint-generator/src/bin/generate_factory.rs b/factorio-blueprint-generator/src/bin/generate_factory.rs index 587952a..38f0a64 100644 --- a/factorio-blueprint-generator/src/bin/generate_factory.rs +++ b/factorio-blueprint-generator/src/bin/generate_factory.rs @@ -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,11 +22,10 @@ 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(); - tracing_perfetto::install_perfetto_subscriber(); + 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(); @@ -33,18 +33,18 @@ fn main() { // dbg!(&factory_graph); let l = ValidLayout { - size_increases: 32, + max_tries: 4, retries: 4, - start_size: Position::new(64, 64), - growth: Position::new(8, 8), + start_size: Position::new(256, 256), + growth: Position::new(16, 16), }; let l = GeneticAlgorithm { mutation_retries: 20, - population_size: 4, - population_keep: 1, - population_new: 1, - generations: 5, + population_size: 20, + population_keep: 4, + population_new: 4, + generations: 40, valid_layout: l, }; let p = ConflictAvoidance { diff --git a/factorio-layout/src/genetic_algorithm_v1.rs b/factorio-layout/src/genetic_algorithm_v1.rs index 292f11a..1077546 100644 --- a/factorio-layout/src/genetic_algorithm_v1.rs +++ b/factorio-layout/src/genetic_algorithm_v1.rs @@ -1,5 +1,5 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; -use tracing::{Level, field::Empty, span, trace, warn}; +use tracing::{Level, field::Empty, info, span, trace, warn}; use crate::{ LayoutResult, Layouter, diff --git a/factorio-layout/src/layout.rs b/factorio-layout/src/layout.rs index 937e4e8..9ea4625 100644 --- a/factorio-layout/src/layout.rs +++ b/factorio-layout/src/layout.rs @@ -6,7 +6,7 @@ use factorio_core::{ use factorio_pathfinding::belt_finding::{self, conflict_avoidance::ConflictAvoidance}; use rand::{ Rng, - seq::IndexedRandom, + seq::{IndexedRandom, SliceRandom}, }; use serde::{Deserialize, Serialize}; use std::{sync::atomic::AtomicU32, time::Instant}; diff --git a/factorio-layout/src/misc.rs b/factorio-layout/src/misc.rs index 63c4ff4..ca7787a 100644 --- a/factorio-layout/src/misc.rs +++ b/factorio-layout/src/misc.rs @@ -3,7 +3,7 @@ use factorio_core::prelude::*; use factorio_pathfinding::{Connection, examples::HashMapMap}; use rand::{ Rng, - seq::IndexedRandom, + seq::{IndexedRandom, SliceRandom}, }; pub fn initally_set_blocks( diff --git a/factorio-pathfinding/Cargo.toml b/factorio-pathfinding/Cargo.toml index 7d0af0c..278445c 100644 --- a/factorio-pathfinding/Cargo.toml +++ b/factorio-pathfinding/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "factorio-pathfinding" version = "0.1.0" -edition = "2024" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/factorio-pathfinding/src/belt_finding/mod.rs b/factorio-pathfinding/src/belt_finding/mod.rs index d486be1..9ed024a 100644 --- a/factorio-pathfinding/src/belt_finding/mod.rs +++ b/factorio-pathfinding/src/belt_finding/mod.rs @@ -2,11 +2,12 @@ use crate::examples::HashMapMap; use crate::graph::wheighted_graph::shortest_path::a_star; use crate::graph::wheighted_graph::WheightedGraph; use crate::misc::Map; +use crate::priority_queue::binary_heap::BinaryHeap; use crate::priority_queue::binary_heap::FastBinaryHeap; use crate::Connection; use crate::Map as _; use crate::SinglePathInput; -use crate::SinglePathfinder; +use crate::{graph::wheighted_graph::shortest_path::dijkstra, SinglePathfinder}; use factorio_core::{prelude::*, visualize::Visualize}; use serde::{Deserialize, Serialize}; use tracing::span; diff --git a/factorio-pathfinding/src/graph/wheighted_graph/shortest_path.rs b/factorio-pathfinding/src/graph/wheighted_graph/shortest_path.rs index c5cf266..b232eeb 100644 --- a/factorio-pathfinding/src/graph/wheighted_graph/shortest_path.rs +++ b/factorio-pathfinding/src/graph/wheighted_graph/shortest_path.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, fmt::Debug, hash::Hash, hash::Hasher}; -use tracing::{field::Empty, trace_span}; +use tracing::{field::Empty, trace, trace_span}; use crate::priority_queue::PriorityQueue; diff --git a/factorio-pathfinding/src/priority_queue/mod.rs b/factorio-pathfinding/src/priority_queue/mod.rs index 5e02acf..f881750 100644 --- a/factorio-pathfinding/src/priority_queue/mod.rs +++ b/factorio-pathfinding/src/priority_queue/mod.rs @@ -1,3 +1,4 @@ +use std::fmt::Debug; pub mod binary_heap; pub mod fibonacci_heap;