From dfdeae5638a9ab177cef52c00799beff0e4806b3 Mon Sep 17 00:00:00 2001 From: hal8174 Date: Sat, 18 Jan 2025 17:30:55 +0100 Subject: [PATCH] Refactor into different crates --- Cargo.lock | 592 ++++++++---------- Cargo.toml | 33 +- factorio-blueprint-generator/Cargo.toml | 11 + .../src}/balancer.rs | 8 +- .../src/bin/balancer_blueprint.rs | 10 + .../src}/bin/station.rs | 18 +- .../src}/bin/train_blueprint.rs | 10 +- factorio-blueprint-generator/src/lib.rs | 3 + .../src}/station.rs | 46 +- .../src}/train.rs | 2 +- factorio-blueprint/Cargo.toml | 13 + .../blueprints}/3train.bp | 0 .../blueprints}/3train.json | 0 .../blueprints}/4train.bp | 0 .../blueprints}/4train.json | 0 .../blueprints}/balancer.bp | 0 .../blueprints}/book | 0 .../blueprints}/bp | 0 factorio-blueprint/blueprints/chests.bp | 1 + .../blueprints}/electric_pole_connection.bp | 0 .../blueprints}/mining | 0 .../blueprints}/nested | 0 .../blueprints}/orientation.bp | 0 .../blueprints}/orientation.json | 0 .../blueprints}/own_train.json | 0 .../blueprints}/rail | 0 .../blueprints}/simple | 0 .../blueprints}/simple_splitter.bp | 0 .../blueprints}/single_belt.bp | 0 .../blueprints}/small_train.bp | 0 .../blueprints}/small_train.json | 0 .../blueprints}/tiles | 0 .../blueprints/train-signals-param.bp | 1 + .../blueprints/train-signals.bp | 1 + .../blueprints}/train2.0.bp | 0 .../blueprints}/train2.0.json | 0 .../blueprints}/walls | 0 factorio-blueprint/src/belt.rs | 59 ++ .../src}/bin/decode_blueprint.rs | 3 +- .../mod.rs => factorio-blueprint/src/lib.rs | 10 +- .../belt.rs => factorio-blueprint/src/misc.rs | 56 -- .../src}/structs.rs | 0 factorio-core/Cargo.toml | 16 + {src/common => factorio-core/src}/aabb.rs | 0 {src/common => factorio-core/src}/block.rs | 0 {src/common => factorio-core/src}/color.rs | 0 .../common => factorio-core/src}/direction.rs | 0 {src => factorio-core/src}/lib.rs | 17 +- .../src/pathfield.rs | 0 {src/common => factorio-core/src}/position.rs | 0 .../src}/transformation.rs | 0 .../src}/visualize/image.rs | 2 +- .../src}/visualize/mod.rs | 0 .../src}/visualize/print.rs | 0 factorio-pathfinding/Cargo.toml | 31 + .../benches}/bruteforce.rs | 2 +- .../examples}/brute_force.rs | 9 +- .../examples}/decode_blueprint.rs | 6 +- .../examples}/priority_queue_test.rs | 2 +- layout.yml => factorio-pathfinding/layout.yml | 0 .../layout2.yml | 0 .../layout3.yml | 0 .../src}/belt_finding/brute_force.rs | 30 +- .../src}/belt_finding/conflict_avoidance.rs | 32 +- .../src}/belt_finding/mod.rs | 27 +- .../src}/bin/beltfinding.rs | 18 +- .../src}/bin/create_beltfinding_image.rs | 7 +- factorio-pathfinding/src/bin/layout.rs | 98 +++ .../src}/graph/mod.rs | 0 .../graph/wheighted_graph/adjacency_list.rs | 0 .../src}/graph/wheighted_graph/mod.rs | 0 .../graph/wheighted_graph/shortest_path.rs | 0 .../src}/layout/mod.rs | 8 +- factorio-pathfinding/src/lib.rs | 5 + .../src}/misc/arena.rs | 0 {src => factorio-pathfinding/src}/misc/map.rs | 0 {src => factorio-pathfinding/src}/misc/mod.rs | 0 .../src}/priority_queue/fibonacci_heap.rs | 0 .../src}/priority_queue/mod.rs | 0 src/bin/balancer_blueprint.rs | 12 - src/bin/layout.rs | 65 -- src/common/mod.rs | 7 - 82 files changed, 624 insertions(+), 647 deletions(-) create mode 100644 factorio-blueprint-generator/Cargo.toml rename {src/blueprint => factorio-blueprint-generator/src}/balancer.rs (94%) create mode 100644 factorio-blueprint-generator/src/bin/balancer_blueprint.rs rename {src => factorio-blueprint-generator/src}/bin/station.rs (88%) rename {src => factorio-blueprint-generator/src}/bin/train_blueprint.rs (79%) create mode 100644 factorio-blueprint-generator/src/lib.rs rename {src/blueprint => factorio-blueprint-generator/src}/station.rs (95%) rename {src/blueprint => factorio-blueprint-generator/src}/train.rs (99%) create mode 100644 factorio-blueprint/Cargo.toml rename {blueprints => factorio-blueprint/blueprints}/3train.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/3train.json (100%) rename {blueprints => factorio-blueprint/blueprints}/4train.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/4train.json (100%) rename {blueprints => factorio-blueprint/blueprints}/balancer.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/book (100%) rename {blueprints => factorio-blueprint/blueprints}/bp (100%) create mode 100644 factorio-blueprint/blueprints/chests.bp rename {blueprints => factorio-blueprint/blueprints}/electric_pole_connection.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/mining (100%) rename {blueprints => factorio-blueprint/blueprints}/nested (100%) rename {blueprints => factorio-blueprint/blueprints}/orientation.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/orientation.json (100%) rename {blueprints => factorio-blueprint/blueprints}/own_train.json (100%) rename {blueprints => factorio-blueprint/blueprints}/rail (100%) rename {blueprints => factorio-blueprint/blueprints}/simple (100%) rename {blueprints => factorio-blueprint/blueprints}/simple_splitter.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/single_belt.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/small_train.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/small_train.json (100%) rename {blueprints => factorio-blueprint/blueprints}/tiles (100%) create mode 100644 factorio-blueprint/blueprints/train-signals-param.bp create mode 100644 factorio-blueprint/blueprints/train-signals.bp rename {blueprints => factorio-blueprint/blueprints}/train2.0.bp (100%) rename {blueprints => factorio-blueprint/blueprints}/train2.0.json (100%) rename {blueprints => factorio-blueprint/blueprints}/walls (100%) create mode 100644 factorio-blueprint/src/belt.rs rename {src => factorio-blueprint/src}/bin/decode_blueprint.rs (88%) rename src/blueprint/mod.rs => factorio-blueprint/src/lib.rs (93%) rename src/blueprint/belt.rs => factorio-blueprint/src/misc.rs (52%) rename {src/blueprint => factorio-blueprint/src}/structs.rs (100%) create mode 100644 factorio-core/Cargo.toml rename {src/common => factorio-core/src}/aabb.rs (100%) rename {src/common => factorio-core/src}/block.rs (100%) rename {src/common => factorio-core/src}/color.rs (100%) rename {src/common => factorio-core/src}/direction.rs (100%) rename {src => factorio-core/src}/lib.rs (55%) rename src/belt_finding/common.rs => factorio-core/src/pathfield.rs (100%) rename {src/common => factorio-core/src}/position.rs (100%) rename {src/common => factorio-core/src}/transformation.rs (100%) rename {src/common => factorio-core/src}/visualize/image.rs (99%) rename {src/common => factorio-core/src}/visualize/mod.rs (100%) rename {src/common => factorio-core/src}/visualize/print.rs (100%) create mode 100644 factorio-pathfinding/Cargo.toml rename {benches => factorio-pathfinding/benches}/bruteforce.rs (88%) rename {examples => factorio-pathfinding/examples}/brute_force.rs (94%) rename {examples => factorio-pathfinding/examples}/decode_blueprint.rs (66%) rename {examples => factorio-pathfinding/examples}/priority_queue_test.rs (91%) rename layout.yml => factorio-pathfinding/layout.yml (100%) rename layout2.yml => factorio-pathfinding/layout2.yml (100%) rename layout3.yml => factorio-pathfinding/layout3.yml (100%) rename {src => factorio-pathfinding/src}/belt_finding/brute_force.rs (96%) rename {src => factorio-pathfinding/src}/belt_finding/conflict_avoidance.rs (95%) rename {src => factorio-pathfinding/src}/belt_finding/mod.rs (95%) rename {src => factorio-pathfinding/src}/bin/beltfinding.rs (84%) rename {src => factorio-pathfinding/src}/bin/create_beltfinding_image.rs (77%) create mode 100644 factorio-pathfinding/src/bin/layout.rs rename {src => factorio-pathfinding/src}/graph/mod.rs (100%) rename {src => factorio-pathfinding/src}/graph/wheighted_graph/adjacency_list.rs (100%) rename {src => factorio-pathfinding/src}/graph/wheighted_graph/mod.rs (100%) rename {src => factorio-pathfinding/src}/graph/wheighted_graph/shortest_path.rs (100%) rename {src => factorio-pathfinding/src}/layout/mod.rs (98%) create mode 100644 factorio-pathfinding/src/lib.rs rename {src => factorio-pathfinding/src}/misc/arena.rs (100%) rename {src => factorio-pathfinding/src}/misc/map.rs (100%) rename {src => factorio-pathfinding/src}/misc/mod.rs (100%) rename {src => factorio-pathfinding/src}/priority_queue/fibonacci_heap.rs (100%) rename {src => factorio-pathfinding/src}/priority_queue/mod.rs (100%) delete mode 100644 src/bin/balancer_blueprint.rs delete mode 100644 src/bin/layout.rs delete mode 100644 src/common/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 454ce47..ad9d941 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,19 +4,13 @@ version = 4 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -40,9 +34,9 @@ checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -55,49 +49,50 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "once_cell", + "windows-sys", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" [[package]] name = "arg_enum_proc_macro" @@ -129,9 +124,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "av1-grain" @@ -149,9 +144,9 @@ dependencies = [ [[package]] name = "avif-serialize" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62" dependencies = [ "arrayvec", ] @@ -165,10 +160,10 @@ dependencies = [ "addr2line", "cfg-if", "libc", - "miniz_oxide 0.8.0", + "miniz_oxide", "object", "rustc-demangle", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -187,19 +182,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] -name = "bit-set" -version = "0.5.3" +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.6.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bit_field" @@ -215,21 +216,21 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bitstream-io" -version = "2.5.3" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b81e1519b0d82120d2fd469d5bfb2919a9361c48b02d82d04befc1cdd2002452" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" [[package]] name = "bon" -version = "3.0.2" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a636f83af97c6946f3f5cf5c268ec02375bf5efd371110292dfd57961f57a509" +checksum = "fe7acc34ff59877422326db7d6f2d845a582b16396b6b08194942bf34c6528ab" dependencies = [ "bon-macros", "rustversion", @@ -237,9 +238,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.0.2" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7eaf1bfaa5b8d512abfd36d0c432591fef139d3de9ee54f1f839ea109d70d33" +checksum = "4159dd617a7fbc9be6a692fe69dc2954f8e6bb6bb5e4d7578467441390d77fd0" dependencies = [ "darling", "ident_case", @@ -252,9 +253,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236e6289eda5a812bc6b53c3b024039382a2895fbbeef2d748b2931546d392c4" +checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" [[package]] name = "bumpalo" @@ -264,9 +265,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -288,9 +289,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.21" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ "jobserver", "libc", @@ -326,9 +327,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" dependencies = [ "clap_builder", "clap_derive", @@ -336,9 +337,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ "anstream", "anstyle", @@ -348,9 +349,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", @@ -360,9 +361,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "color_quant" @@ -372,9 +373,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "crc32fast" @@ -423,9 +424,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -442,9 +443,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -454,9 +455,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -522,38 +523,76 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "exr" -version = "1.72.0" +version = "1.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" dependencies = [ "bit_field", - "flume", "half 2.4.1", "lebe", - "miniz_oxide 0.7.4", + "miniz_oxide", "rayon-core", "smallvec", "zune-inflate", ] [[package]] -name = "factorio_blueprint" +name = "factorio-blueprint" version = "0.1.0" dependencies = [ - "base64", + "base64 0.22.1", "bon", - "clap 4.5.17", + "clap 4.5.26", + "factorio-core", + "flate2", + "serde", + "serde_json", +] + +[[package]] +name = "factorio-blueprint-generator" +version = "0.1.0" +dependencies = [ + "clap 4.5.26", + "factorio-blueprint", + "factorio-core", + "factorio-pathfinding", + "serde_json", +] + +[[package]] +name = "factorio-core" +version = "0.1.0" +dependencies = [ "criterion", + "image", + "proptest", + "proptest-derive", + "rand", + "serde", + "termcolor", +] + +[[package]] +name = "factorio-pathfinding" +version = "0.1.0" +dependencies = [ + "base64 0.21.7", + "bon", + "clap 4.5.26", + "criterion", + "factorio-blueprint", + "factorio-core", "flate2", "image", "miette", @@ -568,36 +607,27 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fdeflate" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" dependencies = [ "simd-adler32", ] [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", -] - -[[package]] -name = "flume" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" -dependencies = [ - "spin", + "miniz_oxide", ] [[package]] @@ -629,9 +659,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "half" @@ -651,9 +681,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -678,9 +708,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "image" -version = "0.25.2" +version = "0.25.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10" +checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" dependencies = [ "bytemuck", "byteorder-lite", @@ -701,9 +731,9 @@ dependencies = [ [[package]] name = "image-webp" -version = "0.1.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79afb8cbee2ef20f59ccd477a218c12a93943d075b492015ecb1bb81f8ee904" +checksum = "b77d01e822461baa8409e156015a1d91735549f0f2c17691bd2d996bef238f7f" dependencies = [ "byteorder-lite", "quick-error 2.0.1", @@ -711,15 +741,15 @@ dependencies = [ [[package]] name = "imgref" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" +checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408" [[package]] name = "indexmap" -version = "2.5.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -768,9 +798,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -789,10 +819,11 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -810,48 +841,31 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libfuzzer-sys" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +checksum = "9b9569d2f74e257076d8c6bfa73fb505b46b851e51ddaecc825944aa3bed17fa" dependencies = [ "arbitrary", "cc", - "once_cell", ] -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "loop9" @@ -869,6 +883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" dependencies = [ "cfg-if", + "rayon", ] [[package]] @@ -879,9 +894,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miette" -version = "7.2.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +checksum = "317f146e2eb7021892722af37cf1b971f0a70c8406f487e24952667616192c64" dependencies = [ "backtrace", "backtrace-ext", @@ -899,9 +914,9 @@ dependencies = [ [[package]] name = "miette-derive" -version = "7.2.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", @@ -916,21 +931,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", - "simd-adler32", -] - -[[package]] -name = "miniz_oxide" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -1003,23 +1009,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] name = "object" -version = "0.36.4" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -1041,9 +1046,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plotters" @@ -1075,15 +1080,15 @@ dependencies = [ [[package]] name = "png" -version = "0.17.13" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.4", + "miniz_oxide", ] [[package]] @@ -1097,9 +1102,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", "syn", @@ -1107,27 +1112,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" dependencies = [ "profiling-procmacros", ] [[package]] name = "profiling-procmacros" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" +checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" dependencies = [ "quote", "syn", @@ -1135,13 +1140,13 @@ dependencies = [ [[package]] name = "proptest" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.6.0", + "bitflags 2.8.0", "lazy_static", "num-traits", "rand", @@ -1155,9 +1160,9 @@ dependencies = [ [[package]] name = "proptest-derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" +checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", @@ -1187,9 +1192,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1270,15 +1275,16 @@ dependencies = [ [[package]] name = "ravif" -version = "0.11.10" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f0bfd976333248de2078d350bfdf182ff96e168a24d23d2436cef320dd4bdd" +checksum = "2413fd96bd0ea5cdeeb37eaf446a22e6ed7b981d792828721e74ded1980a45c6" dependencies = [ "avif-serialize", "imgref", "loop9", "quick-error 2.0.1", "rav1e", + "rayon", "rgb", ] @@ -1304,9 +1310,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -1316,9 +1322,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1327,18 +1333,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rgb" version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" -dependencies = [ - "bytemuck", -] [[package]] name = "rustc-demangle" @@ -1348,22 +1351,22 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rusty-fork" @@ -1392,17 +1395,11 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "serde" -version = "1.0.210" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -1419,9 +1416,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -1430,9 +1427,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -1442,9 +1439,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -1489,21 +1486,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "smawk" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "strsim" version = "0.11.1" @@ -1512,18 +1494,18 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "supports-color" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" dependencies = [ "is_ci", ] [[package]] name = "supports-hyperlinks" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" +checksum = "804f44ed3c63152de6a9f90acbea1a110441de43006ea51bcce8f436196a288b" [[package]] name = "supports-unicode" @@ -1533,9 +1515,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" -version = "2.0.89" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -1563,15 +1545,16 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -1585,12 +1568,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1608,25 +1591,24 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ - "smawk", "unicode-linebreak", "unicode-width", ] [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -1677,9 +1659,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -1696,9 +1678,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-linebreak" @@ -1768,24 +1750,24 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -1794,9 +1776,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1804,9 +1786,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -1817,15 +1799,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -1859,7 +1844,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -1868,46 +1853,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -1916,46 +1868,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1968,48 +1902,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2018,9 +1928,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] @@ -2063,9 +1973,9 @@ dependencies = [ [[package]] name = "zune-jpeg" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768" +checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" dependencies = [ "zune-core", ] diff --git a/Cargo.toml b/Cargo.toml index 30f3466..69f0f0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,31 +1,8 @@ -[package] -name = "factorio_blueprint" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[workspace] +members = [ "factorio-blueprint", "factorio-blueprint-generator", "factorio-core", + "factorio-pathfinding" +] +resolver = "2" [profile.release] debug = true - -[dev-dependencies] -criterion = "0.3" - -[[bench]] -name = "bruteforce" -harness = false - -[dependencies] -base64 = "0.21.5" -bon = "3.0.2" -clap = { version = "4.4.8", features = ["derive"] } -flate2 = "1.0.28" -image = "0.25.2" -miette = { version = "7.2.0", features = ["fancy"] } -proptest = "1.5.0" -proptest-derive = "0.5.0" -rand = { version = "0.8.5", features = ["small_rng"] } -serde = { version = "1.0.192", features = ["derive"] } -serde_json = "1.0.108" -serde_yaml = "0.9.34" -termcolor = "1.4.1" diff --git a/factorio-blueprint-generator/Cargo.toml b/factorio-blueprint-generator/Cargo.toml new file mode 100644 index 0000000..8ac54ed --- /dev/null +++ b/factorio-blueprint-generator/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "factorio-blueprint-generator" +version = "0.1.0" +edition = "2024" + +[dependencies] +factorio-pathfinding = { path = "../factorio-pathfinding" } +factorio-core = { path = "../factorio-core" } +factorio-blueprint = { path = "../factorio-blueprint" } +serde_json = "1.0.135" +clap = { version = "4.5.26", features = ["derive"] } diff --git a/src/blueprint/balancer.rs b/factorio-blueprint-generator/src/balancer.rs similarity index 94% rename from src/blueprint/balancer.rs rename to factorio-blueprint-generator/src/balancer.rs index 1b7098f..fa55fbf 100644 --- a/src/blueprint/balancer.rs +++ b/factorio-blueprint-generator/src/balancer.rs @@ -1,9 +1,7 @@ -use crate::{belt_finding::common::PathField, prelude::*}; - -use super::{ - belt::{convert_to_blueprint, Beltspeed}, - Blueprint, BlueprintEntity, BlueprintPosition, +use factorio_blueprint::{ + Blueprint, BlueprintEntity, BlueprintPosition, belt::convert_to_blueprint, misc::Beltspeed, }; +use factorio_core::{pathfield::PathField, prelude::*}; pub fn generate_4_lane_balancer() -> Blueprint { let mut e = vec![ diff --git a/factorio-blueprint-generator/src/bin/balancer_blueprint.rs b/factorio-blueprint-generator/src/bin/balancer_blueprint.rs new file mode 100644 index 0000000..e3d73ba --- /dev/null +++ b/factorio-blueprint-generator/src/bin/balancer_blueprint.rs @@ -0,0 +1,10 @@ +use factorio_blueprint::{BlueprintString, encode}; +use factorio_blueprint_generator::balancer::generate_4_lane_balancer; + +fn main() { + let b = BlueprintString::Blueprint(generate_4_lane_balancer()); + + println!("{}", serde_json::to_string_pretty(&b).unwrap()); + + println!("{}", encode(&serde_json::to_string(&b).unwrap())); +} diff --git a/src/bin/station.rs b/factorio-blueprint-generator/src/bin/station.rs similarity index 88% rename from src/bin/station.rs rename to factorio-blueprint-generator/src/bin/station.rs index eb044f2..0554adc 100644 --- a/src/bin/station.rs +++ b/factorio-blueprint-generator/src/bin/station.rs @@ -1,9 +1,9 @@ use clap::{Parser, Subcommand}; -use factorio_blueprint::blueprint::{ - belt::{Beltspeed, Belttype}, - station::{basic_unload_station, station_unload}, - BlueprintBook, BlueprintBookEntry, BlueprintString, +use factorio_blueprint::{ + BlueprintBook, BlueprintBookEntry, BlueprintString, encode, + misc::{Beltspeed, Belttype}, }; +use factorio_blueprint_generator::station::basic_unload_station; #[derive(Parser)] struct Args { @@ -104,10 +104,7 @@ fn main() { .build(), ); - println!( - "{}", - factorio_blueprint::blueprint::encode(&serde_json::to_string(&b).unwrap()) - ); + println!("{}", encode(&serde_json::to_string(&b).unwrap())); } Command::Single { locomotives, @@ -126,10 +123,7 @@ fn main() { // println!("{}", serde_json::to_string_pretty(&b).unwrap()); - println!( - "{}", - factorio_blueprint::blueprint::encode(&serde_json::to_string(&b).unwrap()) - ); + println!("{}", encode(&serde_json::to_string(&b).unwrap())); } } } diff --git a/src/bin/train_blueprint.rs b/factorio-blueprint-generator/src/bin/train_blueprint.rs similarity index 79% rename from src/bin/train_blueprint.rs rename to factorio-blueprint-generator/src/bin/train_blueprint.rs index e9e3504..1b117c0 100644 --- a/src/bin/train_blueprint.rs +++ b/factorio-blueprint-generator/src/bin/train_blueprint.rs @@ -1,6 +1,5 @@ -use factorio_blueprint::blueprint::{ - train::generate_train, BlueprintBook, BlueprintBookEntry, BlueprintString, -}; +use factorio_blueprint::{BlueprintBook, BlueprintBookEntry, BlueprintString, encode}; +use factorio_blueprint_generator::train::generate_train; fn main() { let layouts = [ @@ -38,8 +37,5 @@ fn main() { println!("{}", serde_json::to_string_pretty(&b).unwrap()); - println!( - "{}", - factorio_blueprint::blueprint::encode(&serde_json::to_string(&b).unwrap()) - ); + println!("{}", encode(&serde_json::to_string(&b).unwrap())); } diff --git a/factorio-blueprint-generator/src/lib.rs b/factorio-blueprint-generator/src/lib.rs new file mode 100644 index 0000000..1b0ddb2 --- /dev/null +++ b/factorio-blueprint-generator/src/lib.rs @@ -0,0 +1,3 @@ +pub mod balancer; +pub mod station; +pub mod train; diff --git a/src/blueprint/station.rs b/factorio-blueprint-generator/src/station.rs similarity index 95% rename from src/blueprint/station.rs rename to factorio-blueprint-generator/src/station.rs index 753cb96..6f10332 100644 --- a/src/blueprint/station.rs +++ b/factorio-blueprint-generator/src/station.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use super::{ - belt::{Beltspeed, Belttype}, +use factorio_blueprint::{ Blueprint, BlueprintEntity, BlueprintPosition, + misc::{Beltspeed, Belttype}, }; pub fn station_unload( @@ -177,12 +177,14 @@ pub fn station_unload( pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Vec, f64) { match beltspeed { Beltspeed::Normal => { - let mut e = vec![BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - 0, - BlueprintPosition::new(3.5, -1.5), - ) - .build()]; + let mut e = vec![ + BlueprintEntity::builder( + "fast-transport-belt".to_owned(), + 0, + BlueprintPosition::new(3.5, -1.5), + ) + .build(), + ]; if belttype.contains_left() { let offset = e.len() as u32; @@ -239,12 +241,14 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Vec { - let mut e = vec![BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - 0, - BlueprintPosition::new(3.5, -3.5), - ) - .build()]; + let mut e = vec![ + BlueprintEntity::builder( + "fast-transport-belt".to_owned(), + 0, + BlueprintPosition::new(3.5, -3.5), + ) + .build(), + ]; if belttype.contains_left() { let offset = e.len() as u32; @@ -369,12 +373,14 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Vec { - let mut e = vec![BlueprintEntity::builder( - "express-transport-belt".to_owned(), - 0, - BlueprintPosition::new(3.5, -3.5), - ) - .build()]; + let mut e = vec![ + BlueprintEntity::builder( + "express-transport-belt".to_owned(), + 0, + BlueprintPosition::new(3.5, -3.5), + ) + .build(), + ]; if belttype.contains_left() { let offset = e.len() as u32; diff --git a/src/blueprint/train.rs b/factorio-blueprint-generator/src/train.rs similarity index 99% rename from src/blueprint/train.rs rename to factorio-blueprint-generator/src/train.rs index 849a9de..7e471e9 100644 --- a/src/blueprint/train.rs +++ b/factorio-blueprint-generator/src/train.rs @@ -1,4 +1,4 @@ -use super::{ +use factorio_blueprint::{ Blueprint, BlueprintEntity, BlueprintInventoryLocation, BlueprintItemID, BlueprintItemRequest, BlueprintPosition, BlueprintStockConnection, }; diff --git a/factorio-blueprint/Cargo.toml b/factorio-blueprint/Cargo.toml new file mode 100644 index 0000000..9c906ed --- /dev/null +++ b/factorio-blueprint/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "factorio-blueprint" +version = "0.1.0" +edition = "2024" + +[dependencies] +factorio-core = { path = "../factorio-core" } +base64 = "0.22.1" +bon = "3.3.2" +clap = { version = "4.5.26", features = ["derive"] } +serde = "1.0.217" +serde_json = "1.0.135" +flate2 = "1.0.35" diff --git a/blueprints/3train.bp b/factorio-blueprint/blueprints/3train.bp similarity index 100% rename from blueprints/3train.bp rename to factorio-blueprint/blueprints/3train.bp diff --git a/blueprints/3train.json b/factorio-blueprint/blueprints/3train.json similarity index 100% rename from blueprints/3train.json rename to factorio-blueprint/blueprints/3train.json diff --git a/blueprints/4train.bp b/factorio-blueprint/blueprints/4train.bp similarity index 100% rename from blueprints/4train.bp rename to factorio-blueprint/blueprints/4train.bp diff --git a/blueprints/4train.json b/factorio-blueprint/blueprints/4train.json similarity index 100% rename from blueprints/4train.json rename to factorio-blueprint/blueprints/4train.json diff --git a/blueprints/balancer.bp b/factorio-blueprint/blueprints/balancer.bp similarity index 100% rename from blueprints/balancer.bp rename to factorio-blueprint/blueprints/balancer.bp diff --git a/blueprints/book b/factorio-blueprint/blueprints/book similarity index 100% rename from blueprints/book rename to factorio-blueprint/blueprints/book diff --git a/blueprints/bp b/factorio-blueprint/blueprints/bp similarity index 100% rename from blueprints/bp rename to factorio-blueprint/blueprints/bp diff --git a/factorio-blueprint/blueprints/chests.bp b/factorio-blueprint/blueprints/chests.bp new file mode 100644 index 0000000..dbd6711 --- /dev/null +++ b/factorio-blueprint/blueprints/chests.bp @@ -0,0 +1 @@ +0eNqVkN0OgjAMRt+l14XwVw28ijFmYKNNYCAbRkL27o55oVET42Wbfue0XaBuJx5G0RaqBaTptYFqt4CRk1bt2tOqY6jAWOY2as5sLDgE0Ue+QZU6/DGLcJlUK3b2fR6keQlnbo/A2ooVflhDMR/01NU8ejp+Jw698Zler0rPIaKYELwhKmJyH0aEWnnaNlmXfVNkfysoKAIxT9YLxHLn889HIlx5NCFMm6wsypKooKzMU+fu/rR3Gg== diff --git a/blueprints/electric_pole_connection.bp b/factorio-blueprint/blueprints/electric_pole_connection.bp similarity index 100% rename from blueprints/electric_pole_connection.bp rename to factorio-blueprint/blueprints/electric_pole_connection.bp diff --git a/blueprints/mining b/factorio-blueprint/blueprints/mining similarity index 100% rename from blueprints/mining rename to factorio-blueprint/blueprints/mining diff --git a/blueprints/nested b/factorio-blueprint/blueprints/nested similarity index 100% rename from blueprints/nested rename to factorio-blueprint/blueprints/nested diff --git a/blueprints/orientation.bp b/factorio-blueprint/blueprints/orientation.bp similarity index 100% rename from blueprints/orientation.bp rename to factorio-blueprint/blueprints/orientation.bp diff --git a/blueprints/orientation.json b/factorio-blueprint/blueprints/orientation.json similarity index 100% rename from blueprints/orientation.json rename to factorio-blueprint/blueprints/orientation.json diff --git a/blueprints/own_train.json b/factorio-blueprint/blueprints/own_train.json similarity index 100% rename from blueprints/own_train.json rename to factorio-blueprint/blueprints/own_train.json diff --git a/blueprints/rail b/factorio-blueprint/blueprints/rail similarity index 100% rename from blueprints/rail rename to factorio-blueprint/blueprints/rail diff --git a/blueprints/simple b/factorio-blueprint/blueprints/simple similarity index 100% rename from blueprints/simple rename to factorio-blueprint/blueprints/simple diff --git a/blueprints/simple_splitter.bp b/factorio-blueprint/blueprints/simple_splitter.bp similarity index 100% rename from blueprints/simple_splitter.bp rename to factorio-blueprint/blueprints/simple_splitter.bp diff --git a/blueprints/single_belt.bp b/factorio-blueprint/blueprints/single_belt.bp similarity index 100% rename from blueprints/single_belt.bp rename to factorio-blueprint/blueprints/single_belt.bp diff --git a/blueprints/small_train.bp b/factorio-blueprint/blueprints/small_train.bp similarity index 100% rename from blueprints/small_train.bp rename to factorio-blueprint/blueprints/small_train.bp diff --git a/blueprints/small_train.json b/factorio-blueprint/blueprints/small_train.json similarity index 100% rename from blueprints/small_train.json rename to factorio-blueprint/blueprints/small_train.json diff --git a/blueprints/tiles b/factorio-blueprint/blueprints/tiles similarity index 100% rename from blueprints/tiles rename to factorio-blueprint/blueprints/tiles diff --git a/factorio-blueprint/blueprints/train-signals-param.bp b/factorio-blueprint/blueprints/train-signals-param.bp new file mode 100644 index 0000000..87cb941 --- /dev/null +++ b/factorio-blueprint/blueprints/train-signals-param.bp @@ -0,0 +1 @@ +0eNrFld2OmzAQhV9lNZeVWfETkgWpfYJe9i6KLAKTrlWwqW3SRhHv3jE4JLv1ptVetIqExoP9cebMQM6wbwfstZAWyjOIWkkD5fYMRnyVVetysuoQSmiwFg3qqFbdXsjKKg0jAyEb/AllMrLAEasrISNjVX+zNR13DFBaYQXOj5oWJy6Hbo+aWCxwnkGvDB1R0vEJs85o3wnKqMiITbKtVi3f43N1FCSNNhmUDbeKTxQoD1VrkM1M7pg9Nvwq2Z5698ij0HagzKJh3hF9cRUYtDPN8FZ0ghyzergwfe7vkZ9hdExbzVUBOA9feZGyO/a/7cnT02NO7EZorOf7SRo2yWM53WsmlHHZ2xU16CC0uS3MS+orTYElUTHMPaBi3BylcRy7LqvB9oN9PU9/tsWx+hNpGqTlB606LiSBfA/H3TgGrMreadXmv1qVkFVu3bkdTmkJn+Cfe7daQB02YugibMkNLeqoVy0G3XvMvX9r8i+AzBfkfmi/RfR+oKb6Q6z4wtoExjaAXl/LtohtVD+jsXdFTuAAafP+ujeFQ1KjfpBa16ZtwhKWsmzHtilFGUumKHM/imjNVlOOrmzjo5yinKK1zxFvGZW5977joiE1dHk5Sgy+0xhQRdEyhk6pT9JmqXQ3zcmLCfsIkxke7c1gl6AE9/5eZyul8ECcoa3c42NuKNFgT59XlP4beBeXvMAlv+EePjykASR5ISx2boKWvygGRzJmKjNfp8WqKPJ8ladFlozjL1XOQeE= diff --git a/factorio-blueprint/blueprints/train-signals.bp b/factorio-blueprint/blueprints/train-signals.bp new file mode 100644 index 0000000..35e1c8e --- /dev/null +++ b/factorio-blueprint/blueprints/train-signals.bp @@ -0,0 +1 @@ +0eNrFlM9unDAQxt9lziZaYIHAoU/QY2+rFeLPbGPV2JY9bLNa8e4ZA9msIppWOTRCQuOx/fM33xiu0KoRrZOaoLqC7Iz2UB2u4OVP3aiQ082AUEGPnezRRZ0ZWqkbMg4mAVL3+AxVPImNLeQaqSNPxt4tTaajANQkSeJy1Dy41HocWnTMEhv7BVjjeYvRgc+YPOV1F6iiMmU2yyZnVN3iU3OWLI0XedR9TaaeKVCdGuVRLMw6MC329Ztkuthw5Fk6Gjlz07CsiH6ECjzSQvO1koNkx8iNr8w19+/I7zAFJjVLVQDBw3deJOID+//syePjQ8bsXjrslvk42TZpxdY8188oH7L3I27QSTp/X9gqSTqjI6saQlhawLWEa5TsdrvQZDOSHen9dfq7K4FlLyxp1FSfnBlqqRm0tnA6TtOGU+knnSq+0qmYnQrjwTZuFlrBN/jv1u1voAF7OQ4RKjbDyS6yRuGmeQ/Zal/O9m0gsxuyHdWviL8OdISbjdi9soqNS7uBzt/KJkQVdU/o6UORM3iDVHy+7qIMSG7Ub1Yb2nSIRSwSkR7FIeEoFfEcpeHhiMdiP+f4LYo1yjjKOMrXHPMk4RBcu/2UBZzR+VlEliflviyzbJ8lZRpP0wudqOug diff --git a/blueprints/train2.0.bp b/factorio-blueprint/blueprints/train2.0.bp similarity index 100% rename from blueprints/train2.0.bp rename to factorio-blueprint/blueprints/train2.0.bp diff --git a/blueprints/train2.0.json b/factorio-blueprint/blueprints/train2.0.json similarity index 100% rename from blueprints/train2.0.json rename to factorio-blueprint/blueprints/train2.0.json diff --git a/blueprints/walls b/factorio-blueprint/blueprints/walls similarity index 100% rename from blueprints/walls rename to factorio-blueprint/blueprints/walls diff --git a/factorio-blueprint/src/belt.rs b/factorio-blueprint/src/belt.rs new file mode 100644 index 0000000..07f50d5 --- /dev/null +++ b/factorio-blueprint/src/belt.rs @@ -0,0 +1,59 @@ +use factorio_core::{pathfield::PathField, prelude::*}; + +use crate::misc::Beltspeed; + +use super::{BlueprintEntity, BlueprintPosition}; + +pub fn convert_belt_to_blueprint( + belt: &PathField, + speed: &Beltspeed, + nextfree: &mut u32, +) -> impl Iterator + use<> { + match belt { + PathField::Belt { pos, dir } => { + *nextfree += 1; + vec![ + BlueprintEntity::builder( + speed.string(), + *nextfree - 1, + BlueprintPosition::new(pos.x as f64 + 0.5, pos.y as f64 + 0.5), + ) + .direction(dir.get_index() * 4) + .build(), + ] + .into_iter() + } + PathField::Underground { pos, dir, len } => { + *nextfree += 2; + let endpos = pos.in_direction(dir, *len as PositionType); + vec![ + BlueprintEntity::builder( + speed.string_underground(), + *nextfree - 2, + BlueprintPosition::new(pos.x as f64 + 0.5, pos.y as f64 + 0.5), + ) + .underground_type("input".to_string()) + .direction(dir.get_index() * 4) + .build(), + BlueprintEntity::builder( + speed.string_underground(), + *nextfree - 1, + BlueprintPosition::new(endpos.x as f64 + 0.5, endpos.y as f64 + 0.5), + ) + .underground_type("output".to_string()) + .direction(dir.get_index() * 4) + .build(), + ] + .into_iter() + } + } +} + +pub fn convert_to_blueprint<'p, 's, 'n>( + path: &'p [PathField], + speed: &'s Beltspeed, + nextfree: &'n mut u32, +) -> impl Iterator + use<'p, 's, 'n> { + path.iter() + .flat_map(|b| convert_belt_to_blueprint(b, speed, nextfree)) +} diff --git a/src/bin/decode_blueprint.rs b/factorio-blueprint/src/bin/decode_blueprint.rs similarity index 88% rename from src/bin/decode_blueprint.rs rename to factorio-blueprint/src/bin/decode_blueprint.rs index 83dfd8f..808ca7a 100644 --- a/src/bin/decode_blueprint.rs +++ b/factorio-blueprint/src/bin/decode_blueprint.rs @@ -1,6 +1,5 @@ -use base64::prelude::*; use clap::Parser; -use factorio_blueprint::blueprint::{decode, encode}; +use factorio_blueprint::{decode, encode}; use std::path::PathBuf; #[derive(Debug, Parser)] diff --git a/src/blueprint/mod.rs b/factorio-blueprint/src/lib.rs similarity index 93% rename from src/blueprint/mod.rs rename to factorio-blueprint/src/lib.rs index 9e3049b..94d2615 100644 --- a/src/blueprint/mod.rs +++ b/factorio-blueprint/src/lib.rs @@ -1,18 +1,16 @@ +use base64::Engine; use base64::engine::general_purpose::STANDARD; use base64::prelude::BASE64_STANDARD; -use base64::Engine; use std::io::Cursor; use std::io::Read; +pub mod misc; + pub mod structs; +pub mod belt; pub use structs::*; -pub mod balancer; -pub mod belt; -pub mod station; -pub mod train; - pub fn decode(s: &str) -> String { let raw = s.trim().as_bytes(); assert!(raw[0] == b'0'); diff --git a/src/blueprint/belt.rs b/factorio-blueprint/src/misc.rs similarity index 52% rename from src/blueprint/belt.rs rename to factorio-blueprint/src/misc.rs index 1b8f6e2..f8d3ae9 100644 --- a/src/blueprint/belt.rs +++ b/factorio-blueprint/src/misc.rs @@ -1,9 +1,5 @@ use clap::ValueEnum; -use crate::{belt_finding::common::PathField, prelude::PositionType}; - -use super::{Blueprint, BlueprintEntity, BlueprintPosition}; - #[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] pub enum Beltspeed { Normal, @@ -84,55 +80,3 @@ impl Belttype { } } } - -pub fn convert_belt_to_blueprint( - belt: &PathField, - speed: &Beltspeed, - nextfree: &mut u32, -) -> impl Iterator { - match belt { - PathField::Belt { pos, dir } => { - *nextfree += 1; - vec![BlueprintEntity::builder( - speed.string(), - *nextfree - 1, - BlueprintPosition::new(pos.x as f64 + 0.5, pos.y as f64 + 0.5), - ) - .direction(dir.get_index() * 4) - .build()] - .into_iter() - } - PathField::Underground { pos, dir, len } => { - *nextfree += 2; - let endpos = pos.in_direction(dir, *len as PositionType); - vec![ - BlueprintEntity::builder( - speed.string_underground(), - *nextfree - 2, - BlueprintPosition::new(pos.x as f64 + 0.5, pos.y as f64 + 0.5), - ) - .underground_type("input".to_string()) - .direction(dir.get_index() * 4) - .build(), - BlueprintEntity::builder( - speed.string_underground(), - *nextfree - 1, - BlueprintPosition::new(endpos.x as f64 + 0.5, endpos.y as f64 + 0.5), - ) - .underground_type("output".to_string()) - .direction(dir.get_index() * 4) - .build(), - ] - .into_iter() - } - } -} - -pub fn convert_to_blueprint<'p, 's, 'n>( - path: &'p [PathField], - speed: &'s Beltspeed, - nextfree: &'n mut u32, -) -> impl Iterator + use<'p, 's, 'n> { - path.iter() - .flat_map(|b| convert_belt_to_blueprint(b, speed, nextfree)) -} diff --git a/src/blueprint/structs.rs b/factorio-blueprint/src/structs.rs similarity index 100% rename from src/blueprint/structs.rs rename to factorio-blueprint/src/structs.rs diff --git a/factorio-core/Cargo.toml b/factorio-core/Cargo.toml new file mode 100644 index 0000000..24349c6 --- /dev/null +++ b/factorio-core/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "factorio-core" +version = "0.1.0" +edition = "2024" + + +[dev-dependencies] +criterion = "0.3" + +[dependencies] +image = "0.25.5" +proptest = "1.5.0" +proptest-derive = "0.5.0" +rand = "0.8.5" +serde = { version = "1.0.217", features = ["derive"] } +termcolor = "1.4.1" diff --git a/src/common/aabb.rs b/factorio-core/src/aabb.rs similarity index 100% rename from src/common/aabb.rs rename to factorio-core/src/aabb.rs diff --git a/src/common/block.rs b/factorio-core/src/block.rs similarity index 100% rename from src/common/block.rs rename to factorio-core/src/block.rs diff --git a/src/common/color.rs b/factorio-core/src/color.rs similarity index 100% rename from src/common/color.rs rename to factorio-core/src/color.rs diff --git a/src/common/direction.rs b/factorio-core/src/direction.rs similarity index 100% rename from src/common/direction.rs rename to factorio-core/src/direction.rs diff --git a/src/lib.rs b/factorio-core/src/lib.rs similarity index 55% rename from src/lib.rs rename to factorio-core/src/lib.rs index 0442acc..028c38d 100644 --- a/src/lib.rs +++ b/factorio-core/src/lib.rs @@ -1,13 +1,14 @@ -pub mod belt_finding; -pub mod blueprint; -pub mod common; -pub mod graph; -pub mod layout; -pub mod misc; -pub mod priority_queue; +pub mod aabb; +pub mod block; +pub mod color; +pub mod direction; +pub mod pathfield; +pub mod position; +pub mod transformation; +pub mod visualize; pub mod prelude { - pub use crate::common::{ + pub use crate::{ aabb::AABB, block::Block, direction::Direction, diff --git a/src/belt_finding/common.rs b/factorio-core/src/pathfield.rs similarity index 100% rename from src/belt_finding/common.rs rename to factorio-core/src/pathfield.rs diff --git a/src/common/position.rs b/factorio-core/src/position.rs similarity index 100% rename from src/common/position.rs rename to factorio-core/src/position.rs diff --git a/src/common/transformation.rs b/factorio-core/src/transformation.rs similarity index 100% rename from src/common/transformation.rs rename to factorio-core/src/transformation.rs diff --git a/src/common/visualize/image.rs b/factorio-core/src/visualize/image.rs similarity index 99% rename from src/common/visualize/image.rs rename to factorio-core/src/visualize/image.rs index 11f5fc0..d5da511 100644 --- a/src/common/visualize/image.rs +++ b/factorio-core/src/visualize/image.rs @@ -1,5 +1,5 @@ use super::Visualization; -use crate::{common::visualize::Symbol, prelude::Direction}; +use crate::{prelude::Direction, visualize::Symbol}; use image::{GenericImage, Rgba, RgbaImage}; pub(super) fn draw>>(v: &Visualization, image: &mut I) { diff --git a/src/common/visualize/mod.rs b/factorio-core/src/visualize/mod.rs similarity index 100% rename from src/common/visualize/mod.rs rename to factorio-core/src/visualize/mod.rs diff --git a/src/common/visualize/print.rs b/factorio-core/src/visualize/print.rs similarity index 100% rename from src/common/visualize/print.rs rename to factorio-core/src/visualize/print.rs diff --git a/factorio-pathfinding/Cargo.toml b/factorio-pathfinding/Cargo.toml new file mode 100644 index 0000000..c9e3dcf --- /dev/null +++ b/factorio-pathfinding/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "factorio-pathfinding" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + +[dev-dependencies] +criterion = "0.3" + +[[bench]] +name = "bruteforce" +harness = false + +[dependencies] +factorio-core = { path = "../factorio-core" } +factorio-blueprint = { path = "../factorio-blueprint" } +base64 = "0.21.5" +bon = "3.0.2" +clap = { version = "4.4.8", features = ["derive"] } +flate2 = "1.0.28" +image = "0.25.2" +miette = { version = "7.2.0", features = ["fancy"] } +proptest = "1.5.0" +proptest-derive = "0.5.0" +rand = { version = "0.8.5", features = ["small_rng"] } +serde = { version = "1.0.192", features = ["derive"] } +serde_json = "1.0.108" +serde_yaml = "0.9.34" +termcolor = "1.4.1" diff --git a/benches/bruteforce.rs b/factorio-pathfinding/benches/bruteforce.rs similarity index 88% rename from benches/bruteforce.rs rename to factorio-pathfinding/benches/bruteforce.rs index 9516667..f9962b0 100644 --- a/benches/bruteforce.rs +++ b/factorio-pathfinding/benches/bruteforce.rs @@ -1,6 +1,6 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use factorio_blueprint::belt_finding::brute_force::problems::{mid, simple, snake}; +use factorio_pathfinding::belt_finding::brute_force::problems::{mid, simple, snake}; macro_rules! bench_bruteforce { ($b:ident; $i:ident) => { diff --git a/examples/brute_force.rs b/factorio-pathfinding/examples/brute_force.rs similarity index 94% rename from examples/brute_force.rs rename to factorio-pathfinding/examples/brute_force.rs index 0c7bcfa..efa626f 100644 --- a/examples/brute_force.rs +++ b/factorio-pathfinding/examples/brute_force.rs @@ -1,10 +1,7 @@ -use std::io; - use clap::{Parser, ValueEnum}; -use factorio_blueprint::{ - belt_finding::brute_force::{problems, Bruteforce}, - common::visualize::Visualize, -}; +use factorio_core::visualize::Visualize; +use factorio_pathfinding::belt_finding::brute_force::{problems, Bruteforce}; +use std::io; #[derive(ValueEnum, Clone)] enum Mode { diff --git a/examples/decode_blueprint.rs b/factorio-pathfinding/examples/decode_blueprint.rs similarity index 66% rename from examples/decode_blueprint.rs rename to factorio-pathfinding/examples/decode_blueprint.rs index d73426d..c1d4245 100644 --- a/examples/decode_blueprint.rs +++ b/factorio-pathfinding/examples/decode_blueprint.rs @@ -1,5 +1,5 @@ use clap::Parser; -use factorio_blueprint::blueprint; +use factorio_blueprint::{decode, BlueprintString}; use std::path::PathBuf; #[derive(Debug, Parser)] @@ -12,10 +12,10 @@ fn main() { let s = std::fs::read_to_string(args.blueprint).unwrap(); - let raw = blueprint::decode(s.trim_end()); + let raw = decode(s.trim_end()); // println!("{}", &raw); - let bp = serde_json::from_str::(&raw).unwrap(); + let bp = serde_json::from_str::(&raw).unwrap(); dbg!(&bp); diff --git a/examples/priority_queue_test.rs b/factorio-pathfinding/examples/priority_queue_test.rs similarity index 91% rename from examples/priority_queue_test.rs rename to factorio-pathfinding/examples/priority_queue_test.rs index 6a11667..0311bf2 100644 --- a/examples/priority_queue_test.rs +++ b/factorio-pathfinding/examples/priority_queue_test.rs @@ -1,4 +1,4 @@ -use factorio_blueprint::priority_queue::{fibonacci_heap::FibonacciHeap, PriorityQueue}; +use factorio_pathfinding::priority_queue::{fibonacci_heap::FibonacciHeap, PriorityQueue}; use std::fmt::Debug; fn test_loop

() diff --git a/layout.yml b/factorio-pathfinding/layout.yml similarity index 100% rename from layout.yml rename to factorio-pathfinding/layout.yml diff --git a/layout2.yml b/factorio-pathfinding/layout2.yml similarity index 100% rename from layout2.yml rename to factorio-pathfinding/layout2.yml diff --git a/layout3.yml b/factorio-pathfinding/layout3.yml similarity index 100% rename from layout3.yml rename to factorio-pathfinding/layout3.yml diff --git a/src/belt_finding/brute_force.rs b/factorio-pathfinding/src/belt_finding/brute_force.rs similarity index 96% rename from src/belt_finding/brute_force.rs rename to factorio-pathfinding/src/belt_finding/brute_force.rs index 833ecf3..98fe028 100644 --- a/src/belt_finding/brute_force.rs +++ b/factorio-pathfinding/src/belt_finding/brute_force.rs @@ -1,8 +1,8 @@ -use super::{common::PathField, Position}; -use crate::prelude::*; -use crate::{common::visualize::Visualize, misc::Map}; +use factorio_core::{pathfield::PathField, prelude::*, visualize::Visualize}; use std::time::Instant; +use crate::misc::Map; + #[derive(Default, Debug, Clone)] pub struct BruteforceField { pub blocked: bool, @@ -590,8 +590,8 @@ impl Bruteforce { } impl Visualize for Bruteforce { - fn visualize(&self) -> crate::common::visualize::Visualization { - let mut v = crate::common::visualize::Visualization::new(Position::new( + fn visualize(&self) -> factorio_core::visualize::Visualization { + let mut v = factorio_core::visualize::Visualization::new(Position::new( self.map.width as i32, self.map.height as i32, )); @@ -601,8 +601,8 @@ impl Visualize for Bruteforce { if self.map.get(x, y).blocked { v.add_symbol( Position::new(x as i32, y as i32), - crate::common::visualize::Symbol::Block, - Some(crate::common::visualize::Color::white()), + factorio_core::visualize::Symbol::Block, + Some(factorio_core::visualize::Color::white()), None, ); } @@ -615,22 +615,22 @@ impl Visualize for Bruteforce { PathField::Belt { pos, dir } => { v.add_symbol( *pos, - crate::common::visualize::Symbol::Arrow(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::Arrow(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ); } PathField::Underground { pos, dir, len } => { v.add_symbol( *pos, - crate::common::visualize::Symbol::ArrowEnter(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::ArrowEnter(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ); v.add_symbol( pos.in_direction(dir, *len as i32), - crate::common::visualize::Symbol::ArrowExit(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::ArrowExit(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ); } @@ -638,11 +638,11 @@ impl Visualize for Bruteforce { } v.add_symbol( problem.end_pos, - crate::common::visualize::Symbol::Char(match problem.finished { + factorio_core::visualize::Symbol::Char(match problem.finished { true => 'T', false => 't', }), - Some(crate::common::visualize::Color::index(i)), + Some(factorio_core::visualize::Color::index(i)), None, ); } diff --git a/src/belt_finding/conflict_avoidance.rs b/factorio-pathfinding/src/belt_finding/conflict_avoidance.rs similarity index 95% rename from src/belt_finding/conflict_avoidance.rs rename to factorio-pathfinding/src/belt_finding/conflict_avoidance.rs index abcf367..6fd6b4d 100644 --- a/src/belt_finding/conflict_avoidance.rs +++ b/factorio-pathfinding/src/belt_finding/conflict_avoidance.rs @@ -1,13 +1,13 @@ -use super::{common::PathField, Problem}; -use crate::blueprint::belt::{convert_to_blueprint, Beltspeed}; -use crate::blueprint::BlueprintEntity; use crate::{belt_finding::brute_force::BruteforceBuilder, misc::Map}; -use crate::{common::visualize::Visualize, prelude::*}; +use factorio_blueprint::{belt::convert_to_blueprint, misc::Beltspeed, BlueprintEntity}; +use factorio_core::{pathfield::PathField, prelude::*, visualize::Visualize}; use std::{ ops::RangeInclusive, time::{Duration, Instant}, }; +use super::Problem; + #[derive(Default)] struct Field { blocked: bool, @@ -510,8 +510,8 @@ impl ConflictAvoidance { } impl Visualize for ConflictAvoidance { - fn visualize(&self) -> crate::common::visualize::Visualization { - let mut v = crate::common::visualize::Visualization::new(Position::new( + fn visualize(&self) -> factorio_core::visualize::Visualization { + let mut v = factorio_core::visualize::Visualization::new(Position::new( self.map.width as i32, self.map.height as i32, )); @@ -526,8 +526,8 @@ impl Visualize for ConflictAvoidance { v.add_symbol( Position::new(x as i32, y as i32), - crate::common::visualize::Symbol::Block, - Some(crate::common::visualize::Color::white()), + factorio_core::visualize::Symbol::Block, + Some(factorio_core::visualize::Color::white()), None, ); } @@ -555,22 +555,22 @@ impl Visualize for ConflictAvoidance { PathField::Belt { pos, dir } => { v.add_symbol( *pos, - crate::common::visualize::Symbol::Arrow(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::Arrow(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ); } PathField::Underground { pos, dir, len } => { v.add_symbol( *pos, - crate::common::visualize::Symbol::ArrowEnter(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::ArrowEnter(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ); v.add_symbol( pos.in_direction(dir, *len as i32), - crate::common::visualize::Symbol::ArrowExit(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::ArrowExit(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ); } @@ -583,7 +583,7 @@ impl Visualize for ConflictAvoidance { for y in yrange.clone() { v.overwrite_background( Position::new(x, y), - Some(crate::common::visualize::Color::new(150, 150, 0)), + Some(factorio_core::visualize::Color::new(150, 150, 0)), ); } } @@ -594,7 +594,7 @@ impl Visualize for ConflictAvoidance { if conflicts.get(x, y) > &1 { v.overwrite_background( Position::new(x as i32, y as i32), - Some(crate::common::visualize::Color::new(100, 80, 80)), + Some(factorio_core::visualize::Color::new(100, 80, 80)), ); } } diff --git a/src/belt_finding/mod.rs b/factorio-pathfinding/src/belt_finding/mod.rs similarity index 95% rename from src/belt_finding/mod.rs rename to factorio-pathfinding/src/belt_finding/mod.rs index ab621f7..7d5ea38 100644 --- a/src/belt_finding/mod.rs +++ b/factorio-pathfinding/src/belt_finding/mod.rs @@ -1,14 +1,13 @@ -use crate::common::visualize::Visualize; use crate::graph::wheighted_graph::shortest_path::dijkstra; use crate::graph::wheighted_graph::WheightedGraph; use crate::layout::Layout; use crate::misc::Map; -use crate::prelude::*; use crate::priority_queue::BinaryHeap; +use factorio_core::{prelude::*, visualize::Visualize}; use serde::{Deserialize, Serialize}; pub mod brute_force; -pub mod common; + pub mod conflict_avoidance; #[derive(Debug, Default, Serialize, Deserialize, Clone, Copy)] @@ -128,8 +127,8 @@ impl Problem { } impl Visualize for Problem { - fn visualize(&self) -> crate::common::visualize::Visualization { - let mut v = crate::common::visualize::Visualization::new(Position::new( + fn visualize(&self) -> factorio_core::visualize::Visualization { + let mut v = factorio_core::visualize::Visualization::new(Position::new( self.map.width as i32, self.map.height as i32, )); @@ -139,8 +138,8 @@ impl Visualize for Problem { if self.map.get(x, y).blocked { v.add_symbol( Position::new(x as i32, y as i32), - crate::common::visualize::Symbol::Block, - Some(crate::common::visualize::Color::white()), + factorio_core::visualize::Symbol::Block, + Some(factorio_core::visualize::Color::white()), None, ) } @@ -150,8 +149,8 @@ impl Visualize for Problem { for (i, (p, _d)) in self.start.iter().enumerate() { v.add_symbol( *p, - crate::common::visualize::Symbol::Char('S'), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::Char('S'), + Some(factorio_core::visualize::Color::index(i)), None, ) } @@ -159,8 +158,8 @@ impl Visualize for Problem { for (i, (p, _d)) in self.end.iter().enumerate() { v.add_symbol( *p, - crate::common::visualize::Symbol::Char('T'), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::Char('T'), + Some(factorio_core::visualize::Color::index(i)), None, ) } @@ -169,8 +168,8 @@ impl Visualize for Problem { for (pos, dir) in p { v.add_symbol( *pos, - crate::common::visualize::Symbol::Arrow(*dir), - Some(crate::common::visualize::Color::index(i)), + factorio_core::visualize::Symbol::Arrow(*dir), + Some(factorio_core::visualize::Color::index(i)), None, ) } @@ -252,7 +251,7 @@ impl Problem { pub mod problems { use super::Problem; - use crate::prelude::*; + use factorio_core::prelude::*; pub fn simple() -> Problem { let mut p = Problem::new(5, 3); diff --git a/src/bin/beltfinding.rs b/factorio-pathfinding/src/bin/beltfinding.rs similarity index 84% rename from src/bin/beltfinding.rs rename to factorio-pathfinding/src/bin/beltfinding.rs index 448e1f1..709b067 100644 --- a/src/bin/beltfinding.rs +++ b/factorio-pathfinding/src/bin/beltfinding.rs @@ -1,8 +1,8 @@ use clap::{Parser, Subcommand, ValueEnum}; -use factorio_blueprint::{ - belt_finding::{conflict_avoidance::ConflictAvoidance, problems, Problem}, - blueprint::{Blueprint, BlueprintString}, - common::visualize::Visualize, +use factorio_blueprint::{encode, misc::Beltspeed, Blueprint, BlueprintString}; +use factorio_core::visualize::Visualize; +use factorio_pathfinding::belt_finding::{ + conflict_avoidance::ConflictAvoidance, problems, Problem, }; use std::{io, path::PathBuf}; @@ -49,10 +49,7 @@ struct Args { fn output_blueprint(conflict: &ConflictAvoidance) { let mut offset = 0; - let belts = conflict.belt_blueprint( - &factorio_blueprint::blueprint::belt::Beltspeed::Normal, - &mut offset, - ); + let belts = conflict.belt_blueprint(&Beltspeed::Normal, &mut offset); let bp = BlueprintString::Blueprint( Blueprint::builder() @@ -61,10 +58,7 @@ fn output_blueprint(conflict: &ConflictAvoidance) { .build(), ); - println!( - "{}", - factorio_blueprint::blueprint::encode(&serde_json::to_string(&bp).unwrap()) - ); + println!("{}", encode(&serde_json::to_string(&bp).unwrap())); } fn main() { diff --git a/src/bin/create_beltfinding_image.rs b/factorio-pathfinding/src/bin/create_beltfinding_image.rs similarity index 77% rename from src/bin/create_beltfinding_image.rs rename to factorio-pathfinding/src/bin/create_beltfinding_image.rs index a037e3b..2046228 100644 --- a/src/bin/create_beltfinding_image.rs +++ b/factorio-pathfinding/src/bin/create_beltfinding_image.rs @@ -1,8 +1,7 @@ use clap::Parser; -use factorio_blueprint::{ - belt_finding::{conflict_avoidance::ConflictAvoidance, Problem}, - common::visualize::{image_grid, Visualize}, -}; +use factorio_core::visualize::image_grid; +use factorio_core::visualize::Visualize; +use factorio_pathfinding::belt_finding::{conflict_avoidance::ConflictAvoidance, Problem}; use std::{fs::File, path::PathBuf}; #[derive(Parser)] diff --git a/factorio-pathfinding/src/bin/layout.rs b/factorio-pathfinding/src/bin/layout.rs new file mode 100644 index 0000000..151161c --- /dev/null +++ b/factorio-pathfinding/src/bin/layout.rs @@ -0,0 +1,98 @@ +use clap::{Parser, Subcommand}; +use factorio_core::visualize::Visualize; +use factorio_pathfinding::layout::{genetic_algorithm2, GeneticAlgorithm, PathLayout}; +use miette::{Context, IntoDiagnostic, Result}; +use rand::{rngs::SmallRng, SeedableRng}; +use std::path::PathBuf; + +#[derive(Debug, Parser)] +struct Args { + #[clap(short, long, default_value_t = 0)] + seed: u64, + + problem: PathBuf, + + #[command(subcommand)] + subcommand: Commands, +} + +#[derive(Debug, Subcommand)] +enum Commands { + V1, + V2, + Bench { + #[clap(short, long, default_value_t = 100)] + runs: usize, + + #[clap(short, long, default_value_t = 100)] + mutations: usize, + }, +} + +fn main() -> Result<()> { + let args = Args::parse(); + + let mut rng = SmallRng::seed_from_u64(args.seed); + let file = std::fs::File::open(args.problem) + .into_diagnostic() + .context("Failed to open problem file.")?; + let p = serde_yaml::from_reader(file) + .into_diagnostic() + .context("Failed to parse yaml.")?; + + match args.subcommand { + Commands::V1 => { + let mut g = GeneticAlgorithm::new(&p, 20, 2, 0, &mut rng); + + for i in 0..100 { + println!("Generatrion {i}"); + g.generation(&mut rng); + } + + g.output_population(); + } + Commands::V2 => { + let mut m: Option = None; + for _ in 0..20 { + let g = genetic_algorithm2(&p, 10, 320, 10000, &mut rng); + + g.print_visualization(); + if m.as_ref().is_none_or(|m| g.score() < m.score()) { + m = Some(g); + } + } + + m.unwrap().print_visualization(); + } + Commands::Bench { runs, mutations } => { + let mut map = Vec::new(); + + let mut m: Option = None; + let start = std::time::Instant::now(); + for _ in 0..runs { + let g = genetic_algorithm2(&p, 1, mutations, mutations, &mut rng); + + map.push(g.score()); + if m.as_ref().is_none_or(|m| g.score() < m.score()) { + m = Some(g); + } + } + + println!("Time: {:.2}", start.elapsed().as_secs_f32()); + + let mean = map.iter().sum::() / runs; + println!("Mean: {}", mean); + let min = map.iter().min().unwrap(); + println!("Min: {}", min); + let max = map.iter().max().unwrap(); + println!("Max: {}", max); + let stddev = + ((map.iter().map(|v| (v - mean) * (v - mean)).sum::() / runs) as f64).sqrt(); + println!("Stddev: {:.1}", stddev); + + m.unwrap().print_visualization(); + } + } + + Ok(()) +} diff --git a/src/graph/mod.rs b/factorio-pathfinding/src/graph/mod.rs similarity index 100% rename from src/graph/mod.rs rename to factorio-pathfinding/src/graph/mod.rs diff --git a/src/graph/wheighted_graph/adjacency_list.rs b/factorio-pathfinding/src/graph/wheighted_graph/adjacency_list.rs similarity index 100% rename from src/graph/wheighted_graph/adjacency_list.rs rename to factorio-pathfinding/src/graph/wheighted_graph/adjacency_list.rs diff --git a/src/graph/wheighted_graph/mod.rs b/factorio-pathfinding/src/graph/wheighted_graph/mod.rs similarity index 100% rename from src/graph/wheighted_graph/mod.rs rename to factorio-pathfinding/src/graph/wheighted_graph/mod.rs diff --git a/src/graph/wheighted_graph/shortest_path.rs b/factorio-pathfinding/src/graph/wheighted_graph/shortest_path.rs similarity index 100% rename from src/graph/wheighted_graph/shortest_path.rs rename to factorio-pathfinding/src/graph/wheighted_graph/shortest_path.rs diff --git a/src/layout/mod.rs b/factorio-pathfinding/src/layout/mod.rs similarity index 98% rename from src/layout/mod.rs rename to factorio-pathfinding/src/layout/mod.rs index 58694fc..32e3463 100644 --- a/src/layout/mod.rs +++ b/factorio-pathfinding/src/layout/mod.rs @@ -1,7 +1,7 @@ -use crate::belt_finding::common::PathField; use crate::belt_finding::conflict_avoidance::ConflictAvoidance; -use crate::common::visualize::{image_grid, Color, Symbol, Visualization, Visualize}; -use crate::prelude::*; +use factorio_core::pathfield::PathField; +use factorio_core::prelude::*; +use factorio_core::visualize::{image_grid, Color, Symbol, Visualization, Visualize}; use rand::{seq::SliceRandom, Rng}; use serde::{Deserialize, Serialize}; use std::sync::atomic::AtomicU32; @@ -241,7 +241,7 @@ impl<'a> PathLayout<'a> { } impl<'a> Visualize for PathLayout<'a> { - fn visualize(&self) -> Visualization { + fn visualize(&self) -> factorio_core::visualize::Visualization { let mut v = self.layout.visualize(); let offset = self.layout.blocks.len(); diff --git a/factorio-pathfinding/src/lib.rs b/factorio-pathfinding/src/lib.rs new file mode 100644 index 0000000..de710f8 --- /dev/null +++ b/factorio-pathfinding/src/lib.rs @@ -0,0 +1,5 @@ +pub mod belt_finding; +pub mod graph; +pub mod layout; +pub mod misc; +pub mod priority_queue; diff --git a/src/misc/arena.rs b/factorio-pathfinding/src/misc/arena.rs similarity index 100% rename from src/misc/arena.rs rename to factorio-pathfinding/src/misc/arena.rs diff --git a/src/misc/map.rs b/factorio-pathfinding/src/misc/map.rs similarity index 100% rename from src/misc/map.rs rename to factorio-pathfinding/src/misc/map.rs diff --git a/src/misc/mod.rs b/factorio-pathfinding/src/misc/mod.rs similarity index 100% rename from src/misc/mod.rs rename to factorio-pathfinding/src/misc/mod.rs diff --git a/src/priority_queue/fibonacci_heap.rs b/factorio-pathfinding/src/priority_queue/fibonacci_heap.rs similarity index 100% rename from src/priority_queue/fibonacci_heap.rs rename to factorio-pathfinding/src/priority_queue/fibonacci_heap.rs diff --git a/src/priority_queue/mod.rs b/factorio-pathfinding/src/priority_queue/mod.rs similarity index 100% rename from src/priority_queue/mod.rs rename to factorio-pathfinding/src/priority_queue/mod.rs diff --git a/src/bin/balancer_blueprint.rs b/src/bin/balancer_blueprint.rs deleted file mode 100644 index 0d35842..0000000 --- a/src/bin/balancer_blueprint.rs +++ /dev/null @@ -1,12 +0,0 @@ -use factorio_blueprint::blueprint::{balancer::generate_4_lane_balancer, BlueprintString}; - -fn main() { - let b = BlueprintString::Blueprint(generate_4_lane_balancer()); - - println!("{}", serde_json::to_string_pretty(&b).unwrap()); - - println!( - "{}", - factorio_blueprint::blueprint::encode(&serde_json::to_string(&b).unwrap()) - ); -} diff --git a/src/bin/layout.rs b/src/bin/layout.rs deleted file mode 100644 index 413fffa..0000000 --- a/src/bin/layout.rs +++ /dev/null @@ -1,65 +0,0 @@ -use clap::{Parser, Subcommand}; -use factorio_blueprint::{ - common::visualize::Visualize, - layout::{genetic_algorithm2, GeneticAlgorithm, PathLayout}, -}; -use miette::{Context, IntoDiagnostic, Result}; -use rand::{rngs::SmallRng, SeedableRng}; -use std::path::PathBuf; - -#[derive(Debug, Parser)] -struct Args { - #[clap(short, long, default_value_t = 0)] - seed: u64, - - problem: PathBuf, - - #[command(subcommand)] - subcommand: Commands, -} - -#[derive(Debug, Subcommand)] -enum Commands { - V1, - V2, -} - -fn main() -> Result<()> { - let args = Args::parse(); - - let mut rng = SmallRng::seed_from_u64(args.seed); - let file = std::fs::File::open(args.problem) - .into_diagnostic() - .context("Failed to open problem file.")?; - let p = serde_yaml::from_reader(file) - .into_diagnostic() - .context("Failed to parse yaml.")?; - - match args.subcommand { - Commands::V1 => { - let mut g = GeneticAlgorithm::new(&p, 20, 2, 0, &mut rng); - - for i in 0..100 { - println!("Generatrion {i}"); - g.generation(&mut rng); - } - - g.output_population(); - } - Commands::V2 => { - let mut m: Option = None; - for _ in 0..20 { - let g = genetic_algorithm2(&p, 10, 320, &mut rng); - - g.print_visualization(); - if m.as_ref().is_none_or(|m| g.score() < m.score()) { - m = Some(g); - } - } - - m.unwrap().print_visualization(); - } - } - - Ok(()) -} diff --git a/src/common/mod.rs b/src/common/mod.rs deleted file mode 100644 index fb457f6..0000000 --- a/src/common/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod aabb; -pub mod block; -pub mod color; -pub mod direction; -pub mod position; -pub mod transformation; -pub mod visualize;