Parameterize priority queue
This commit is contained in:
parent
6f74f1345e
commit
ffe51bede9
14 changed files with 276 additions and 183 deletions
270
Cargo.lock
generated
270
Cargo.lock
generated
|
|
@ -90,9 +90,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.96"
|
||||
version = "1.0.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
|
||||
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
|
|
@ -139,9 +139,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "avif-serialize"
|
||||
version = "0.8.2"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62"
|
||||
checksum = "98922d6a4cfbcb08820c69d8eeccc05bb1f29bfa06b4f5b1dbfe9a868bd7608e"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
|
|
@ -205,9 +205,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.8.0"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||
|
||||
[[package]]
|
||||
name = "bitstream-io"
|
||||
|
|
@ -217,9 +217,9 @@ checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
|
|||
|
||||
[[package]]
|
||||
name = "bon"
|
||||
version = "3.3.2"
|
||||
version = "3.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe7acc34ff59877422326db7d6f2d845a582b16396b6b08194942bf34c6528ab"
|
||||
checksum = "65268237be94042665b92034f979c42d431d2fd998b49809543afe3e66abad1c"
|
||||
dependencies = [
|
||||
"bon-macros",
|
||||
"rustversion",
|
||||
|
|
@ -227,9 +227,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bon-macros"
|
||||
version = "3.3.2"
|
||||
version = "3.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4159dd617a7fbc9be6a692fe69dc2954f8e6bb6bb5e4d7578467441390d77fd0"
|
||||
checksum = "803c95b2ecf650eb10b5f87dda6b9f6a1b758cee53245e2b7b825c9b3803a443"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"ident_case",
|
||||
|
|
@ -254,15 +254,9 @@ checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
|||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.21.0"
|
||||
version = "1.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder-lite"
|
||||
|
|
@ -272,9 +266,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
|||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.0"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
|
||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
|
|
@ -284,9 +278,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.14"
|
||||
version = "1.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
|
||||
checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
|
@ -338,9 +332,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.30"
|
||||
version = "4.5.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d"
|
||||
checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
|
|
@ -348,9 +342,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.30"
|
||||
version = "4.5.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c"
|
||||
checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
|
@ -360,9 +354,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.28"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed"
|
||||
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
|
|
@ -501,9 +495,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
|
|
@ -548,6 +542,7 @@ dependencies = [
|
|||
"flate2",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -557,6 +552,7 @@ dependencies = [
|
|||
"clap",
|
||||
"factorio-blueprint",
|
||||
"factorio-core",
|
||||
"factorio-graph",
|
||||
"factorio-layout",
|
||||
"factorio-pathfinding",
|
||||
"rand 0.9.0",
|
||||
|
|
@ -595,6 +591,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"clap",
|
||||
"factorio-core",
|
||||
"factorio-graph",
|
||||
"factorio-pathfinding",
|
||||
"image",
|
||||
"miette",
|
||||
|
|
@ -652,9 +649,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
|||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.35"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
|
||||
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
|
|
@ -679,14 +676,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
|
||||
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.13.3+wasi-0.2.2",
|
||||
"windows-targets",
|
||||
"r-efi",
|
||||
"wasi 0.14.2+wasi-0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -707,9 +704,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
|||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.4.1"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
|
||||
checksum = "7db2ff139bba50379da6aa0766b52fdcb62cb5b263009b09ed58ba604e14bbd1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
|
|
@ -729,9 +726,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.4.0"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"
|
||||
checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e"
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
|
|
@ -741,9 +738,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
|||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.5"
|
||||
version = "0.25.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b"
|
||||
checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder-lite",
|
||||
|
|
@ -780,9 +777,9 @@ checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
|
|||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.7.1"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
|
||||
checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
|
|
@ -801,9 +798,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.15"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
|
||||
checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
|
|
@ -851,9 +848,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.14"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
|
|
@ -894,9 +891,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.169"
|
||||
version = "0.2.171"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
||||
|
||||
[[package]]
|
||||
name = "libfuzzer-sys"
|
||||
|
|
@ -910,15 +907,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.25"
|
||||
version = "0.4.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
|
||||
[[package]]
|
||||
name = "loop9"
|
||||
|
|
@ -971,7 +968,7 @@ dependencies = [
|
|||
"terminal_size",
|
||||
"textwrap",
|
||||
"thiserror",
|
||||
"unicode-width",
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -993,9 +990,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b"
|
||||
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
|
|
@ -1100,15 +1097,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.3"
|
||||
version = "1.21.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
|
||||
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
|
||||
|
||||
[[package]]
|
||||
name = "oorandom"
|
||||
version = "11.1.4"
|
||||
version = "11.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"
|
||||
checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
|
|
@ -1118,9 +1115,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
|||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "4.1.0"
|
||||
version = "4.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56"
|
||||
checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
|
|
@ -1146,9 +1143,9 @@ checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
|||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.31"
|
||||
version = "0.3.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||
|
||||
[[package]]
|
||||
name = "plotters"
|
||||
|
|
@ -1193,18 +1190,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.20"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy 0.7.35",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.2.29"
|
||||
version = "0.2.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac"
|
||||
checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
|
|
@ -1212,9 +1209,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.93"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
||||
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
@ -1246,7 +1243,7 @@ checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50"
|
|||
dependencies = [
|
||||
"bit-set",
|
||||
"bit-vec",
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.0",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"rand 0.8.5",
|
||||
|
|
@ -1344,13 +1341,19 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.38"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
|
|
@ -1369,8 +1372,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.1",
|
||||
"zerocopy 0.8.20",
|
||||
"rand_core 0.9.3",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1390,7 +1393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.1",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1404,12 +1407,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.1"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a88e0da7a2c97baa202165137c158d0a2e824ac465d13d81046727b34cb247d3"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom 0.3.1",
|
||||
"zerocopy 0.8.20",
|
||||
"getrandom 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1549,11 +1551,11 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
|||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.0",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
|
|
@ -1562,9 +1564,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.19"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
||||
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
||||
|
||||
[[package]]
|
||||
name = "rusty-fork"
|
||||
|
|
@ -1580,9 +1582,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.19"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
|
|
@ -1595,18 +1597,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.218"
|
||||
version = "1.0.219"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
|
||||
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.218"
|
||||
version = "1.0.219"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
|
||||
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -1615,9 +1617,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.139"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
|
|
@ -1712,9 +1714,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.98"
|
||||
version = "2.0.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
||||
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -1742,13 +1744,12 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.17.1"
|
||||
version = "3.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230"
|
||||
checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"getrandom 0.3.1",
|
||||
"getrandom 0.3.2",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
|
|
@ -1765,9 +1766,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9"
|
||||
checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed"
|
||||
dependencies = [
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
|
|
@ -1775,12 +1776,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.1"
|
||||
version = "0.16.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"
|
||||
checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
|
||||
dependencies = [
|
||||
"unicode-linebreak",
|
||||
"unicode-width",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1914,7 +1915,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "tracing-perfetto"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.he-li.dev/hal8174/tracing-perfetto.git#349c0e688c5701dd89f95819e05b1552615d747b"
|
||||
source = "git+https://git.he-li.dev/hal8174/tracing-perfetto.git#dc8afb0cacb439f38500c470791aef56be98073b"
|
||||
dependencies = [
|
||||
"prost",
|
||||
"prost-build",
|
||||
|
|
@ -1948,9 +1949,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"
|
|||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.17"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-linebreak"
|
||||
|
|
@ -1964,6 +1965,12 @@ version = "0.1.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.11"
|
||||
|
|
@ -2026,9 +2033,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.13.3+wasi-0.2.2"
|
||||
version = "0.14.2+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
|
||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
|
@ -2213,57 +2220,36 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.3"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1"
|
||||
checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.33.0"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bitflags 2.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
version = "0.8.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive 0.7.35",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c"
|
||||
dependencies = [
|
||||
"zerocopy-derive 0.8.20",
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.35"
|
||||
version = "0.8.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700"
|
||||
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ factorio-pathfinding = { path = "../factorio-pathfinding" }
|
|||
factorio-layout = { path = "../factorio-layout" }
|
||||
factorio-core = { path = "../factorio-core" }
|
||||
factorio-blueprint = { path = "../factorio-blueprint" }
|
||||
factorio-graph = { path = "../factorio-graph" }
|
||||
serde = { version = "1.0.192", features = ["derive"] }
|
||||
serde_json = "1.0.135"
|
||||
serde_yaml = "0.9.34"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
use clap::Parser;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use factorio_blueprint::{BlueprintString, encode};
|
||||
use factorio_blueprint_generator::factory::{FactoryGraph, generate_factory};
|
||||
use factorio_core::{prelude::*, visualize::Visualize};
|
||||
use factorio_layout::{genetic_algorithm_v1::GeneticAlgorithm, valid_layout::ValidLayout};
|
||||
use factorio_pathfinding::belt_finding::ConflictAvoidance;
|
||||
use factorio_graph::{
|
||||
priority_queue::{
|
||||
PriorityQueue,
|
||||
binary_heap::{BinaryHeap, FastBinaryHeap},
|
||||
},
|
||||
wheighted_graph::shortest_path::QueueObject,
|
||||
};
|
||||
use factorio_layout::{
|
||||
Layouter, genetic_algorithm_v1::GeneticAlgorithm, valid_layout::ValidLayout,
|
||||
};
|
||||
use factorio_pathfinding::{Pathfinder, belt_finding::ConflictAvoidance};
|
||||
use rand::{SeedableRng, rngs::SmallRng};
|
||||
use std::path::PathBuf;
|
||||
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
|
|
@ -15,19 +25,42 @@ struct Args {
|
|||
json: bool,
|
||||
|
||||
path: PathBuf,
|
||||
|
||||
#[arg(short, long, default_value = "none")]
|
||||
tracing: Tracing,
|
||||
|
||||
#[arg(long, default_value = "ca-fbh")]
|
||||
pathfinder: PathfinderArg,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Clone, Copy)]
|
||||
enum Tracing {
|
||||
Perfetto,
|
||||
Stdio,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Clone, Copy)]
|
||||
enum PathfinderArg {
|
||||
CaFbh,
|
||||
CaBh,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
// tracing_subscriber::fmt::fmt()
|
||||
// .with_env_filter(EnvFilter::from_default_env())
|
||||
// .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
|
||||
// .init();
|
||||
// tracing_perfetto::install_perfetto_subscriber();
|
||||
|
||||
let text = std::fs::File::open(&args.path).unwrap();
|
||||
let factory_graph: FactoryGraph = serde_yaml::from_reader(text).unwrap();
|
||||
match args.tracing {
|
||||
Tracing::Stdio => {
|
||||
tracing_subscriber::fmt::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
|
||||
.init();
|
||||
}
|
||||
Tracing::Perfetto => {
|
||||
tracing_perfetto::install_perfetto_subscriber();
|
||||
}
|
||||
Tracing::None => (),
|
||||
}
|
||||
|
||||
// dbg!(&factory_graph);
|
||||
|
||||
|
|
@ -40,16 +73,49 @@ fn main() {
|
|||
|
||||
let l = GeneticAlgorithm {
|
||||
mutation_retries: 20,
|
||||
population_size: 10,
|
||||
population_size: 6,
|
||||
population_keep: 2,
|
||||
population_new: 2,
|
||||
generations: 4,
|
||||
generations: 2,
|
||||
valid_layout: l,
|
||||
};
|
||||
|
||||
execute_without_pathfinder::<_>(args, l);
|
||||
}
|
||||
|
||||
fn execute_without_pathfinder<L>(args: Args, l: L)
|
||||
where
|
||||
L: Layouter,
|
||||
{
|
||||
match args.pathfinder {
|
||||
PathfinderArg::CaFbh => {
|
||||
let p = ConflictAvoidance {
|
||||
timeout: Some(std::time::Duration::from_millis(100)),
|
||||
priority_queue: std::marker::PhantomData::<
|
||||
FastBinaryHeap<QueueObject<(Position, Direction)>>,
|
||||
>,
|
||||
};
|
||||
execute::<_, _>(args, l, p);
|
||||
}
|
||||
PathfinderArg::CaBh => {
|
||||
let p = ConflictAvoidance {
|
||||
timeout: Some(std::time::Duration::from_millis(100)),
|
||||
priority_queue: std::marker::PhantomData::<
|
||||
BinaryHeap<QueueObject<(Position, Direction)>>,
|
||||
>,
|
||||
};
|
||||
execute::<_, _>(args, l, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn execute<L, P>(args: Args, l: L, p: P)
|
||||
where
|
||||
P: Pathfinder + Sync,
|
||||
L: Layouter,
|
||||
{
|
||||
let text = std::fs::File::open(&args.path).unwrap();
|
||||
let factory_graph: FactoryGraph = serde_yaml::from_reader(text).unwrap();
|
||||
let mut rng = SmallRng::seed_from_u64(args.seed);
|
||||
|
||||
let b = generate_factory(&l, &p, factory_graph, &mut rng);
|
||||
|
|
|
|||
|
|
@ -12,3 +12,4 @@ clap = { version = "4.5.26", features = ["derive"] }
|
|||
serde = "1.0.217"
|
||||
serde_json = "1.0.135"
|
||||
flate2 = "1.0.35"
|
||||
tracing = "0.1.41"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use factorio_graph::{
|
|||
priority_queue::binary_heap::FastBinaryHeap,
|
||||
wheighted_graph::{WheightedGraph, shortest_path::dijkstra, steiner_tree},
|
||||
};
|
||||
use tracing::trace_span;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
@ -112,6 +113,7 @@ fn power_connections(
|
|||
|
||||
impl Blueprint {
|
||||
pub fn connect_power_networks(&mut self) {
|
||||
let _complete_span = trace_span!("connect power networks").entered();
|
||||
let mut power_pole_map = self
|
||||
.entities
|
||||
.iter()
|
||||
|
|
@ -246,6 +248,7 @@ where
|
|||
|
||||
impl Blueprint {
|
||||
pub fn connect_roboport_power(&mut self) {
|
||||
let _complete_span = trace_span!("connect roboport power").entered();
|
||||
let mut roboportmap = self
|
||||
.entities
|
||||
.iter()
|
||||
|
|
@ -287,8 +290,8 @@ impl Blueprint {
|
|||
{
|
||||
let placibility = self.placibility_map();
|
||||
for (electric_pole_type, dist) in [
|
||||
(ElectricPoleType::Small, 9),
|
||||
(ElectricPoleType::Medium, 11),
|
||||
(ElectricPoleType::Small, 7),
|
||||
(ElectricPoleType::Medium, 9),
|
||||
(ElectricPoleType::Big, 6),
|
||||
] {
|
||||
for (x, y) in
|
||||
|
|
@ -314,6 +317,7 @@ impl Blueprint {
|
|||
let mut visited_roboports = vec![start_roboport];
|
||||
|
||||
while !roboportmap.is_empty() {
|
||||
let _inner = trace_span!("inner").entered();
|
||||
let placibility = self.placibility_map();
|
||||
let mut power_pole_map = self
|
||||
.entities
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use factorio_graph::{
|
|||
priority_queue::binary_heap::FastBinaryHeap,
|
||||
set_cover::{greedy_connected_set_cover_priority_queue, greedy_set_cover_priority_queue},
|
||||
};
|
||||
use tracing::trace_span;
|
||||
|
||||
use crate::abstraction::Entity;
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ impl Graph for RoboportGraph<'_> {
|
|||
|
||||
impl Blueprint {
|
||||
pub fn add_roboport_network(&mut self) {
|
||||
let _complete_span = trace_span!("roboport_network").entered();
|
||||
let aabb = self.get_aabb().unwrap();
|
||||
|
||||
let universe = self.entities.len();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use std::ops::Deref;
|
||||
|
||||
use tracing::trace_span;
|
||||
|
||||
use crate::{graph::Graph, priority_queue::PriorityQueue};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -130,6 +132,7 @@ where
|
|||
G: Graph<Node = usize>,
|
||||
P: PriorityQueue<SetUncovered>,
|
||||
{
|
||||
let _complete_span = trace_span!("greedy connectd set cover").entered();
|
||||
let mut covered = vec![false; universe];
|
||||
let mut covered_count = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,13 @@ where
|
|||
G: WheightedGraph,
|
||||
E: Fn(&'_ G::Node) -> bool,
|
||||
{
|
||||
let span = trace_span!("graph", seen_nodes = Empty, visited_nodes = Empty).entered();
|
||||
let span = trace_span!(
|
||||
"dijkstra",
|
||||
insert_count = Empty,
|
||||
pop_min_count = Empty,
|
||||
decrease_key_count = Empty,
|
||||
)
|
||||
.entered();
|
||||
if end(&start) {
|
||||
return Some(vec![start]);
|
||||
}
|
||||
|
|
@ -74,11 +80,12 @@ where
|
|||
let mut q = P::new();
|
||||
q.insert(QueueObject::new(start.clone(), 0));
|
||||
|
||||
let mut visited_nodes: usize = 1;
|
||||
let mut pop_min_count: usize = 0;
|
||||
let mut decrease_key_count: usize = 0;
|
||||
|
||||
let mut end_node = None;
|
||||
while let Some(o) = q.pop_min() {
|
||||
visited_nodes += 1;
|
||||
pop_min_count += 1;
|
||||
if let Some(m) = map.get_mut(&o.node) {
|
||||
m.key = None;
|
||||
}
|
||||
|
|
@ -93,6 +100,7 @@ where
|
|||
if let Some(n) = map.get_mut(&node) {
|
||||
if let Some(h) = &n.key {
|
||||
if score < n.score {
|
||||
decrease_key_count += 1;
|
||||
n.parent = o.node.clone();
|
||||
n.score = score;
|
||||
q.decrease_key(h, |i| i.score = score);
|
||||
|
|
@ -106,8 +114,9 @@ where
|
|||
// dbg!(&q);
|
||||
}
|
||||
|
||||
span.record("seen_nodes", map.len());
|
||||
span.record("visited_nodes", visited_nodes);
|
||||
span.record("insert_count", map.len());
|
||||
span.record("pop_min_count", pop_min_count);
|
||||
span.record("decrease_key_count", decrease_key_count);
|
||||
|
||||
if let Some(end_node) = end_node {
|
||||
map.get(&end_node)?;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use tracing::trace_span;
|
||||
|
||||
use crate::priority_queue::PriorityQueue;
|
||||
use std::hash::Hash;
|
||||
use std::{collections::HashSet, fmt::Debug};
|
||||
|
|
@ -35,6 +37,7 @@ where
|
|||
G::Node: Eq + Hash + Clone + Debug,
|
||||
G: WheightedGraph,
|
||||
{
|
||||
let _complete_span = trace_span!("takaheshi_matsuyama").entered();
|
||||
if nodes.is_empty() {
|
||||
return Some(Vec::new());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ edition = "2024"
|
|||
[dependencies]
|
||||
factorio-core = { path = "../factorio-core" }
|
||||
factorio-pathfinding = { path = "../factorio-pathfinding" }
|
||||
factorio-graph = { path = "../factorio-graph" }
|
||||
rand = { version = "0.9.0", features = ["small_rng"] }
|
||||
serde = { version = "1.0.192", features = ["derive"] }
|
||||
image = "0.25.2"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use factorio_core::prelude::Position;
|
||||
use factorio_core::prelude::{Direction, Position};
|
||||
use factorio_graph::{
|
||||
priority_queue::binary_heap::FastBinaryHeap, wheighted_graph::shortest_path::QueueObject,
|
||||
};
|
||||
use factorio_layout::{Layouter, valid_layout::ValidLayout};
|
||||
use factorio_pathfinding::belt_finding::ConflictAvoidance;
|
||||
use rand::{SeedableRng, rngs::SmallRng};
|
||||
|
|
@ -32,6 +35,9 @@ fn main() {
|
|||
|
||||
let p = ConflictAvoidance {
|
||||
timeout: Some(std::time::Duration::from_millis(5)),
|
||||
priority_queue: std::marker::PhantomData::<
|
||||
FastBinaryHeap<QueueObject<(Position, Direction)>>,
|
||||
>,
|
||||
};
|
||||
|
||||
let mut rng = SmallRng::seed_from_u64(args.seed);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ use factorio_core::{
|
|||
prelude::*,
|
||||
visualize::{Color, Symbol, Visualization, Visualize, image_grid},
|
||||
};
|
||||
use factorio_graph::priority_queue::binary_heap::FastBinaryHeap;
|
||||
use factorio_pathfinding::belt_finding::{self, conflict_avoidance::ConflictAvoidance};
|
||||
use rand::{
|
||||
Rng,
|
||||
seq::IndexedRandom,
|
||||
};
|
||||
use rand::{Rng, seq::IndexedRandom};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{sync::atomic::AtomicU32, time::Instant};
|
||||
|
||||
|
|
@ -241,7 +239,7 @@ impl<'a> PathLayout<'a> {
|
|||
pub fn new(layout: Layout<'a>) -> Option<PathLayout<'a>> {
|
||||
let mut p = beltfinding_problem_from_layout(&layout);
|
||||
|
||||
if !p.find_path() {
|
||||
if !p.find_path::<FastBinaryHeap<_>>() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::Connection;
|
||||
use crate::Map as _;
|
||||
use crate::SinglePathInput;
|
||||
|
|
@ -5,8 +7,9 @@ use crate::SinglePathfinder;
|
|||
use crate::examples::HashMapMap;
|
||||
use factorio_core::misc::Map;
|
||||
use factorio_core::{prelude::*, visualize::Visualize};
|
||||
use factorio_graph::priority_queue::binary_heap::FastBinaryHeap;
|
||||
use factorio_graph::priority_queue::PriorityQueue;
|
||||
use factorio_graph::wheighted_graph::WheightedGraph;
|
||||
use factorio_graph::wheighted_graph::shortest_path::QueueObject;
|
||||
use factorio_graph::wheighted_graph::shortest_path::a_star;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::Level;
|
||||
|
|
@ -16,11 +19,16 @@ pub mod brute_force;
|
|||
|
||||
pub mod conflict_avoidance;
|
||||
|
||||
pub struct ConflictAvoidance {
|
||||
pub struct ConflictAvoidance<P> {
|
||||
pub timeout: Option<std::time::Duration>,
|
||||
pub priority_queue: PhantomData<P>,
|
||||
}
|
||||
|
||||
impl SinglePathfinder for ConflictAvoidance {
|
||||
impl<P> SinglePathfinder for ConflictAvoidance<P>
|
||||
where
|
||||
P: PriorityQueue<QueueObject<(Position, Direction)>> + std::fmt::Debug,
|
||||
P::Handle: std::fmt::Debug,
|
||||
{
|
||||
fn find_paths<M: crate::Map>(
|
||||
&self,
|
||||
input: SinglePathInput<M>,
|
||||
|
|
@ -47,7 +55,7 @@ impl SinglePathfinder for ConflictAvoidance {
|
|||
|
||||
// p.print_visualization();
|
||||
|
||||
if p.find_path() {
|
||||
if p.find_path::<P>() {
|
||||
let mut c = conflict_avoidance::ConflictAvoidance::new(&p);
|
||||
// c.print_visualization();
|
||||
|
||||
|
|
@ -270,7 +278,11 @@ impl WheightedGraph for MapInternal<'_> {
|
|||
}
|
||||
|
||||
impl Problem {
|
||||
pub fn find_path(&mut self) -> bool {
|
||||
pub fn find_path<P>(&mut self) -> bool
|
||||
where
|
||||
P: PriorityQueue<QueueObject<(Position, Direction)>> + std::fmt::Debug,
|
||||
P::Handle: std::fmt::Debug,
|
||||
{
|
||||
let _span = span!(Level::TRACE, "find_path").entered();
|
||||
for i in 0..self.start.len() {
|
||||
self.calculate_wheights(i);
|
||||
|
|
@ -280,7 +292,7 @@ impl Problem {
|
|||
};
|
||||
let p = {
|
||||
// dijkstra::<MapInternal, FastBinaryHeap<_>>(&m, self.start[i], self.end[i])
|
||||
a_star::<MapInternal, FastBinaryHeap<_>, _, _>(
|
||||
a_star::<MapInternal, P, _, _>(
|
||||
&m,
|
||||
self.start[i],
|
||||
|&n| n == self.end[i],
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
use factorio_blueprint::{encode, Blueprint, BlueprintString};
|
||||
use factorio_blueprint::{Blueprint, BlueprintString, encode};
|
||||
use factorio_core::{beltoptions::Beltspeed, visualize::Visualize};
|
||||
use factorio_graph::priority_queue::binary_heap::FastBinaryHeap;
|
||||
use factorio_pathfinding::{
|
||||
belt_finding::{conflict_avoidance::ConflictAvoidance, Problem},
|
||||
belt_finding::{Problem, conflict_avoidance::ConflictAvoidance},
|
||||
examples,
|
||||
};
|
||||
use std::{io, path::PathBuf};
|
||||
|
|
@ -70,14 +71,14 @@ fn main() {
|
|||
match args.mode {
|
||||
Mode::Solve => {
|
||||
p.print_visualization();
|
||||
p.find_path();
|
||||
p.find_path::<FastBinaryHeap<_>>();
|
||||
p.print_visualization();
|
||||
}
|
||||
Mode::ConflictAvoidance => {
|
||||
p.print_visualization();
|
||||
p.find_path();
|
||||
p.find_path::<FastBinaryHeap<_>>();
|
||||
p.print_visualization();
|
||||
p.find_path();
|
||||
p.find_path::<FastBinaryHeap<_>>();
|
||||
p.print_visualization();
|
||||
let mut c = ConflictAvoidance::new(&p);
|
||||
c.print_visualization();
|
||||
|
|
@ -88,7 +89,7 @@ fn main() {
|
|||
}
|
||||
Mode::ConflictStep => {
|
||||
p.print_visualization();
|
||||
p.find_path();
|
||||
p.find_path::<FastBinaryHeap<_>>();
|
||||
p.print_visualization();
|
||||
let mut c = ConflictAvoidance::new(&p);
|
||||
c.print_visualization();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue