Replace the local implementation of 2d geometry by lowdim
This also forces an update of the rand dependency, so while we are at it we update all the dependencies.
This commit is contained in:
		
							
								
								
									
										516
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										516
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -1,207 +1,499 @@
 | 
			
		||||
# This file is automatically @generated by Cargo.
 | 
			
		||||
# It is not intended for manual editing.
 | 
			
		||||
version = 3
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "bitflags"
 | 
			
		||||
version = "1.0.4"
 | 
			
		||||
name = "android_system_properties"
 | 
			
		||||
version = "0.1.5"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "libc",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "autocfg"
 | 
			
		||||
version = "1.1.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "bumpalo"
 | 
			
		||||
version = "3.12.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cc"
 | 
			
		||||
version = "1.0.79"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cfg-if"
 | 
			
		||||
version = "1.0.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "chrono"
 | 
			
		||||
version = "0.4.6"
 | 
			
		||||
version = "0.4.24"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "iana-time-zone",
 | 
			
		||||
 "js-sys",
 | 
			
		||||
 "num-integer",
 | 
			
		||||
 "num-traits",
 | 
			
		||||
 "time",
 | 
			
		||||
 "wasm-bindgen",
 | 
			
		||||
 "winapi",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cloudabi"
 | 
			
		||||
version = "0.0.3"
 | 
			
		||||
name = "codespan-reporting"
 | 
			
		||||
version = "0.11.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "termcolor",
 | 
			
		||||
 "unicode-width",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "fuchsia-zircon"
 | 
			
		||||
version = "0.3.3"
 | 
			
		||||
name = "core-foundation-sys"
 | 
			
		||||
version = "0.8.4"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cxx"
 | 
			
		||||
version = "1.0.94"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "cc",
 | 
			
		||||
 "cxxbridge-flags",
 | 
			
		||||
 "cxxbridge-macro",
 | 
			
		||||
 "link-cplusplus",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "fuchsia-zircon-sys"
 | 
			
		||||
version = "0.3.3"
 | 
			
		||||
name = "cxx-build"
 | 
			
		||||
version = "1.0.94"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cc",
 | 
			
		||||
 "codespan-reporting",
 | 
			
		||||
 "once_cell",
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "scratch",
 | 
			
		||||
 "syn 2.0.13",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cxxbridge-flags"
 | 
			
		||||
version = "1.0.94"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cxxbridge-macro"
 | 
			
		||||
version = "1.0.94"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "syn 2.0.13",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "getrandom"
 | 
			
		||||
version = "0.2.9"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cfg-if",
 | 
			
		||||
 "libc",
 | 
			
		||||
 "wasi 0.11.0+wasi-snapshot-preview1",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "iana-time-zone"
 | 
			
		||||
version = "0.1.56"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "android_system_properties",
 | 
			
		||||
 "core-foundation-sys",
 | 
			
		||||
 "iana-time-zone-haiku",
 | 
			
		||||
 "js-sys",
 | 
			
		||||
 "wasm-bindgen",
 | 
			
		||||
 "windows",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "iana-time-zone-haiku"
 | 
			
		||||
version = "0.1.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cxx",
 | 
			
		||||
 "cxx-build",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "js-sys"
 | 
			
		||||
version = "0.3.61"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "wasm-bindgen",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "libc"
 | 
			
		||||
version = "0.2.44"
 | 
			
		||||
version = "0.2.141"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "link-cplusplus"
 | 
			
		||||
version = "1.0.8"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cc",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "log"
 | 
			
		||||
version = "0.4.17"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cfg-if",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "lowdim"
 | 
			
		||||
version = "0.6.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "014a69d87fffff8f5facec9e56f7dc470399448dc8ceed0dbc61032d6651039d"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "rand",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "num-integer"
 | 
			
		||||
version = "0.1.39"
 | 
			
		||||
version = "0.1.45"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "autocfg",
 | 
			
		||||
 "num-traits",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "num-traits"
 | 
			
		||||
version = "0.2.6"
 | 
			
		||||
version = "0.2.15"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "autocfg",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "once_cell"
 | 
			
		||||
version = "1.17.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "pixelfoo"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
version = "0.2.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "lowdim",
 | 
			
		||||
 "rand",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "ppv-lite86"
 | 
			
		||||
version = "0.2.17"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "proc-macro2"
 | 
			
		||||
version = "1.0.56"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "unicode-ident",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "quote"
 | 
			
		||||
version = "1.0.26"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand"
 | 
			
		||||
version = "0.6.1"
 | 
			
		||||
version = "0.8.5"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "libc",
 | 
			
		||||
 "rand_chacha",
 | 
			
		||||
 "rand_core",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand_chacha"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
version = "0.3.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "ppv-lite86",
 | 
			
		||||
 "rand_core",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand_core"
 | 
			
		||||
version = "0.3.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand_hc"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
version = "0.6.4"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "getrandom",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand_isaac"
 | 
			
		||||
version = "0.1.1"
 | 
			
		||||
name = "scratch"
 | 
			
		||||
version = "1.0.5"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "syn"
 | 
			
		||||
version = "1.0.109"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "unicode-ident",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand_pcg"
 | 
			
		||||
version = "0.1.1"
 | 
			
		||||
name = "syn"
 | 
			
		||||
version = "2.0.13"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "unicode-ident",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rand_xorshift"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
name = "termcolor"
 | 
			
		||||
version = "1.2.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "winapi-util",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "redox_syscall"
 | 
			
		||||
version = "0.1.43"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "rustc_version"
 | 
			
		||||
version = "0.2.3"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "semver"
 | 
			
		||||
version = "0.9.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "semver-parser"
 | 
			
		||||
version = "0.7.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "time"
 | 
			
		||||
version = "0.1.40"
 | 
			
		||||
version = "0.1.45"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "libc",
 | 
			
		||||
 "wasi 0.10.0+wasi-snapshot-preview1",
 | 
			
		||||
 "winapi",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "winapi"
 | 
			
		||||
version = "0.3.6"
 | 
			
		||||
name = "unicode-ident"
 | 
			
		||||
version = "1.0.8"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "unicode-width"
 | 
			
		||||
version = "0.1.10"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasi"
 | 
			
		||||
version = "0.10.0+wasi-snapshot-preview1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasi"
 | 
			
		||||
version = "0.11.0+wasi-snapshot-preview1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen"
 | 
			
		||||
version = "0.2.84"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "cfg-if",
 | 
			
		||||
 "wasm-bindgen-macro",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-backend"
 | 
			
		||||
