diff --git a/.gitignore b/.gitignore index 04dc301..37360bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target +target/ tarpaulin-report.html \ No newline at end of file diff --git a/.idea/bamboo.iml b/.idea/bamboo.iml index 394aa25..ddeae3f 100644 --- a/.idea/bamboo.iml +++ b/.idea/bamboo.iml @@ -7,8 +7,10 @@ - + + + diff --git a/Cargo.lock b/Cargo.lock index 4a7ce5f..d6cc967 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -16,12 +27,321 @@ dependencies = [ "spin", ] +[[package]] +name = "bincode" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a6301db0b49fb63551bc15b5ae348147101cdf323242b93ec7546d5002ff1af" +dependencies = [ + "byteorder", + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitstring" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a39c0db600cfe77ef1b6d9ea71173bdccf190722877969d526d380519b6ecc" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[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 = "clap" +version = "4.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "console" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.42.0", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa 0.4.8", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "envor" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edde1c2487f9e5da9e3afdbb0a853f22347c348b800d901debf937234f5803b" +dependencies = [ + "dotenv", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "indicatif" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lock_api" version = "0.4.9" @@ -32,12 +352,371 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.42.0", +] + +[[package]] +name = "neuroflow" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cc1d18776c6954a1e478e6ea7c79c7a99f8f4765f7a4f74a935f03f3a5b521d" +dependencies = [ + "bincode", + "csv", + "rand 0.3.23", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "poceae" +version = "0.1.0" +dependencies = [ + "bamboo", + "bitstring", + "clap", + "indicatif", + "itertools", + "log", + "neuroflow", + "rand 0.8.5", + "simple_logger", + "tokio", + "uciengine", +] + +[[package]] +name = "portable-atomic" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +dependencies = [ + "libc", + "rand 0.4.6", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "rustix" +version = "0.36.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +dependencies = [ + "itoa 1.0.5", + "ryu", + "serde", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "simple_logger" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e190a521c2044948158666916d9e872cbb9984f755e9bb3b5b75a836205affcd" +dependencies = [ + "atty", + "colored", + "log", + "time", + "windows-sys 0.42.0", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "spin" version = "0.9.5" @@ -46,3 +725,259 @@ checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" dependencies = [ "lock_api", ] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +dependencies = [ + "itoa 1.0.5", + "libc", + "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + +[[package]] +name = "tokio" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.42.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "uciengine" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40fbc4b3240348173c7ebe246c03ba7948c6b958fea6151c54369e451bd85c8f" +dependencies = [ + "envor", + "log", + "serde", + "serde_json", + "thiserror", + "tokio", +] + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[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" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +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-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +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.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" diff --git a/Cargo.toml b/Cargo.toml index 97cd20b..7d782bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,5 @@ -[package] -name = "bamboo" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -spin = "0.9.5" -hex = "0.4.3" \ No newline at end of file +[workspace] +members = [ + "poceae", + "bamboo" +] \ No newline at end of file diff --git a/bamboo/Cargo.lock b/bamboo/Cargo.lock new file mode 100644 index 0000000..e7cc543 --- /dev/null +++ b/bamboo/Cargo.lock @@ -0,0 +1,910 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bamboo" +version = "0.1.0" +dependencies = [ + "hex", + "neuroflow", + "spin", +] + +[[package]] +name = "bincode" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a6301db0b49fb63551bc15b5ae348147101cdf323242b93ec7546d5002ff1af" +dependencies = [ + "byteorder", + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[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 = "clap" +version = "4.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa 0.4.8", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "envor" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edde1c2487f9e5da9e3afdbb0a853f22347c348b800d901debf937234f5803b" +dependencies = [ + "dotenv", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "io-lifetimes" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.42.0", +] + +[[package]] +name = "neuroflow" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cc1d18776c6954a1e478e6ea7c79c7a99f8f4765f7a4f74a935f03f3a5b521d" +dependencies = [ + "bincode", + "csv", + "rand 0.3.23", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "poceae" +version = "0.1.0" +dependencies = [ + "clap", + "log", + "neuroflow", + "rand 0.8.5", + "simple_logger", + "tokio", + "uciengine", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +dependencies = [ + "libc", + "rand 0.4.6", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "rustix" +version = "0.36.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +dependencies = [ + "itoa 1.0.5", + "ryu", + "serde", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "simple_logger" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e190a521c2044948158666916d9e872cbb9984f755e9bb3b5b75a836205affcd" +dependencies = [ + "atty", + "colored", + "log", + "time", + "windows-sys 0.42.0", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" +dependencies = [ + "lock_api", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +dependencies = [ + "itoa 1.0.5", + "libc", + "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + +[[package]] +name = "tokio" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.42.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "uciengine" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40fbc4b3240348173c7ebe246c03ba7948c6b958fea6151c54369e451bd85c8f" +dependencies = [ + "envor", + "log", + "serde", + "serde_json", + "thiserror", + "tokio", +] + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[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" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +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-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +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.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" diff --git a/bamboo/Cargo.toml b/bamboo/Cargo.toml new file mode 100644 index 0000000..97cd20b --- /dev/null +++ b/bamboo/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "bamboo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +spin = "0.9.5" +hex = "0.4.3" \ No newline at end of file diff --git a/src/board.rs b/bamboo/src/board.rs similarity index 82% rename from src/board.rs rename to bamboo/src/board.rs index 08cf0d0..699688f 100644 --- a/src/board.rs +++ b/bamboo/src/board.rs @@ -2,10 +2,11 @@ use std::error::Error; use std::fmt::{Display, Formatter}; use std::num::ParseIntError; use crate::boardfield::{Boardfield, BoardfieldOps}; +use crate::error::FENParseError; use crate::piece::{PieceColor, PieceOnBoard, PieceType}; -use crate::utils::{algebraic_to_boardloc, AlgebraicNotationError, boardloc_to_algebraic}; +use crate::utils::{algebraic_to_boardloc}; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub struct Board { bitfield: Boardfield, // While this is a less efficient memory layout, having an array of where all the pieces are will make move generation significantly faster. @@ -18,43 +19,14 @@ pub struct Board { castle_black_kingside: bool, castle_black_queenside: bool, - en_passant_target: Option, + en_passant_target: Option, move_counter: usize, halfmove_counter: usize } -#[derive(Debug)] -pub enum FENParseError { - InvalidNumberOfComponents { got: usize }, - InvalidPlayerToMove { got: String }, - EnPassantTargetParseError { e: AlgebraicNotationError }, - InvalidMoveCounter { e: ParseIntError }, - InvalidPieceCharacter { got: char }, - CannotSkipToOutsideOfBoard { got: usize, which_is: usize }, -} -impl Error for FENParseError {} -impl Display for FENParseError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::InvalidNumberOfComponents { got } => write!(f, "Invalid number of components: got {}, expected 6", got), - Self::InvalidPlayerToMove { got } => write!(f, "Invalid player to move: expected one of `wb`, got `{}`", got), - Self::EnPassantTargetParseError { e } => write!(f, "Error parsing en passant target: {}", e), - Self::InvalidMoveCounter { e } => write!(f, "Invalid move counter: {}", e), - Self::InvalidPieceCharacter { got } => write!(f, "Invalid piece character: expected one of `rnbqkpRNBQKP`, got `{}`", got), - Self::CannotSkipToOutsideOfBoard { got, which_is } => write!(f, "Cannot skip files to outside the board (tried to skip {} positions, which would be at position {})", got, which_is) - } - } -} - impl Board { pub fn to_board_id(&self) -> [u8; 41] { - // 0-31 BOARDFILED - // 32 FLAGS - // 33-36 EN_PASSANT_TARGET - // 37-38 HALFMOVE_COUNTER - // 39-40 FULLMOVE_COUNTER - let mut res = [0u8; 41]; res[0..32].copy_from_slice(&self.bitfield.get_field()); @@ -95,7 +67,7 @@ impl Board { let en_passant_target: [u8; 4] = match self.en_passant_target { Some(target) => { (target as u32).to_le_bytes() - }, + } None => { u32::MAX.to_le_bytes() } @@ -111,7 +83,7 @@ impl Board { pub fn from_fen(fen: &str) -> Result { let components = fen.split(' ').collect::>(); if components.len() != 6 { - return Err(FENParseError::InvalidNumberOfComponents { got: components.len() }) + return Err(FENParseError::InvalidNumberOfComponents { got: components.len() as isize }); } // turn to move @@ -122,10 +94,10 @@ impl Board { }; // castling rights - let castle_white_kingside = components[2].contains("K"); - let castle_white_queenside = components[2].contains("Q"); - let castle_black_kingside = components[2].contains("k"); - let castle_black_queenside = components[2].contains("q"); + let castle_white_kingside = components[2].contains('K'); + let castle_white_queenside = components[2].contains('Q'); + let castle_black_kingside = components[2].contains('k'); + let castle_black_queenside = components[2].contains('q'); let en_passant_target = match components[3] { "-" => None, @@ -160,29 +132,29 @@ impl Board { piecelist.push(create_fen_piece(char, 8 - rank, file)?); bitfield.set_pos(((8 - rank) + file * 8) - 1, create_bitfield_piece(char)?); file += 1; - }, + } _ if char.is_numeric() => { - let num = char.to_digit(10).unwrap() as usize; + let num = char.to_digit(10).unwrap() as isize; if !(1..=8).contains(&num) { - return Err(FENParseError::CannotSkipToOutsideOfBoard {got: num, which_is: num}) + return Err(FENParseError::CannotSkipToOutsideOfBoard { got: num, which_is: num }); } if file + num > 8 { - return Err(FENParseError::CannotSkipToOutsideOfBoard {got: num, which_is: file + num}) + return Err(FENParseError::CannotSkipToOutsideOfBoard { got: num, which_is: file + num }); } file += num; - }, + } '/' => { if rank == 7 { - return Err(FENParseError::CannotSkipToOutsideOfBoard { got: 1, which_is: file + 1 }) + return Err(FENParseError::CannotSkipToOutsideOfBoard { got: 1, which_is: file + 1 }); } rank += 1; file = 0; } - _ => return Err(FENParseError::InvalidPieceCharacter {got: char}) + _ => return Err(FENParseError::InvalidPieceCharacter { got: char }) } } @@ -201,9 +173,9 @@ impl Board { } } -fn create_fen_piece(c: char, rank: usize, file: usize) -> Result { +fn create_fen_piece(c: char, rank: isize, file: isize) -> Result { Ok(PieceOnBoard { - loc: rank + file * 8, + loc: (rank + file * 8) - 1, value: match c { 'r' => PieceColor::Black as u8 | PieceType::Rook as u8, 'n' => PieceColor::Black as u8 | PieceType::Knight as u8, @@ -221,6 +193,7 @@ fn create_fen_piece(c: char, rank: usize, file: usize) -> Result Result { match c { 'r' => Ok(PieceColor::Black as u8 | PieceType::Rook as u8), @@ -243,7 +216,7 @@ fn create_bitfield_piece(c: char) -> Result { #[cfg(test)] mod tests { - use crate::board::Board; + use crate::board::{Board, create_bitfield_piece, create_fen_piece}; use crate::boardfield::BoardfieldOps; use crate::boardloc; use crate::piece::{PieceColor, PieceType}; @@ -264,25 +237,32 @@ mod tests { assert_eq!(Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1").unwrap().to_board_id(), [156, 0, 0, 65, 154, 0, 0, 33, 155, 0, 0, 49, 157, 0, 0, 81, 158, 0, 0, 97, 155, 0, 0, 49, 154, 0, 0, 33, 156, 0, 0, 65, 7, 255, 255, 255, 255, 0, 0, 1, 0]); assert_eq!(Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQq - 0 1").unwrap().to_board_id(), [156, 0, 0, 65, 154, 0, 0, 33, 155, 0, 0, 49, 157, 0, 0, 81, 158, 0, 0, 97, 155, 0, 0, 49, 154, 0, 0, 33, 156, 0, 0, 65, 23, 255, 255, 255, 255, 0, 0, 1, 0]); assert_eq!(Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQk - 0 1").unwrap().to_board_id(), [156, 0, 0, 65, 154, 0, 0, 33, 155, 0, 0, 49, 157, 0, 0, 81, 158, 0, 0, 97, 155, 0, 0, 49, 154, 0, 0, 33, 156, 0, 0, 65, 15, 255, 255, 255, 255, 0, 0, 1, 0]); - assert_eq!(Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1").unwrap().to_board_id(), [156, 0, 0, 65, 154, 0, 0, 33, 155, 0, 0, 49, 157, 0, 0, 81, 158, 0, 0, 97, 155, 0, 0, 49, 154, 0, 0, 33, 156, 0, 0, 65, 31, 255, 255, 255, 255, 0, 0, 1, 0]); assert_eq!(Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq a4 0 1").unwrap().to_board_id(), [156, 0, 0, 65, 154, 0, 0, 33, 155, 0, 0, 49, 157, 0, 0, 81, 158, 0, 0, 97, 155, 0, 0, 49, 154, 0, 0, 33, 156, 0, 0, 65, 30, 3, 0, 0, 0, 0, 0, 1, 0]); - assert!(Board::from_fen("d").is_err()); - assert!(Board::from_fen("8/8/8/8/8/8/8/8 h - - 0 1").is_err()); - assert!(Board::from_fen("8/8/8/8/8/8/8 w KQkq j4 0 1").is_err()); + println!("{}", Board::from_fen("d").unwrap_err()); + println!("{}", Board::from_fen("8/8/8/8/8/8/8/8 h - - 0 1").unwrap_err()); + println!("{}", Board::from_fen("8/8/8/8/8/8/8 w KQkq j4 0 1").unwrap_err()); - assert!(Board::from_fen("9/8/8/8/8/8/8 w KQkq a4 0 1").is_err()); - assert!(Board::from_fen("18/8/8/8/8/8/8 w KQkq a4 0 1").is_err()); - assert!(Board::from_fen("8/8/8/8/8/8/8/8/8 w KQkq a4 0 1").is_err()); - assert!(Board::from_fen("8/8/8/8/8/8/8/8 w KQkq a4 a 1").is_err()); - assert!(Board::from_fen("8/8/8/8/8/8/8/8 w KQkq a4 0 a").is_err()); + println!("{}", Board::from_fen("9/8/8/8/8/8/8 w KQkq a4 0 1").unwrap_err()); + println!("{}", Board::from_fen("18/8/8/8/8/8/8 w KQkq a4 0 1").unwrap_err()); + println!("{}", Board::from_fen("8/8/8/8/8/8/8/8/8 w KQkq a4 0 1").unwrap_err()); + println!("{}", Board::from_fen("8/8/8/8/8/8/8/8 w KQkq a4 a 1").unwrap_err()); + println!("{}", Board::from_fen("8/8/8/8/8/8/8/8 w KQkq a4 0 a").unwrap_err()); - assert!(Board::from_fen("s w KQkq a4 0 1").is_err()); + println!("{}", Board::from_fen("s w KQkq a4 0 1").unwrap_err()); assert_eq!(Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1").unwrap().to_board_id(), [156, 0, 0, 65, 154, 0, 0, 33, 155, 0, 0, 49, 157, 0, 0, 81, 158, 0, 0, 97, 155, 0, 0, 49, 154, 0, 0, 33, 156, 0, 0, 65, 31, 255, 255, 255, 255, 0, 0, 1, 0]); } + #[test] + pub fn fen_error_testing() { + assert!(create_fen_piece('m', 0, 0).is_err()); + println!("{}", create_fen_piece('m', 0, 0).unwrap_err()); + assert!(create_bitfield_piece('m').is_err()); + println!("{}", create_bitfield_piece('m').unwrap_err()); + } + #[test] pub fn fen_parse_testing() { let board = Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1").unwrap(); diff --git a/src/boardfield.rs b/bamboo/src/boardfield.rs similarity index 92% rename from src/boardfield.rs rename to bamboo/src/boardfield.rs index 3fd601f..1dd9853 100644 --- a/src/boardfield.rs +++ b/bamboo/src/boardfield.rs @@ -7,23 +7,6 @@ // Boards are stored as a 32-byte bitfield, to make accessing them as efficient as possible. // We could theoretically pack it into two u128s, but some basic testing seems like LLVM can optimize array indexing faster than the bucketload of shift ops needed to pack it into u128s. - -/* - - a b c d e f g h - -8 56 57 58 59 60 61 62 63 8 -+ -7 48 49 50 51 52 53 54 55 7 |- bf2 -6 40 41 42 43 44 45 46 47 6 | -5 32 33 34 35 36 37 38 39 5 -+ -4 24 25 26 27 28 29 30 31 4 -+ -3 16 17 18 19 20 21 22 23 3 | -2 8 9 10 11 12 13 14 15 2 |- bf1 -1 0 1 2 3 4 5 6 7 1 -+ - - a b c d e f g h - */ - use crate::boardloc; use crate::piece::{PieceColor, PieceType}; @@ -31,8 +14,8 @@ pub type Boardfield = [u8; 32]; pub trait BoardfieldOps { fn new() -> Self where Self: Sized; fn startpos() -> Self where Self: Sized; - fn get_pos(&self, boardloc: usize) -> u8; - fn set_pos(&mut self, boardloc: usize, piece: u8); + fn get_pos(&self, boardloc: isize) -> u8; + fn set_pos(&mut self, boardloc: isize, piece: u8); fn get_field(&self) -> [u8; 32]; } impl BoardfieldOps for Boardfield { @@ -87,7 +70,7 @@ impl BoardfieldOps for Boardfield { field } - fn get_pos(&self, boardloc: usize) -> u8 { + fn get_pos(&self, boardloc: isize) -> u8 { // bf1: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 // bf2: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 @@ -95,18 +78,18 @@ impl BoardfieldOps for Boardfield { panic!("boardloc out of range"); } - let field = self[boardloc / 2]; + let field = self[(boardloc / 2) as usize]; let shift = 4 * (boardloc % 2); (field & (0b1111 << shift)) >> shift } - fn set_pos(&mut self, boardloc: usize, piece: u8) { + fn set_pos(&mut self, boardloc: isize, piece: u8) { if boardloc > 63 { panic!("boardloc out of range {}", boardloc); } - let field = self[boardloc / 2]; + let field = self[(boardloc / 2) as usize]; let shift = 4 * (boardloc % 2); // clear out the field @@ -116,7 +99,7 @@ impl BoardfieldOps for Boardfield { // then OR them together let bf_new = bf_cleared | piece_shifted; - self[boardloc / 2] = bf_new; + self[(boardloc / 2) as usize] = bf_new; } fn get_field(&self) -> [u8; 32] { diff --git a/bamboo/src/error.rs b/bamboo/src/error.rs new file mode 100644 index 0000000..2e6a097 --- /dev/null +++ b/bamboo/src/error.rs @@ -0,0 +1,45 @@ +use std::error::Error; +use std::fmt::{Display, Formatter}; +use std::num::ParseIntError; + +#[derive(Debug)] +pub enum FENParseError { + InvalidNumberOfComponents { got: isize }, + InvalidPlayerToMove { got: String }, + EnPassantTargetParseError { e: AlgebraicNotationError }, + InvalidMoveCounter { e: ParseIntError }, + InvalidPieceCharacter { got: char }, + CannotSkipToOutsideOfBoard { got: isize, which_is: isize }, +} + +impl Error for FENParseError {} + +impl Display for FENParseError { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + Self::InvalidNumberOfComponents { got } => write!(f, "Invalid number of components: got {}, expected 6", got), + Self::InvalidPlayerToMove { got } => write!(f, "Invalid player to move: expected one of `wb`, got `{}`", got), + Self::EnPassantTargetParseError { e } => write!(f, "Error parsing en passant target: {}", e), + Self::InvalidMoveCounter { e } => write!(f, "Invalid move counter: {}", e), + Self::InvalidPieceCharacter { got } => write!(f, "Invalid piece character: expected one of `rnbqkpRNBQKP`, got `{}`", got), + Self::CannotSkipToOutsideOfBoard { got, which_is } => write!(f, "Cannot skip files to outside the board (tried to skip {} positions, which would be at position {})", got, which_is) + } + } +} + +#[derive(Debug)] +pub enum AlgebraicNotationError { + InvalidRank { got: String }, + InvalidFile { got: String }, + InvalidLength { got: isize } +} +impl Error for AlgebraicNotationError {} +impl Display for AlgebraicNotationError { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + AlgebraicNotationError::InvalidRank { got } => write!(f, "Invalid rank: expected one of `012345678`, got `{}`", got), + AlgebraicNotationError::InvalidFile { got } => write!(f, "Invalid file: expected one of `abcdefgh`, got `{}`", got), + AlgebraicNotationError::InvalidLength { got } => write!(f, "Invalid length, expected 2, got `{}`", got) + } + } +} \ No newline at end of file diff --git a/bamboo/src/lib.rs b/bamboo/src/lib.rs new file mode 100644 index 0000000..a41fb7c --- /dev/null +++ b/bamboo/src/lib.rs @@ -0,0 +1,7 @@ +pub mod boardfield; +pub mod piece; +pub mod board; +#[macro_use] +pub mod utils; +pub mod nn; +pub mod error; \ No newline at end of file diff --git a/src/main.rs b/bamboo/src/main.rs similarity index 93% rename from src/main.rs rename to bamboo/src/main.rs index b6f9293..e66353e 100644 --- a/src/main.rs +++ b/bamboo/src/main.rs @@ -1,5 +1,4 @@ -use std::{fs, io}; -use std::path::Path; +use std::{io}; use std::sync::{Arc}; use crate::uci::{uci_handle_command, UCIState}; use spin::Mutex; @@ -13,6 +12,8 @@ pub mod piece; pub mod board; #[macro_use] pub mod utils; +pub mod nn; +pub mod error; pub const ENGINE_NAME: &str = "Bamboo"; pub const ENGINE_VERSION: &str = "1.0"; @@ -45,8 +46,8 @@ fn main() { println!("{} {} by {}", ENGINE_NAME, ENGINE_VERSION, ENGINE_AUTHOR); - let mut uci_state = UCIState::new(); - let mut uci_lock = Arc::new(Mutex::new(uci_state)); + let uci_state = UCIState::new(); + let uci_lock = Arc::new(Mutex::new(uci_state)); loop { let mut cmdbuf = String::new(); diff --git a/bamboo/src/nn/mod.rs b/bamboo/src/nn/mod.rs new file mode 100644 index 0000000..21d652a --- /dev/null +++ b/bamboo/src/nn/mod.rs @@ -0,0 +1,6 @@ +#[derive(Default, Debug)] +pub struct BNNModel { + +} + +// Model architecture \ No newline at end of file diff --git a/src/piece.rs b/bamboo/src/piece.rs similarity index 63% rename from src/piece.rs rename to bamboo/src/piece.rs index 0514069..fa79f7e 100644 --- a/src/piece.rs +++ b/bamboo/src/piece.rs @@ -1,18 +1,27 @@ -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] +use crate::piece::PieceType::{Bishop, King, Knight, Pawn, Queen, Rook}; + +#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone)] pub struct PieceOnBoard { - pub loc: usize, + pub loc: isize, pub value: Piece } impl PieceOnBoard { - fn new(loc: usize, value: Piece) -> Self { - Self { + fn empty(loc: isize) -> Self { + PieceOnBoard { + loc, + value: 0u8 + } + } + + fn new(loc: isize, value: Piece) -> Self { + PieceOnBoard { loc, value } } } -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] +#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Copy)] #[repr(u8)] pub enum PieceType { Pawn = 1, @@ -23,18 +32,29 @@ pub enum PieceType { King = 6 } -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] +#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Copy)] #[repr(u8)] pub enum PieceColor { White = 8, Black = 0 } +impl PieceColor { + pub fn invert(&self) -> Self { + match self { + Self::White => PieceColor::Black, + Self::Black => PieceColor::White + } + } +} + pub type Piece = u8; pub trait PieceOps { fn is_white(value: u8) -> bool; - fn is_black(value: u8) -> bool; + + fn get_type(value: u8) -> Option; + fn get_color(value: u8) -> PieceColor; } impl PieceOps for Piece { fn is_white(value: u8) -> bool { @@ -48,12 +68,40 @@ impl PieceOps for Piece { fn is_black(value: u8) -> bool { !Self::is_white(value) } + + fn get_type(value: u8) -> Option { + match value & 0b111 { + 1 => Some(Pawn), + 2 => Some(Knight), + 3 => Some(Bishop), + 4 => Some(Rook), + 5 => Some(Queen), + 6 => Some(King), + _ => None + } + } + + fn get_color(value: u8) -> PieceColor { + if Self::is_white(value) { + PieceColor::White + } else { + PieceColor::Black + } + } } #[cfg(test)] mod piece_tests { use crate::piece::{Piece, PieceColor, PieceOnBoard, PieceOps, PieceType}; + #[test] + fn piece_constructor() { + assert_eq!(PieceOnBoard::empty(0), PieceOnBoard { + loc: 0, + value: 0, + }); + } + #[test] fn piece_serialization() { assert_eq!(PieceOnBoard::new(0, 0), PieceOnBoard { @@ -81,6 +129,20 @@ mod piece_tests { assert_eq!(PieceType::King as u8 | PieceColor::Black as u8, 0b0110); } + #[test] + pub fn piece_deserialization_test() { + assert_eq!(Piece::get_type(PieceType::King as u8).unwrap(), PieceType::King); + assert_eq!(Piece::get_type(PieceType::Queen as u8).unwrap(), PieceType::Queen); + assert_eq!(Piece::get_type(PieceType::Rook as u8).unwrap(), PieceType::Rook); + assert_eq!(Piece::get_type(PieceType::Bishop as u8).unwrap(), PieceType::Bishop); + assert_eq!(Piece::get_type(PieceType::Knight as u8).unwrap(), PieceType::Knight); + assert_eq!(Piece::get_type(PieceType::Pawn as u8).unwrap(), PieceType::Pawn); + assert_eq!(Piece::get_type(191u8), None); + + assert_eq!(Piece::get_color(PieceColor::Black as u8), PieceColor::Black); + assert_eq!(Piece::get_color(PieceColor::White as u8), PieceColor::White); + } + #[test] fn piece_color_checks() { assert!(!Piece::is_white(PieceType::Pawn as u8 | PieceColor::Black as u8)); @@ -112,5 +174,8 @@ mod piece_tests { assert!(Piece::is_white(PieceType::King as u8 | PieceColor::White as u8)); assert!(Piece::is_black(PieceType::King as u8 | PieceColor::Black as u8)); assert!(!Piece::is_black(PieceType::King as u8 | PieceColor::White as u8)); + + assert_eq!(PieceColor::White.invert(), PieceColor::Black); + assert_eq!(PieceColor::Black.invert(), PieceColor::White); } } \ No newline at end of file diff --git a/src/uci.rs b/bamboo/src/uci.rs similarity index 95% rename from src/uci.rs rename to bamboo/src/uci.rs index 2034111..3c6804c 100644 --- a/src/uci.rs +++ b/bamboo/src/uci.rs @@ -3,11 +3,13 @@ use crate::{ENGINE_AUTHOR, ENGINE_NAME, ENGINE_VERSION}; use std::fmt::Write; use std::sync::{Arc}; use spin::Mutex; +use crate::nn::BNNModel; #[derive(Default)] pub struct UCIState { debug: bool, - is_blocking: bool + is_blocking: bool, + nn_model: BNNModel } impl UCIState { diff --git a/src/utils.rs b/bamboo/src/utils.rs similarity index 58% rename from src/utils.rs rename to bamboo/src/utils.rs index ccae1b0..d1b9fcf 100644 --- a/src/utils.rs +++ b/bamboo/src/utils.rs @@ -16,27 +16,11 @@ use std::error::Error; use std::fmt::{Display, Formatter}; +use crate::error::AlgebraicNotationError; -#[derive(Debug)] -pub enum AlgebraicNotationError { - InvalidRank { got: String }, - InvalidFile { got: String }, - InvalidLength { got: usize } -} -impl Error for AlgebraicNotationError {} -impl Display for AlgebraicNotationError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - AlgebraicNotationError::InvalidRank { got } => write!(f, "Invalid rank: expected one of `012345678`, got `{}`", got), - AlgebraicNotationError::InvalidFile { got } => write!(f, "Invalid file: expected one of `abcdefgh`, got `{}`", got), - AlgebraicNotationError::InvalidLength { got } => write!(f, "Invalid length, expected 2, got `{}`", got) - } - } -} - -pub fn algebraic_to_boardloc(algebraic: &str) -> Result { +pub fn algebraic_to_boardloc(algebraic: &str) -> Result { if algebraic.chars().count() != 2 { - return Err(AlgebraicNotationError::InvalidLength { got: algebraic.chars().count() }) + return Err(AlgebraicNotationError::InvalidLength { got: algebraic.chars().count() as isize }) } let chars: Vec = algebraic.chars().collect(); @@ -51,16 +35,16 @@ pub fn algebraic_to_boardloc(algebraic: &str) -> Result(boardloc: usize) -> &'a str { - BOARDLOC_TO_ALG[boardloc] +pub fn boardloc_to_algebraic<'a>(boardloc: isize) -> &'a str { + BOARDLOC_TO_ALG[boardloc as usize] } #[macro_export] @@ -73,7 +57,7 @@ macro_rules! boardloc { #[macro_export] macro_rules! algebraic { ($boardloc:expr) => { - $crate::utils::BOARDLOC_TO_ALG[$boardloc] + $crate::utils::BOARDLOC_TO_ALG[$boardloc as usize] } } diff --git a/poceae/Cargo.lock b/poceae/Cargo.lock new file mode 100644 index 0000000..4786827 --- /dev/null +++ b/poceae/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "poceae" +version = "0.1.0" diff --git a/poceae/Cargo.toml b/poceae/Cargo.toml new file mode 100644 index 0000000..4091230 --- /dev/null +++ b/poceae/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "poceae" +description = "Generate and train models for BambooNN." +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.8.5" +uciengine = "0.1.33" +tokio = "1.25.0" +simple_logger = "4.0.0" +log = "0.4.17" +neuroflow = "0.1.3" +clap = { version = "4.1.4", features = ["derive"] } +indicatif = "0.17.3" +itertools = "0.10.5" +bitstring = "0.1.2" +bamboo = { version = "0.1.0", path = "../bamboo" } \ No newline at end of file diff --git a/poceae/src/main.rs b/poceae/src/main.rs new file mode 100644 index 0000000..b39485e --- /dev/null +++ b/poceae/src/main.rs @@ -0,0 +1,73 @@ +use std::path::PathBuf; +use clap::{Parser, Subcommand}; + +#[derive(Parser)] +#[command(author = "c0repwn3r", version, about, long_about = None)] +struct Cli { + #[command(subcommand)] + command: Commands +} + +#[derive(Subcommand)] +enum Commands { + /// Create a .csv dataset for use with train-model + BuildDataset { + #[arg(short, long, value_name = "FILE")] + /// The .csv file to output the dataset to. This file will be **VERY LARGE**, so make sure it is in a place that can handle upwards of 10 GB of data + output_file: PathBuf, + + #[arg(short, long, value_name = "ENGINE_BINARY")] + /// The path to a UCI-compatible chess engine, for example /usr/bin/stockfish + uci_engine_binary: PathBuf, + + #[arg(short, long, default_value = "500000")] + /// The amount of dataset entries to generate. By default, set to 500,000 + dataset_size: usize, + + #[arg(short, long, default_value = "20")] + /// The search depth to be used to evaluate positions, sent directly to the UCI engine, set to 20 by default + search_depth: i32, + + #[arg(short, long, default_value = "4")] + /// The amount of threads to be used to search each position, set to 4 by default + threads: i32, + + #[arg(short, long, default_value = "128")] + /// The amount of memory to be allocated by the UCI engine, in MiB, set to 128 by default + allocate: i32 + }, + /// Given a .csv dataset, train the model and output a trained BNNF file. + TrainModel { + #[arg(short, long, value_name = "DATA_FILE")] + /// The path to the .csv dataset file, as created by build-dataset + data_file: PathBuf, + + #[arg(short, long, default_value = "0.01")] + /// The rate to perform training at. By default, set to 0.01. + /// Larger values will result in faster training but less accurate results. + training_rate: f32, + + #[arg(short, long, default_value = "50000")] + /// The amount of training iterations to perform. By default, set to 50,000. + /// Larger values will result in more accurate training but will eventually degrade model performance. Fine-tune to get best performance. + iterations: usize, + + #[arg(short, long, value_name = "MODEL_FILE")] + /// The .bnnf file to output the trained model to. This file *may* become large, but will not always be large. + output_file: PathBuf + } +} + +#[tokio::main] +async fn main() { + + let cli = Cli::parse(); + match cli.command { + Commands::BuildDataset { output_file, uci_engine_binary, dataset_size, search_depth, threads, allocate } => { + + }, + Commands::TrainModel { data_file, training_rate, iterations, output_file } => { + + } + } +} \ No newline at end of file