diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6a2e443..36c4e72 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,5 +11,7 @@ jobs: run: cargo build - name: Test run: cargo test --quiet --lib + - name: Test Shortdeck + run: cargo test --quiet --lib --features shortdeck - name: Benchmark run: cargo bench --quiet --message-format short diff --git a/Cargo.lock b/Cargo.lock index 6f0a50f..b48546f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,9 +73,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" @@ -85,9 +85,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" @@ -103,9 +103,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cast" @@ -297,9 +297,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fixedbitset" @@ -319,9 +319,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -336,9 +336,9 @@ checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "hermit-abi" @@ -363,9 +363,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown", @@ -416,30 +416,30 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" @@ -449,9 +449,9 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "num-traits" @@ -480,9 +480,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -536,24 +536,27 @@ checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -610,9 +613,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -622,9 +625,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -633,9 +636,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "robopoker" @@ -657,11 +660,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -733,9 +736,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "syn" -version = "2.0.52" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -744,14 +747,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -765,18 +769,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -795,15 +799,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "utf8parse" @@ -829,9 +833,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -840,9 +844,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -855,9 +859,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -865,9 +869,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -878,15 +882,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -914,7 +918,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -938,7 +942,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -958,17 +971,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -979,9 +993,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -991,9 +1005,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1003,9 +1017,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1015,9 +1035,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1027,9 +1047,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -1039,9 +1059,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1051,12 +1071,33 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index 67cf0b1..5f2b850 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,3 +29,7 @@ criterion = { version = "0.3", features = ["html_reports"] } [[bench]] name = "benchmarks" harness = false + +[features] +default = [] +shortdeck = [] diff --git a/Dockerfile b/Dockerfile index b3d512c..c6c64dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,9 @@ RUN cargo build --release # Binary stage FROM debian:bookworm-slim AS binary + +WORKDIR /output + RUN apt-get update && \ apt-get install -y libssl3 ca-certificates && \ rm -rf /var/lib/apt/lists/* diff --git a/src/cards/card.rs b/src/cards/card.rs index 31c8edf..dbb5a7a 100644 --- a/src/cards/card.rs +++ b/src/cards/card.rs @@ -1,6 +1,12 @@ use super::rank::Rank; use super::suit::Suit; +#[cfg(not(feature = "shortdeck"))] +pub const CARD_COUNT_IN_DECK: usize = 52; + +#[cfg(feature = "shortdeck")] +pub const CARD_COUNT_IN_DECK: usize = 36; + /// Card represents a playing card /// it is a tuple of Rank and Suit #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -15,8 +21,13 @@ impl Card { } pub fn draw() -> Card { use rand::Rng; - let ref mut rng = rand::thread_rng(); - Card::from(rng.gen_range(0..52) as u8) + let rng = &mut rand::thread_rng(); + let suit = rng.gen_range(0..4) as u8; + #[cfg(not(feature = "shortdeck"))] + let rank = rng.gen_range(0..13) as u8; + #[cfg(feature = "shortdeck")] + let rank = rng.gen_range(4..13) as u8; + Card::from((Rank::from(rank), Suit::from(suit))) } } diff --git a/src/cards/evaluator.rs b/src/cards/evaluator.rs index bcf812d..80dc7cc 100644 --- a/src/cards/evaluator.rs +++ b/src/cards/evaluator.rs @@ -16,6 +16,16 @@ impl From for Evaluator { } } +#[cfg(not(feature = "shortdeck"))] +const WHEEL: u16 = 0b_1000000001111; +#[cfg(feature = "shortdeck")] +const WHEEL: u16 = 0b_1000011110000; + +#[cfg(not(feature = "shortdeck"))] +const LOWEST_STRAIGHT_RANK: Rank = Rank::Five; +#[cfg(feature = "shortdeck")] +const LOWEST_STRAIGHT_RANK: Rank = Rank::Nine; + impl Evaluator { pub fn find_ranking(&self) -> Ranking { None.or_else(|| self.find_flush()) @@ -93,10 +103,8 @@ impl Evaluator { }) } - /// - fn find_rank_of_straight(&self, hand: Hand) -> Option { - let wheel = 0b_1000000001111u16; + let wheel = WHEEL; let ranks = u16::from(hand); let mut bits = ranks; bits &= bits << 1; @@ -106,7 +114,7 @@ impl Evaluator { if bits > 0 { Some(Rank::from(bits)) } else if wheel == (wheel & ranks) { - Some(Rank::Five) + Some(LOWEST_STRAIGHT_RANK) } else { None } @@ -222,6 +230,7 @@ mod tests { } #[test] + #[cfg(not(feature = "shortdeck"))] fn wheel_straight() { assert!( Evaluator::from(Hand::from("As 2h 3d 4c 5s")).find_ranking() @@ -230,6 +239,16 @@ mod tests { } #[test] + #[cfg(feature = "shortdeck")] + fn shortdeck_wheel_straight() { + assert_eq!( + Evaluator::from(Hand::from("6s 7h 8d 9c As")).find_ranking(), + Ranking::Straight(Rank::Nine) + ); + } + + #[test] + #[cfg(not(feature = "shortdeck"))] fn wheel_straight_flush() { assert!( Evaluator::from(Hand::from("As 2s 3s 4s 5s")).find_ranking() @@ -237,6 +256,15 @@ mod tests { ); } + #[test] + #[cfg(feature = "shortdeck")] + fn wheel_straight_flush() { + assert!( + Evaluator::from(Hand::from("As 6s 7s 8s 9s")).find_ranking() + == Ranking::StraightFlush(Rank::Nine) + ); + } + #[test] fn seven_card_hand() { assert!( diff --git a/src/cards/hands.rs b/src/cards/hands.rs index 96368c8..9cee3cc 100644 --- a/src/cards/hands.rs +++ b/src/cards/hands.rs @@ -102,6 +102,9 @@ impl From<(usize, Hand)> for HandIterator { fn from((n, mask): (usize, Hand)) -> Self { let mut this = Self { next: (1 << n) - 1, + #[cfg(feature = "shortdeck")] + mask: u64::from(mask) | 0b1111111111111111, // remove 2-5 cards + #[cfg(not(feature = "shortdeck"))] mask: u64::from(mask), }; while this.next & this.mask > 0 && !this.exhausted() { @@ -113,6 +116,8 @@ impl From<(usize, Hand)> for HandIterator { #[cfg(test)] mod tests { + use crate::cards::card::CARD_COUNT_IN_DECK; + use super::*; #[test] @@ -123,9 +128,10 @@ mod tests { #[test] fn n_choose_1() { let iter = HandIterator::from((1, Hand::empty())); - assert_eq!(iter.count(), 52); + assert_eq!(iter.count(), CARD_COUNT_IN_DECK); } #[test] + #[cfg(not(feature = "shortdeck"))] fn n_choose_2() { let iter = HandIterator::from((2, Hand::empty())); assert_eq!(iter.count(), 1326); @@ -138,12 +144,14 @@ mod tests { assert_eq!(iter.count(), 0); } #[test] + #[cfg(not(feature = "shortdeck"))] fn n_choose_1_mask_4() { let mask = Hand::from(0b1111); let iter = HandIterator::from((1, mask)); assert_eq!(iter.count(), 48); } #[test] + #[cfg(not(feature = "shortdeck"))] fn n_choose_2_mask_4() { let mask = Hand::from(0b1111); let iter = HandIterator::from((2, mask)); @@ -151,6 +159,7 @@ mod tests { } #[test] + #[cfg(not(feature = "shortdeck"))] fn choose_3() { let mut iter = HandIterator::from((3, Hand::empty())); assert!(iter.next() == Some(Hand::from(0b00111))); @@ -166,6 +175,14 @@ mod tests { } #[test] + #[cfg(feature = "shortdeck")] + fn choose_2_shortdeck() { + let mut iter = HandIterator::from((2, Hand::from(0))); + assert_eq!(iter.next(), Some(Hand::from(0b110000000000000000))); + } + + #[test] + #[cfg(not(feature = "shortdeck"))] fn choose_3_from_5() { let mask = Hand::from(0b_________________1111_00_1).complement(); let mut iter = HandIterator::from((3, mask)); diff --git a/src/cards/observations.rs b/src/cards/observations.rs index 31acd0f..ec0436b 100644 --- a/src/cards/observations.rs +++ b/src/cards/observations.rs @@ -23,7 +23,12 @@ impl From for ObservationIterator { // need to make it work with Street::Pref (Hand::empty()) // and it should compose well with a separate HandIterator, so // ObsIterator can reap the benefit + + // start with first card + #[cfg(not(feature = "shortdeck"))] let pocket = Hand::from(0b11); + #[cfg(feature = "shortdeck")] + let pocket = Hand::from(0b11_0000_0000_0000_0000); let inner = HandIterator::from((street.n_observed(), pocket)); let mut outer = HandIterator::from((2, Hand::empty())); match street { @@ -89,28 +94,28 @@ mod tests { fn n_pref() { let street = Street::Pref; let iter = ObservationIterator::from(street); - assert!(iter.combinations() == street.n_observations()); - assert!(iter.combinations() == iter.count()); + assert_eq!(iter.combinations(), street.n_observations()); + assert_eq!(iter.combinations(), iter.count()); } #[test] fn n_flop() { let street = Street::Flop; let iter = ObservationIterator::from(street); - assert!(iter.combinations() == street.n_observations()); - assert!(iter.combinations() == iter.count()); + assert_eq!(iter.combinations(), street.n_observations()); + assert_eq!(iter.combinations(), iter.count()); } #[test] fn n_turn() { let street = Street::Turn; let iter = ObservationIterator::from(street); - assert!(iter.combinations() == street.n_observations()); - assert!(iter.combinations() == iter.count()); + assert_eq!(iter.combinations(), street.n_observations()); + assert_eq!(iter.combinations(), iter.count()); } #[test] fn n_rive() { let street = Street::Rive; let iter = ObservationIterator::from(street); - assert!(iter.combinations() == street.n_observations()); - assert!(iter.combinations() == iter.count()); + assert_eq!(iter.combinations(), street.n_observations()); + assert_eq!(iter.combinations(), iter.count()); } } diff --git a/src/cards/ranking.rs b/src/cards/ranking.rs index 336353f..51cf6cd 100644 --- a/src/cards/ranking.rs +++ b/src/cards/ranking.rs @@ -4,6 +4,7 @@ use super::rank::Rank; /// /// This is a simplified version of the hand's value, and does not include the hand's kicker cards. /// The value is ordered by the hand's Strength, and the kicker cards are used to break ties. +#[cfg(feature = "shortdeck")] #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord)] pub enum Ranking { HighCard(Rank), // 4 kickers @@ -17,6 +18,20 @@ pub enum Ranking { StraightFlush(Rank), // 0 kickers MAX, // useful for showdown implementation } +#[cfg(not(feature = "shortdeck"))] +#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord)] +pub enum Ranking { + HighCard(Rank), // 4 kickers + OnePair(Rank), // 3 kickers + TwoPair(Rank, Rank), // 1 kickers + ThreeOAK(Rank), // 2 kickers + Straight(Rank), // 0 kickers + FullHouse(Rank, Rank), // 0 kickers + Flush(Rank), // 0 kickers + FourOAK(Rank), // 1 kickers + StraightFlush(Rank), // 0 kickers + MAX, // useful for showdown implementation +} impl std::fmt::Display for Ranking { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/src/cards/street.rs b/src/cards/street.rs index e224507..0e59e6c 100644 --- a/src/cards/street.rs +++ b/src/cards/street.rs @@ -42,6 +42,8 @@ impl Street { Self::Rive => panic!("terminal"), } } + + #[cfg(not(feature = "shortdeck"))] pub const fn n_observations(&self) -> usize { match self { Self::Pref => 0_______1_326, @@ -50,6 +52,18 @@ impl Street { Self::Rive => 2_809_475_760, } } + + #[cfg(feature = "shortdeck")] + pub const fn n_observations(&self) -> usize { + match self { + Self::Pref => 0_________630, + Self::Flop => 0___3_769_920, + Self::Turn => 0__29_216_880, + Self::Rive => 0_175_301_280, + } + } + + #[cfg(not(feature = "shortdeck"))] pub const fn n_isomorphisms(&self) -> usize { match self { Self::Pref => 0_________169, diff --git a/src/clustering/layer.rs b/src/clustering/layer.rs index 972fa9c..4044b49 100644 --- a/src/clustering/layer.rs +++ b/src/clustering/layer.rs @@ -161,11 +161,13 @@ impl Layer { self.street, self.street.prev() ); - let progress = Self::progress(self.street.prev().n_isomorphisms()); - let projection = Observation::exhaust(self.street.prev()) - .filter(|o| Isomorphism::is_canonical(o)) - .map(|o| Isomorphism::from(o)) // isomorphism translation - .collect::>() // isomorphism translation + let isomorphisms = Observation::exhaust(self.street.prev()) + .filter(Isomorphism::is_canonical) + .map(Isomorphism::from) // isomorphism translation + .collect::>(); + + let progress = Self::progress(isomorphisms.len()); + let projection = isomorphisms .into_par_iter() .map(|inner| (inner, self.lookup.projection(&inner))) .inspect(|_| progress.inc(1))