version = "0.2.84"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "bumpalo",
 | 
			
		||||
 "log",
 | 
			
		||||
 "once_cell",
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "syn 1.0.109",
 | 
			
		||||
 "wasm-bindgen-shared",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-macro"
 | 
			
		||||
version = "0.2.84"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "quote",
 | 
			
		||||
 "wasm-bindgen-macro-support",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-macro-support"
 | 
			
		||||
version = "0.2.84"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "syn 1.0.109",
 | 
			
		||||
 "wasm-bindgen-backend",
 | 
			
		||||
 "wasm-bindgen-shared",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-shared"
 | 
			
		||||
version = "0.2.84"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "winapi"
 | 
			
		||||
version = "0.3.9"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "winapi-i686-pc-windows-gnu",
 | 
			
		||||
 "winapi-x86_64-pc-windows-gnu",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "winapi-i686-pc-windows-gnu"
 | 
			
		||||
version = "0.4.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "winapi-util"
 | 
			
		||||
version = "0.1.5"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "winapi",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "winapi-x86_64-pc-windows-gnu"
 | 
			
		||||
version = "0.4.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 | 
			
		||||
 | 
			
		||||
[metadata]
 | 
			
		||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
 | 
			
		||||
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
 | 
			
		||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
 | 
			
		||||
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
 | 
			
		||||
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
 | 
			
		||||
"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311"
 | 
			
		||||
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
 | 
			
		||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
 | 
			
		||||
"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a"
 | 
			
		||||
"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
 | 
			
		||||
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
 | 
			
		||||
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
 | 
			
		||||
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
 | 
			
		||||
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
 | 
			
		||||
"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3"
 | 
			
		||||
"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d"
 | 
			
		||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
 | 
			
		||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
 | 
			
		||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
 | 
			
		||||
"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b"
 | 
			
		||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
 | 
			
		||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
 | 
			
		||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "windows-targets",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows-targets"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "windows_aarch64_gnullvm",
 | 
			
		||||
 "windows_aarch64_msvc",
 | 
			
		||||
 "windows_i686_gnu",
 | 
			
		||||
 "windows_i686_msvc",
 | 
			
		||||
 "windows_x86_64_gnu",
 | 
			
		||||
 "windows_x86_64_gnullvm",
 | 
			
		||||
 "windows_x86_64_msvc",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_aarch64_gnullvm"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_aarch64_msvc"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_i686_gnu"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_i686_msvc"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_x86_64_gnu"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_x86_64_gnullvm"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows_x86_64_msvc"
 | 
			
		||||
version = "0.48.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "pixelfoo"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
version = "0.2.0"
 | 
			
		||||
authors = ["juergen <juergen@chaospott.de>"]
 | 
			
		||||
edition = "2018"
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
rand = "0.6.0"
 | 
			
		||||
rand = "0.8.4"
 | 
			
		||||
chrono = "0.4.6"
 | 
			
		||||
lowdim = { version = "0.6.0", features = ["random"] }
 | 
			
		||||
 
 | 
			
		||||
