Skip to content

Commit 56fabe6

Browse files
committed
replaced snip files
1 parent 2a977b4 commit 56fabe6

File tree

13 files changed

+1121
-1951
lines changed

13 files changed

+1121
-1951
lines changed

Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "ckc-rs"
33
description = "Poker hand evaluation library"
4-
version = "0.1.16"
4+
version = "0.1.17"
55
authors = ["electronicpanopticon <[email protected]>"]
66
repository = "https://github.com/ImperialBower/ckc-rs.git"
77
homepage = "https://github.com/ImperialBower/ckc-rs"
@@ -13,10 +13,8 @@ exclude = [".github/workflows/*", ".gitignore", "Cargo.lock"]
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16-
log = { version = "0.4.21", default-features = false }
17-
serde = { version = "1.0.197", default-features = false, features = ["derive"] }
18-
strum = { version = "0.26.2", features = ["derive"] }
16+
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
17+
strum = { version = "0.27.1", features = ["derive"] }
1918

2019
[dev-dependencies]
21-
cardpack = "0.5.1"
22-
rstest = "0.18.2"
20+
rstest = "0.25.0"

src/cards/five.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Five {
9090
while low <= high {
9191
mid = (high + low) >> 1; // divide by two
9292

93-
let product = crate::lookups::PRODUCTS[mid] as usize;
93+
let product = crate::lookups::products::PRODUCTS[mid] as usize;
9494
if key < product {
9595
high = mid - 1;
9696
} else if key > product {
@@ -103,15 +103,15 @@ impl Five {
103103
}
104104

105105
fn not_unique(&self) -> HandRankValue {
106-
crate::lookups::VALUES[Five::find_in_products(self.multiply_primes())]
106+
crate::lookups::values::VALUES[Five::find_in_products(self.multiply_primes())]
107107
}
108108

109109
#[allow(clippy::cast_possible_truncation)]
110110
fn unique(index: usize) -> HandRankValue {
111111
if index > Five::POSSIBLE_COMBINATIONS {
112112
return CardNumber::BLANK as HandRankValue;
113113
}
114-
crate::lookups::UNIQUE_5[index]
114+
crate::lookups::unique5::UNIQUE_5[index]
115115
}
116116

117117
//endregion
@@ -179,7 +179,7 @@ impl HandRanker for Five {
179179
let i = self.or_rank_bits() as usize;
180180

181181
let hrv: HandRankValue = if self.is_flush() {
182-
crate::lookups::FLUSHES[i]
182+
crate::lookups::flushes::FLUSHES[i]
183183
} else {
184184
// Continue to evaluate if it's not a flush and the cards aren't
185185
// unique (straight or high card).

src/cards/two.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,7 @@ impl Two {
148148
pub fn get_gap(&self) -> u8 {
149149
let s = self.sort();
150150
let distance_between = s.first().get_card_rank() as u8 - s.second().get_card_rank() as u8;
151-
if distance_between < 1 {
152-
0
153-
} else {
154-
distance_between - 1
155-
}
151+
distance_between.saturating_sub(1)
156152
}
157153

158154
#[must_use]

src/lookups/examples.snip

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/lookups/flushes.rs

Lines changed: 242 additions & 0 deletions
Large diffs are not rendered by default.

src/lookups/flushes.snip

Lines changed: 0 additions & 418 deletions
This file was deleted.

src/lookups/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@
3030
/// flushes and straight-flushes. entries containing a zero
3131
/// mean that combination is not possible with a five-card
3232
/// flush hand.
33-
pub const FLUSHES: [u16; 7937] = include!("flushes.snip");
34-
35-
/// this is a table lookup for all non-flush hands consisting
36-
/// of five unique ranks (i.e. either Straights or High Card
37-
/// hands). it's similar to the above "flushes" array.
38-
pub const UNIQUE_5: [u16; 7937] = include!("unique5.snip");
39-
40-
/// those two arrays are needed for original evaluator version
41-
pub const PRODUCTS: [u32; 4888] = include!("products.snip");
42-
pub const VALUES: [u16; 4888] = include!("values.snip");
33+
pub mod flushes;
34+
pub mod products;
35+
pub mod unique5;
36+
pub mod values;

src/lookups/products.rs

Lines changed: 359 additions & 0 deletions
Large diffs are not rendered by default.

src/lookups/products.snip

Lines changed: 0 additions & 629 deletions
This file was deleted.

src/lookups/unique5.rs

Lines changed: 249 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)