@@ -56,8 +56,8 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
    .take(y_size)
 | 
			
		||||
    .collect::<Vec<_>>();
 | 
			
		||||
    loop {
 | 
			
		||||
        let x = rng.gen_range(0, x_size);
 | 
			
		||||
        let y = rng.gen_range(0, y_size);
 | 
			
		||||
        let x = rng.gen_range(0..x_size);
 | 
			
		||||
        let y = rng.gen_range(0..y_size);
 | 
			
		||||
        let c = pick_color(c0, c1, &mut rng);
 | 
			
		||||
        frame[y][x] = c;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,11 +12,16 @@ use chrono::Timelike;
 | 
			
		||||
use rand::thread_rng;
 | 
			
		||||
use rand::Rng;
 | 
			
		||||
 | 
			
		||||
use lowdim::bb2d;
 | 
			
		||||
use lowdim::p2d;
 | 
			
		||||
use lowdim::v2d;
 | 
			
		||||
use lowdim::Array2d;
 | 
			
		||||
use lowdim::BBox2d;
 | 
			
		||||
use lowdim::Point2d;
 | 
			
		||||
use lowdim::Vec2d;
 | 
			
		||||
use lowdim::Vector;
 | 
			
		||||
 | 
			
		||||
use pixelfoo::color::Color;
 | 
			
		||||
use pixelfoo::point2d::p2d;
 | 
			
		||||
use pixelfoo::point2d::Point2d;
 | 
			
		||||
use pixelfoo::vec2d::v2d;
 | 
			
		||||
use pixelfoo::vec2d::Vec2d;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
 | 
			
		||||
enum Square {
 | 
			
		||||
@@ -37,17 +42,24 @@ impl Square {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Board(Vec<Vec<Square>>);
 | 
			
		||||
#[derive(Clone, Debug)]
 | 
			
		||||
struct Board(Array2d<i64, Square>);
 | 
			
		||||
impl Board {
 | 
			
		||||
    fn bbox(&self) -> BBox2d {
 | 
			
		||||
        self.0.bbox()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn send<T: Write>(w: &mut T, board: &Board) -> std::io::Result<()> {
 | 
			
		||||
    for line in &board.0 {
 | 
			
		||||
        for square in line {
 | 
			
		||||
    for y in board.bbox().y_range() {
 | 
			
		||||
        for x in board.bbox().x_range() {
 | 
			
		||||
            let square = board.0[p2d(x, y)];
 | 
			
		||||
            let c = match square {
 | 
			
		||||
                Square::Unused => Color::black(),
 | 
			
		||||
                Square::Unknown { prio } => {
 | 
			
		||||
                    if *prio == 0 {
 | 
			
		||||
                    if prio == 0 {
 | 
			
		||||
                        Color::black()
 | 
			
		||||
                    } else if *prio > 0 {
 | 
			
		||||
                    } else if prio > 0 {
 | 
			
		||||
                        Color::lightblue()
 | 
			
		||||
                    } else {
 | 
			
		||||
                        Color::darkyellow()
 | 
			
		||||
@@ -71,35 +83,32 @@ enum Orientation {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Board {
 | 
			
		||||
    fn new(board_size: Vec2d, maze_size: Vec2d) -> Board {
 | 
			
		||||
        Board(
 | 
			
		||||
            (0..board_size.y)
 | 
			
		||||
                .map(move |y| {
 | 
			
		||||
                    (0..board_size.x)
 | 
			
		||||
                        .map(|x| {
 | 
			
		||||
                            if x < maze_size.x && y < maze_size.y {
 | 
			
		||||
                                if x == 0 || x == maze_size.x - 1 || y == 0 || y == maze_size.y - 1
 | 
			
		||||
                                {
 | 
			
		||||
                                    Square::Wall
 | 
			
		||||
                                } else if x % 2 != 0 && y % 2 != 0 {
 | 
			
		||||
                                    Square::Corridor
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    Square::Unknown { prio: 0 }
 | 
			
		||||
                                }
 | 
			
		||||
                            } else {
 | 
			
		||||
                                Square::Unused
 | 
			
		||||
                            }
 | 
			
		||||
                        })
 | 
			
		||||
                        .collect::<Vec<_>>()
 | 
			
		||||
                })
 | 
			
		||||
                .collect::<Vec<_>>(),
 | 
			
		||||
        )
 | 
			
		||||
    fn new(board_bbox: BBox2d, maze_bbox: BBox2d) -> Board {
 | 
			
		||||
        Board(Array2d::with(board_bbox, |p| {
 | 
			
		||||
            if maze_bbox.contains(&p) {
 | 
			
		||||
                let x = p.x();
 | 
			
		||||
                let y = p.y();
 | 
			
		||||
                if x == maze_bbox.x_min()
 | 
			
		||||
                    || x == maze_bbox.x_max()
 | 
			
		||||
                    || y == maze_bbox.y_min()
 | 
			
		||||
                    || y == maze_bbox.y_max()
 | 
			
		||||
                {
 | 
			
		||||
                    Square::Wall
 | 
			
		||||
                } else if x % 2 != 0 && y % 2 != 0 {
 | 
			
		||||
                    Square::Corridor
 | 
			
		||||
                } else {
 | 
			
		||||
                    Square::Unknown { prio: 0 }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                Square::Unused
 | 
			
		||||
            }
 | 
			
		||||
        }))
 | 
			
		||||
    }
 | 
			
		||||
    fn get(&self, pos: Point2d) -> Square {
 | 
			
		||||
        self.0[pos.y as usize][pos.x as usize]
 | 
			
		||||
        self.0[pos]
 | 
			
		||||
    }
 | 
			
		||||
    fn set(&mut self, pos: Point2d, sq: Square) {
 | 
			
		||||
        self.0[pos.y as usize][pos.x as usize] = sq;
 | 
			
		||||
        self.0[pos] = sq;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn set_orientation(&mut self, desired: Orientation, pos: Point2d) {
 | 
			
		||||
@@ -107,14 +116,14 @@ impl Board {
 | 
			
		||||
        match sq {
 | 
			
		||||
            Square::Unknown { .. } => {
 | 
			
		||||
                let prio;
 | 
			
		||||
                if pos.x % 2 == 0 && pos.y % 2 != 0 {
 | 
			
		||||
                if pos.x() % 2 == 0 && pos.y() % 2 != 0 {
 | 
			
		||||
                    // horizontal corridor, vertical wall
 | 
			
		||||
                    prio = if desired == Orientation::Vertical {
 | 
			
		||||
                        10
 | 
			
		||||
                    } else {
 | 
			
		||||
                        -10
 | 
			
		||||
                    };
 | 
			
		||||
                } else if pos.x % 2 != 0 && pos.y % 2 == 0 {
 | 
			
		||||
                } else if pos.x() % 2 != 0 && pos.y() % 2 == 0 {
 | 
			
		||||
                    // vertical corridor, horizontal wall
 | 
			
		||||
                    prio = if desired == Orientation::Horizontal {
 | 
			
		||||
                        10
 | 
			
		||||
@@ -137,28 +146,28 @@ impl Board {
 | 
			
		||||
        self.set_orientation(Orientation::Vertical, pos);
 | 
			
		||||
    }
 | 
			
		||||
    fn draw_horizontal_segment(&mut self, pos: Point2d, size: Vec2d) {
 | 
			
		||||
        for x in 0..size.x {
 | 
			
		||||
            let xn = size.x - 1 - x;
 | 
			
		||||
        for x in 0..size.x() {
 | 
			
		||||
            let xn = size.x() - 1 - x;
 | 
			
		||||
            self.set_horizontal(pos + v2d(x, 0));
 | 
			
		||||
            for y in 1..x.min(xn).min(size.y / 2) + 1 {
 | 
			
		||||
            for y in 1..x.min(xn).min(size.y() / 2) + 1 {
 | 
			
		||||
                self.set_horizontal(pos + v2d(x, y));
 | 
			
		||||
                self.set_horizontal(pos + v2d(x, -y));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    fn draw_vertical_segment(&mut self, pos: Point2d, size: Vec2d) {
 | 
			
		||||
        for y in 0..size.y {
 | 
			
		||||
            let yn = size.y - 1 - y;
 | 
			
		||||
        for y in 0..size.y() {
 | 
			
		||||
            let yn = size.y() - 1 - y;
 | 
			
		||||
            self.set_vertical(pos + v2d(0, y));
 | 
			
		||||
            for x in 1..y.min(yn).min(size.x / 2) + 1 {
 | 
			
		||||
            for x in 1..y.min(yn).min(size.x() / 2) + 1 {
 | 
			
		||||
                self.set_vertical(pos + v2d(x, y));
 | 
			
		||||
                self.set_vertical(pos + v2d(-x, y));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    fn draw_7_segments(&mut self, pos: Point2d, size: Vec2d, segments: u8) {
 | 
			
		||||
        let length = size.x;
 | 
			
		||||
        let width = size.y;
 | 
			
		||||
        let length = size.x();
 | 
			
		||||
        let width = size.y();
 | 
			
		||||
        let delta = length + 1;
 | 
			
		||||
        let hsize = v2d(length, width);
 | 
			
		||||
        let vsize = v2d(width, length);
 | 
			
		||||
@@ -226,7 +235,7 @@ where
 | 
			
		||||
        open.push(Move {
 | 
			
		||||
            from,
 | 
			
		||||
            dir,
 | 
			
		||||
            prio: prio * 100 + rng.gen_range(0, 1000),
 | 
			
		||||
            prio: prio * 100 + rng.gen_range(0..1000),
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -237,8 +246,8 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
    let args = args().collect::<Vec<_>>();
 | 
			
		||||
    eprintln!("executing {}", args[0]);
 | 
			
		||||
 | 
			
		||||
    let x_size = args[1].parse::<usize>().unwrap();
 | 
			
		||||
    let y_size = args[2].parse::<usize>().unwrap();
 | 
			
		||||
    let x_size = args[1].parse::<i64>().unwrap();
 | 
			
		||||
    let y_size = args[2].parse::<i64>().unwrap();
 | 
			
		||||
    let arg = args[3].parse::<isize>().unwrap_or(DEFAULT_ARG);
 | 
			
		||||
    eprintln!("screen size {}x{}, arg {}", x_size, y_size, arg);
 | 
			
		||||
 | 
			
		||||
@@ -247,14 +256,11 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
    let t_frame = 0.040; // s
 | 
			
		||||
    let delay = Duration::new(0, (1_000_000_000.0 * t_frame) as u32);
 | 
			
		||||
 | 
			
		||||
    let board_size = v2d(x_size as i32, y_size as i32);
 | 
			
		||||
    let board_bbox = bb2d(0..x_size, 0..y_size);
 | 
			
		||||
    // round down to odd size for maze
 | 
			
		||||
    let maze_size = v2d(
 | 
			
		||||
        (board_size.x - 1) / 2 * 2 + 1,
 | 
			
		||||
        (board_size.y - 1) / 2 * 2 + 1,
 | 
			
		||||
    );
 | 
			
		||||
    let maze_bbox = bb2d(0..(x_size - 1) / 2 * 2 + 1, 0..(y_size - 1) / 2 * 2 + 1);
 | 
			
		||||
 | 
			
		||||
    let mut board = Board(Vec::new());
 | 
			
		||||
    let mut board = Board::new(board_bbox, maze_bbox);
 | 
			
		||||
    let mut open = BinaryHeap::new();
 | 
			
		||||
    let mut last_drawn_minute = 99;
 | 
			
		||||
    loop {
 | 
			
		||||
@@ -267,7 +273,7 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
            if m != last_drawn_minute {
 | 
			
		||||
                last_drawn_minute = m;
 | 
			
		||||
 | 
			
		||||
                board = Board::new(board_size, maze_size);
 | 
			
		||||
                board = Board::new(board_bbox, maze_bbox);
 | 
			
		||||
 | 
			
		||||
                // draw time in prios
 | 
			
		||||
                let segment_size = v2d(11, 5);
 | 
			
		||||
@@ -277,23 +283,35 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
                board.draw_digit(p2d(59, 7), segment_size, (m % 10) as u8);
 | 
			
		||||
 | 
			
		||||
                // start building walls from the border
 | 
			
		||||
                for x in (2..(maze_size.x - 2)).step_by(2) {
 | 
			
		||||
                    add_move(&board, &mut open, &mut rng, p2d(x, 0), v2d(0, 1));
 | 
			
		||||
                for x in (2..(maze_bbox.x_max() - 1)).step_by(2) {
 | 
			
		||||
                    add_move(
 | 
			
		||||
                        &board,
 | 
			
		||||
                        &mut open,
 | 
			
		||||
                        &mut rng,
 | 
			
		||||
                        p2d(x, maze_size.y - 1),
 | 
			
		||||
                        p2d(x, maze_bbox.y_min()),
 | 
			
		||||
                        v2d(0, 1),
 | 
			
		||||
                    );
 | 
			
		||||
                    add_move(
 | 
			
		||||
                        &board,
 | 
			
		||||
                        &mut open,
 | 
			
		||||
                        &mut rng,
 | 
			
		||||
                        p2d(x, maze_bbox.y_max()),
 | 
			
		||||
                        v2d(0, -1),
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
                for y in (2..(maze_size.y - 2)).step_by(2) {
 | 
			
		||||
                    add_move(&board, &mut open, &mut rng, p2d(0, y), v2d(1, 0));
 | 
			
		||||
                for y in (2..(maze_bbox.y_max() - 1)).step_by(2) {
 | 
			
		||||
                    add_move(
 | 
			
		||||
                        &board,
 | 
			
		||||
                        &mut open,
 | 
			
		||||
                        &mut rng,
 | 
			
		||||
                        p2d(maze_size.x - 1, y),
 | 
			
		||||
                        p2d(maze_bbox.x_min(), y),
 | 
			
		||||
                        v2d(1, 0),
 | 
			
		||||
                    );
 | 
			
		||||
                    add_move(
 | 
			
		||||
                        &board,
 | 
			
		||||
                        &mut open,
 | 
			
		||||
                        &mut rng,
 | 
			
		||||
                        p2d(maze_bbox.x_max(), y),
 | 
			
		||||
                        v2d(-1, 0),
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
@@ -316,7 +334,7 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
                board.set(p1, Square::Wall);
 | 
			
		||||
                board.set(p2, Square::Wall);
 | 
			
		||||
 | 
			
		||||
                for dir1 in Vec2d::directions() {
 | 
			
		||||
                for dir1 in Vec2d::unit_vecs_l1() {
 | 
			
		||||
                    let p3 = p2 + dir1;
 | 
			
		||||
                    let p4 = p3 + dir1;
 | 
			
		||||
                    if board.get(p3).is_unknown() {
 | 
			
		||||
@@ -332,12 +350,12 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if open.is_empty() {
 | 
			
		||||
                board.set(p2d(1, 1), Square::Start);
 | 
			
		||||
                board.set(p2d(maze_size.x - 2, maze_size.y - 2), Square::Finish);
 | 
			
		||||
                board.set(maze_bbox.min() + v2d(1, 1), Square::Start);
 | 
			
		||||
                board.set(maze_bbox.max() - v2d(1, 1), Square::Finish);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let mut buf = Vec::with_capacity((board_size.x * board_size.y * 3) as usize);
 | 
			
		||||
        let mut buf = Vec::with_capacity(board_bbox.area() * 3);
 | 
			
		||||
        send(&mut buf, &board)?;
 | 
			
		||||
        stdout().write_all(&buf)?;
 | 
			
		||||
        stdout().flush()?;
 | 
			
		||||
 
 | 
			
		||||
@@ -12,11 +12,16 @@ use chrono::Timelike;
 | 
			
		||||
use rand::thread_rng;
 | 
			
		||||
use rand::Rng;
 | 
			
		||||
 | 
			
		||||
use lowdim::bb2d;
 | 
			
		||||
use lowdim::p2d;
 | 
			
		||||
use lowdim::v2d;
 | 
			
		||||
use lowdim::Array2d;
 | 
			
		||||
use lowdim::BBox2d;
 | 
			
		||||
use lowdim::Point2d;
 | 
			
		||||
use lowdim::Vec2d;
 | 
			
		||||
use lowdim::Vector;
 | 
			
		||||
 | 
			
		||||
use pixelfoo::color::Color;
 | 
			
		||||
use pixelfoo::point2d::p2d;
 | 
			
		||||
use pixelfoo::point2d::Point2d;
 | 
			
		||||
use pixelfoo::vec2d::v2d;
 | 
			
		||||
use pixelfoo::vec2d::Vec2d;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
 | 
			
		||||
enum Square {
 | 
			
		||||
@@ -37,17 +42,24 @@ impl Square {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Board(Vec<Vec<Square>>);
 | 
			
		||||
#[derive(Clone, Debug)]
 | 
			
		||||
struct Board(Array2d<i64, Square>);
 | 
			
		||||
impl Board {
 | 
			
		||||
    fn bbox(&self) -> BBox2d {
 | 
			
		||||
        self.0.bbox()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn send<T: Write>(w: &mut T, board: &Board) -> std::io::Result<()> {
 | 
			
		||||
    for line in &board.0 {
 | 
			
		||||
        for square in line {
 | 
			
		||||
    for y in board.bbox().y_range() {
 | 
			
		||||
        for x in board.bbox().x_range() {
 | 
			
		||||
            let square = board.0[p2d(x, y)];
 | 
			
		||||
            let c = match square {
 | 
			
		||||
                Square::Unused => Color::black(),
 | 
			
		||||
                Square::Unknown { prio } => {
 | 
			
		||||
                    if *prio == 0 {
 | 
			
		||||
                    if prio == 0 {
 | 
			
		||||
                        Color::black()
 | 
			
		||||
                    } else if *prio < 0 {
 | 
			
		||||
                    } else if prio < 0 {
 | 
			
		||||
                        Color::lightblue()
 | 
			
		||||
                    } else {
 | 
			
		||||
                        Color::darkyellow()
 | 
			
		||||
@@ -71,37 +83,31 @@ enum Orientation {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Board {
 | 
			
		||||
    fn new(board_size: Vec2d, maze_size: Vec2d) -> Board {
 | 
			
		||||
        Board(
 | 
			
		||||
            (0..board_size.y)
 | 
			
		||||
                .map(move |y| {
 | 
			
		||||
                    (0..board_size.x)
 | 
			
		||||
                        .map(|x| {
 | 
			
		||||
                            if x < maze_size.x && y < maze_size.y {
 | 
			
		||||
                                if x == 0
 | 
			
		||||
                                    || x == maze_size.x - 1
 | 
			
		||||
                                    || y == 0
 | 
			
		||||
                                    || y == maze_size.y - 1
 | 
			
		||||
                                    || (x % 2 == 0 && y % 2 == 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    Square::Wall
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    Square::Unknown { prio: 0 }
 | 
			
		||||
                                }
 | 
			
		||||
                            } else {
 | 
			
		||||
                                Square::Unused
 | 
			
		||||
                            }
 | 
			
		||||
                        })
 | 
			
		||||
                        .collect::<Vec<_>>()
 | 
			
		||||
                })
 | 
			
		||||
                .collect::<Vec<_>>(),
 | 
			
		||||
        )
 | 
			
		||||
    fn new(board_bbox: BBox2d, maze_bbox: BBox2d) -> Board {
 | 
			
		||||
        Board(Array2d::with(board_bbox, |p| {
 | 
			
		||||
            if maze_bbox.contains(&p) {
 | 
			
		||||
                let x = p.x();
 | 
			
		||||
                let y = p.y();
 | 
			
		||||
                if x == maze_bbox.x_min()
 | 
			
		||||
                    || x == maze_bbox.x_max()
 | 
			
		||||
                    || y == maze_bbox.y_min()
 | 
			
		||||
                    || y == maze_bbox.y_max()
 | 
			
		||||
                    || (x % 2 == 0 && y % 2 == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    Square::Wall
 | 
			
		||||
                } else {
 | 
			
		||||
                    Square::Unknown { prio: 0 }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                Square::Unused
 | 
			
		||||
            }
 | 
			
		||||
        }))
 | 
			
		||||
    }
 | 
			
		||||
    fn get(&self, pos: Point2d) -> Square {
 | 
			
		||||
        self.0[pos.y as usize][pos.x as usize]
 | 
			
		||||
        self.0[pos]
 | 
			
		||||
    }
 | 
			
		||||
    fn set(&mut self, pos: Point2d, sq: Square) {
 | 
			
		||||
        self.0[pos.y as usize][pos.x as usize] = sq;
 | 
			
		||||
        self.0[pos] = sq;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn set_orientation(&mut self, desired: Orientation, pos: Point2d) {
 | 
			
		||||
@@ -109,14 +115,14 @@ impl Board {
 | 
			
		||||
        match sq {
 | 
			
		||||
            Square::Unknown { .. } => {
 | 
			
		||||
                let prio;
 | 
			
		||||
                if pos.x % 2 == 0 && pos.y % 2 != 0 {
 | 
			
		||||
                if pos.x() % 2 == 0 && pos.y() % 2 != 0 {
 | 
			
		||||
                    // horizontal corridor, vertical wall
 | 
			
		||||
                    prio = if desired == Orientation::Horizontal {
 | 
			
		||||
                        10
 | 
			
		||||
                    } else {
 | 
			
		||||
                        -10
 | 
			
		||||
                    };
 | 
			
		||||
                } else if pos.x % 2 != 0 && pos.y % 2 == 0 {
 | 
			
		||||
                } else if pos.x() % 2 != 0 && pos.y() % 2 == 0 {
 | 
			
		||||
                    // vertical corridor, horizontal wall
 | 
			
		||||
                    prio = if desired == Orientation::Vertical {
 | 
			
		||||
                        10
 | 
			
		||||
@@ -139,28 +145,28 @@ impl Board {
 | 
			
		||||
        self.set_orientation(Orientation::Vertical, pos);
 | 
			
		||||
    }
 | 
			
		||||
    fn draw_horizontal_segment(&mut self, pos: Point2d, size: Vec2d) {
 | 
			
		||||
        for x in 0..size.x {
 | 
			
		||||
            let xn = size.x - 1 - x;
 | 
			
		||||
        for x in 0..size.x() {
 | 
			
		||||
            let xn = size.x() - 1 - x;
 | 
			
		||||
            self.set_horizontal(pos + v2d(x, 0));
 | 
			
		||||
            for y in 1..x.min(xn).min(size.y / 2) + 1 {
 | 
			
		||||
            for y in 1..x.min(xn).min(size.y() / 2) + 1 {
 | 
			
		||||
                self.set_horizontal(pos + v2d(x, y));
 | 
			
		||||
                self.set_horizontal(pos + v2d(x, -y));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    fn draw_vertical_segment(&mut self, pos: Point2d, size: Vec2d) {
 | 
			
		||||
        for y in 0..size.y {
 | 
			
		||||
            let yn = size.y - 1 - y;
 | 
			
		||||
        for y in 0..size.y() {
 | 
			
		||||
            let yn = size.y() - 1 - y;
 | 
			
		||||
            self.set_vertical(pos + v2d(0, y));
 | 
			
		||||
            for x in 1..y.min(yn).min(size.x / 2) + 1 {
 | 
			
		||||
            for x in 1..y.min(yn).min(size.x() / 2) + 1 {
 | 
			
		||||
                self.set_vertical(pos + v2d(x, y));
 | 
			
		||||
                self.set_vertical(pos + v2d(-x, y));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    fn draw_7_segments(&mut self, pos: Point2d, size: Vec2d, segments: u8) {
 | 
			
		||||
        let length = size.x;
 | 
			
		||||
        let width = size.y;
 | 
			
		||||
        let length = size.x();
 | 
			
		||||
        let width = size.y();
 | 
			
		||||
        let delta = length + 1;
 | 
			
		||||
        let hsize = v2d(length, width);
 | 
			
		||||
        let vsize = v2d(width, length);
 | 
			
		||||
@@ -228,7 +234,7 @@ where
 | 
			
		||||
        open.push(Move {
 | 
			
		||||
            from,
 | 
			
		||||
            dir,
 | 
			
		||||
            prio: prio * 100 + rng.gen_range(0, 1000),
 | 
			
		||||
            prio: prio * 100 + rng.gen_range(0..1000),
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -239,8 +245,8 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
    let args = args().collect::<Vec<_>>();
 | 
			
		||||
    eprintln!("executing {}", args[0]);
 | 
			
		||||
 | 
			
		||||
    let x_size = args[1].parse::<usize>().unwrap();
 | 
			
		||||
    let y_size = args[2].parse::<usize>().unwrap();
 | 
			
		||||
    let x_size = args[1].parse::<i64>().unwrap();
 | 
			
		||||
    let y_size = args[2].parse::<i64>().unwrap();
 | 
			
		||||
    let arg = args[3].parse::<isize>().unwrap_or(DEFAULT_ARG);
 | 
			
		||||
    eprintln!("screen size {}x{}, arg {}", x_size, y_size, arg);
 | 
			
		||||
 | 
			
		||||
@@ -249,16 +255,13 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
    let t_frame = 0.040; // s
 | 
			
		||||
    let delay = Duration::new(0, (1_000_000_000.0 * t_frame) as u32);
 | 
			
		||||
 | 
			
		||||
    let board_size = v2d(x_size as i32, y_size as i32);
 | 
			
		||||
    let board_bbox = bb2d(0..x_size, 0..y_size);
 | 
			
		||||
    // round down to odd size for maze
 | 
			
		||||
    let maze_size = v2d(
 | 
			
		||||
        (board_size.x - 1) / 2 * 2 + 1,
 | 
			
		||||
        (board_size.y - 1) / 2 * 2 + 1,
 | 
			
		||||
    );
 | 
			
		||||
    let maze_bbox = bb2d(0..(x_size - 1) / 2 * 2 + 1, 0..(y_size - 1) / 2 * 2 + 1);
 | 
			
		||||
    // pick odd position at or near the middle
 | 
			
		||||
    let maze_mid = p2d((maze_size.x - 1) / 4 * 2 + 1, (maze_size.y - 1) / 4 * 2 + 1);
 | 
			
		||||
    let maze_mid = maze_bbox.center();
 | 
			
		||||
 | 
			
		||||
    let mut board = Board(Vec::new());
 | 
			
		||||
    let mut board = Board::new(board_bbox, maze_bbox);
 | 
			
		||||
    let mut open = BinaryHeap::new();
 | 
			
		||||
    let mut last_drawn_minute = 99;
 | 
			
		||||
    loop {
 | 
			
		||||
@@ -271,7 +274,7 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
            if m != last_drawn_minute {
 | 
			
		||||
                last_drawn_minute = m;
 | 
			
		||||
 | 
			
		||||
                board = Board::new(board_size, maze_size);
 | 
			
		||||
                board = Board::new(board_bbox, maze_bbox);
 | 
			
		||||
 | 
			
		||||
                // draw time in prios
 | 
			
		||||
                let segment_size = v2d(11, 5);
 | 
			
		||||
@@ -305,7 +308,7 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
                board.set(p1, Square::Corridor);
 | 
			
		||||
                board.set(p2, Square::Corridor);
 | 
			
		||||
 | 
			
		||||
                for dir1 in Vec2d::directions() {
 | 
			
		||||
                for dir1 in Vec2d::unit_vecs_l1() {
 | 
			
		||||
                    let p3 = p2 + dir1;
 | 
			
		||||
                    let p4 = p3 + dir1;
 | 
			
		||||
                    if board.get(p3).is_unknown() {
 | 
			
		||||
@@ -321,12 +324,12 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if open.is_empty() {
 | 
			
		||||
                board.set(p2d(1, 1), Square::Start);
 | 
			
		||||
                board.set(p2d(maze_size.x - 2, maze_size.y - 2), Square::Finish);
 | 
			
		||||
                board.set(maze_bbox.min() + v2d(1, 1), Square::Start);
 | 
			
		||||
                board.set(maze_bbox.max() - v2d(1, 1), Square::Finish);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let mut buf = Vec::with_capacity((board_size.x * board_size.y * 3) as usize);
 | 
			
		||||
        let mut buf = Vec::with_capacity(board_bbox.area() * 3);
 | 
			
		||||
        send(&mut buf, &board)?;
 | 
			
		||||
        stdout().write_all(&buf)?;
 | 
			
		||||
        stdout().flush()?;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,19 @@
 | 
			
		||||
use std::env::args;
 | 
			
		||||
use std::io::stdout;
 | 
			
		||||
use std::io::Write;
 | 
			
		||||
use std::iter::repeat_with;
 | 
			
		||||
use std::thread::sleep;
 | 
			
		||||
use std::time::Duration;
 | 
			
		||||
 | 
			
		||||
use rand::thread_rng;
 | 
			
		||||
use rand::Rng;
 | 
			
		||||
 | 
			
		||||
use lowdim::bb2d;
 | 
			
		||||
use lowdim::p2d;
 | 
			
		||||
use lowdim::Array2d;
 | 
			
		||||
use lowdim::BBox2d;
 | 
			
		||||
use lowdim::Point2d;
 | 
			
		||||
 | 
			
		||||
use pixelfoo::color::Color;
 | 
			
		||||
use pixelfoo::point2d::Point2d;
 | 
			
		||||
use pixelfoo::rect2d::Rect2d;
 | 
			
		||||
use pixelfoo::vec2d::v2d;
 | 
			
		||||
use pixelfoo::vec2d::Vec2d;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
 | 
			
		||||
enum Square {
 | 
			
		||||
@@ -22,40 +23,27 @@ enum Square {
 | 
			
		||||
    Fox,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Board(Vec<Vec<Square>>);
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Debug)]
 | 
			
		||||
struct Board(Array2d<i64, Square>);
 | 
			
		||||
impl Board {
 | 
			
		||||
    pub fn new(size: Vec2d, mut f: impl FnMut() -> Square) -> Board {
 | 
			
		||||
        Board(
 | 
			
		||||
            repeat_with(|| {
 | 
			
		||||
                repeat_with(&mut f)
 | 
			
		||||
                    .take(size.x as usize)
 | 
			
		||||
                    .collect::<Vec<_>>()
 | 
			
		||||
            })
 | 
			
		||||
            .take(size.y as usize)
 | 
			
		||||
            .collect::<Vec<_>>(),
 | 
			
		||||
        )
 | 
			
		||||
    pub fn new(bbox: BBox2d, mut f: impl FnMut() -> Square) -> Board {
 | 
			
		||||
        Board(Array2d::with(bbox, |_p| f()))
 | 
			
		||||
    }
 | 
			
		||||
    pub fn size(&self) -> Vec2d {
 | 
			
		||||
        let x_size = self.0[0].len() as i32;
 | 
			
		||||
        let y_size = self.0.len() as i32;
 | 
			
		||||
        v2d(x_size, y_size)
 | 
			
		||||
    fn bbox(&self) -> BBox2d {
 | 
			
		||||
        self.0.bbox()
 | 
			
		||||
    }
 | 
			
		||||
    pub fn rect(&self) -> Rect2d {
 | 
			
		||||
        Rect2d::new(0, self.size().x, 0, self.size().y)
 | 
			
		||||
    fn get(&self, pos: Point2d) -> Square {
 | 
			
		||||
        self.0[pos]
 | 
			
		||||
    }
 | 
			
		||||
    pub fn get(&self, pos: Point2d) -> Square {
 | 
			
		||||
        self.0[pos.y as usize][pos.x as usize]
 | 
			
		||||
    }
 | 
			
		||||
    pub fn set(&mut self, pos: Point2d, sq: Square) {
 | 
			
		||||
        self.0[pos.y as usize][pos.x as usize] = sq;
 | 
			
		||||
    fn set(&mut self, pos: Point2d, sq: Square) {
 | 
			
		||||
        self.0[pos] = sq;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn send<T: Write>(w: &mut T, board: &Board) -> std::io::Result<()> {
 | 
			
		||||
    let Board(lines) = board;
 | 
			
		||||
    for line in lines {
 | 
			
		||||
        for square in line {
 | 
			
		||||
    for y in board.bbox().y_range() {
 | 
			
		||||
        for x in board.bbox().x_range() {
 | 
			
		||||
            let square = board.0[p2d(x, y)];
 | 
			
		||||
            let c = match square {
 | 
			
		||||
                Square::Empty => Color::blue(),
 | 
			
		||||
                Square::Grass => Color::green(),
 | 
			
		||||
@@ -68,11 +56,9 @@ fn send<T: Write>(w: &mut T, board: &Board) -> std::io::Result<()> {
 | 
			
		||||
    w.flush()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const DEFAULT_ARG: usize = 10;
 | 
			
		||||
 | 
			
		||||
fn grow(board: &Board, pos: Point2d, grow: Square, die: Square) -> Square {
 | 
			
		||||
    for pos1 in pos.neighbours() {
 | 
			
		||||
        if board.rect().contains(pos1) {
 | 
			
		||||
    for pos1 in pos.neighbors_l1() {
 | 
			
		||||
        if board.bbox().contains(&pos1) {
 | 
			
		||||
            let neigh_sq = board.get(pos1);
 | 
			
		||||
            if neigh_sq == grow {
 | 
			
		||||
                return grow;
 | 
			
		||||
@@ -82,23 +68,24 @@ fn grow(board: &Board, pos: Point2d, grow: Square, die: Square) -> Square {
 | 
			
		||||
    die
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const DEFAULT_ARG: usize = 10;
 | 
			
		||||
 | 
			
		||||
fn main() -> std::io::Result<()> {
 | 
			
		||||
    let args = args().collect::<Vec<_>>();
 | 
			
		||||
    eprintln!("executing {}", args[0]);
 | 
			
		||||
 | 
			
		||||
    let x_size = args[1].parse::<usize>().unwrap();
 | 
			
		||||
    let y_size = args[2].parse::<usize>().unwrap();
 | 
			
		||||
    let x_size = args[1].parse::<i64>().unwrap();
 | 
			
		||||
    let y_size = args[2].parse::<i64>().unwrap();
 | 
			
		||||
    let arg = args[3].parse::<usize>().unwrap_or(DEFAULT_ARG);
 | 
			
		||||
    eprintln!("screen size {}x{}, arg {}", x_size, y_size, arg);
 | 
			
		||||
 | 
			
		||||
    let mut rng = thread_rng();
 | 
			
		||||
    let size = v2d(x_size as i32, y_size as i32);
 | 
			
		||||
    let bbox = bb2d(0..x_size, 0..y_size);
 | 
			
		||||
 | 
			
		||||
    let p_empty = 0.25;
 | 
			
		||||
    let p_grass = 0.25;
 | 
			
		||||
    let p_rabbit = 0.25;
 | 
			
		||||
    // p_fox = 0.05
 | 
			
		||||
    let mut board = Board::new(size, || {
 | 
			
		||||
    let mut board = Board::new(bbox, || {
 | 
			
		||||
        let p = rng.gen::<f64>();
 | 
			
		||||
        if p < p_empty {
 | 
			
		||||
            Square::Empty
 | 
			
		||||
@@ -115,18 +102,18 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
    let delay = Duration::new(0, (1_000_000_000.0 * t_frame) as u32);
 | 
			
		||||
 | 
			
		||||
    // mid point of the board
 | 
			
		||||
    let x_mid = (x_size - 1) as f64 / 2.0;
 | 
			
		||||
    let y_mid = (y_size - 1) as f64 / 2.0;
 | 
			
		||||
    let x_mid = (bbox.x_min() + bbox.x_max()) as f64 / 2.0;
 | 
			
		||||
    let y_mid = (bbox.y_min() + bbox.y_max()) as f64 / 2.0;
 | 
			
		||||
 | 
			
		||||
    // radius of the death zone in the middle
 | 
			
		||||
    let r = (x_size.min(y_size) - 1) as f64 / 2.5;
 | 
			
		||||
 | 
			
		||||
    loop {
 | 
			
		||||
        for _ in 0..arg {
 | 
			
		||||
            let pos = board.rect().random_point(&mut rng);
 | 
			
		||||
            let pos = bbox.random_point(&mut rng);
 | 
			
		||||
            let sq = board.get(pos);
 | 
			
		||||
            let dx = (pos.x as f64 - x_mid as f64) / r as f64;
 | 
			
		||||
            let dy = (pos.y as f64 - y_mid as f64) / r as f64;
 | 
			
		||||
            let dx = (pos.x() as f64 - x_mid as f64) / r as f64;
 | 
			
		||||
            let dy = (pos.y() as f64 - y_mid as f64) / r as f64;
 | 
			
		||||
            let p0 = (dx * dx + dy * dy).min(1.0);
 | 
			
		||||
            let p_survive = match sq {
 | 
			
		||||
                Square::Empty => 1.0,
 | 
			
		||||
@@ -150,7 +137,7 @@ fn main() -> std::io::Result<()> {
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let mut buf = Vec::with_capacity(x_size * y_size * 3);
 | 
			
		||||
        let mut buf = Vec::with_capacity(bbox.area() * 3);
 | 
			
		||||
        send(&mut buf, &board)?;
 | 
			
		||||
        stdout().write_all(&buf)?;
 | 
			
		||||
        stdout().flush()?;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1 @@
 | 
			
		||||
pub mod color;
 | 
			
		||||
 | 
			
		||||
pub mod vec2d;
 | 
			
		||||
 | 
			
		||||
pub mod point2d;
 | 
			
		||||
 | 
			
		||||
pub mod rect2d;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,63 +0,0 @@
 | 
			
		||||
use std::ops::Add;
 | 
			
		||||
 | 
			
		||||
use crate::vec2d::Vec2d;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
 | 
			
		||||
pub struct Point2d {
 | 
			
		||||
    pub x: i32,
 | 
			
		||||
    pub y: i32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Point2d {
 | 
			
		||||
    pub fn new(x: i32, y: i32) -> Point2d {
 | 
			
		||||
        Point2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn neighbours(&self) -> Vec<Point2d> {
 | 
			
		||||
        Vec2d::directions().iter().map(|v| self + v).collect()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn p2d(x: i32, y: i32) -> Point2d {
 | 
			
		||||
    Point2d::new(x, y)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Add<Vec2d> for Point2d {
 | 
			
		||||
    type Output = Point2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: Vec2d) -> Point2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Point2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> Add<&'a Vec2d> for Point2d {
 | 
			
		||||
    type Output = Point2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: &'a Vec2d) -> Point2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Point2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> Add<Vec2d> for &'a Point2d {
 | 
			
		||||
    type Output = Point2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: Vec2d) -> Point2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Point2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> Add<&'a Vec2d> for &'a Point2d {
 | 
			
		||||
    type Output = Point2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: &'a Vec2d) -> Point2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Point2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,58 +0,0 @@
 | 
			
		||||
use rand::Rng;
 | 
			
		||||
 | 
			
		||||
use crate::point2d::p2d;
 | 
			
		||||
use crate::point2d::Point2d;
 | 
			
		||||
use crate::vec2d::v2d;
 | 
			
		||||
use crate::vec2d::Vec2d;
 | 
			
		||||
 | 
			
		||||
pub struct Rect2d {
 | 
			
		||||
    origin: Point2d,
 | 
			
		||||
    size: Vec2d,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Rect2d {
 | 
			
		||||
    pub fn new(x0: i32, x1: i32, y0: i32, y1: i32) -> Rect2d {
 | 
			
		||||
        assert!(x0 <= x1 && y0 <= y1);
 | 
			
		||||
        let origin = p2d(x0, y0);
 | 
			
		||||
        let size = v2d(x1 - x0, y1 - y0);
 | 
			
		||||
        Rect2d { origin, size }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn left(&self) -> i32 {
 | 
			
		||||
        self.origin.x
 | 
			
		||||
    }
 | 
			
		||||
    pub fn right(&self) -> i32 {
 | 
			
		||||
        self.origin.x + self.size.x
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn bottom(&self) -> i32 {
 | 
			
		||||
        self.origin.y
 | 
			
		||||
    }
 | 
			
		||||
    pub fn top(&self) -> i32 {
 | 
			
		||||
        self.origin.y + self.size.y
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn width(&self) -> i32 {
 | 
			
		||||
        self.size.x
 | 
			
		||||
    }
 | 
			
		||||
    pub fn height(&self) -> i32 {
 | 
			
		||||
        self.size.y
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn contains(&self, p: Point2d) -> bool {
 | 
			
		||||
        self.left() <= p.x && p.x < self.right() && self.bottom() <= p.y && p.y < self.top()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn random_point<R>(&self, rng: &mut R) -> Point2d
 | 
			
		||||
    where
 | 
			
		||||
        R: Rng,
 | 
			
		||||
    {
 | 
			
		||||
        let x = rng.gen_range(self.left(), self.right());
 | 
			
		||||
        let y = rng.gen_range(self.bottom(), self.top());
 | 
			
		||||
        p2d(x, y)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn r2d(x0: i32, x1: i32, y0: i32, y1: i32) -> Rect2d {
 | 
			
		||||
    Rect2d::new(x0, x1, y0, y1)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										61
									
								
								src/vec2d.rs
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								src/vec2d.rs
									
									
									
									
									
								
							@@ -1,61 +0,0 @@
 | 
			
		||||
use std::ops::Add;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
 | 
			
		||||
pub struct Vec2d {
 | 
			
		||||
    pub x: i32,
 | 
			
		||||
    pub y: i32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Vec2d {
 | 
			
		||||
    pub fn new(x: i32, y: i32) -> Vec2d {
 | 
			
		||||
        Vec2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn directions() -> Vec<Vec2d> {
 | 
			
		||||
        vec![v2d(1, 0), v2d(0, 1), v2d(-1, 0), v2d(0, -1)]
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn v2d(x: i32, y: i32) -> Vec2d {
 | 
			
		||||
    Vec2d::new(x, y)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Add for Vec2d {
 | 
			
		||||
    type Output = Vec2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: Vec2d) -> Vec2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Vec2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> Add<&'a Vec2d> for Vec2d {
 | 
			
		||||
    type Output = Vec2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: &'a Vec2d) -> Vec2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Vec2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> Add<Vec2d> for &'a Vec2d {
 | 
			
		||||
    type Output = Vec2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: Vec2d) -> Vec2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Vec2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> Add<&'a Vec2d> for &'a Vec2d {
 | 
			
		||||
    type Output = Vec2d;
 | 
			
		||||
 | 
			
		||||
    fn add(self, other: &'a Vec2d) -> Vec2d {
 | 
			
		||||
        let x = self.x + other.x;
 | 
			
		||||
        let y = self.y + other.y;
 | 
			
		||||
        Vec2d { x, y }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user