Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ckc-rs"
description = "Poker hand evaluation library"
version = "0.1.16"
version = "0.1.17"
authors = ["electronicpanopticon <[email protected]>"]
repository = "https://github.com/ImperialBower/ckc-rs.git"
homepage = "https://github.com/ImperialBower/ckc-rs"
Expand All @@ -13,10 +13,8 @@ exclude = [".github/workflows/*", ".gitignore", "Cargo.lock"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log = { version = "0.4.21", default-features = false }
serde = { version = "1.0.197", default-features = false, features = ["derive"] }
strum = { version = "0.26.2", features = ["derive"] }
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
strum = { version = "0.27.1", features = ["derive"] }

[dev-dependencies]
cardpack = "0.5.1"
rstest = "0.18.2"
rstest = "0.25.0"
8 changes: 4 additions & 4 deletions src/cards/five.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Five {
while low <= high {
mid = (high + low) >> 1; // divide by two

let product = crate::lookups::PRODUCTS[mid] as usize;
let product = crate::lookups::products::PRODUCTS[mid] as usize;
if key < product {
high = mid - 1;
} else if key > product {
Expand All @@ -103,15 +103,15 @@ impl Five {
}

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

#[allow(clippy::cast_possible_truncation)]
fn unique(index: usize) -> HandRankValue {
if index > Five::POSSIBLE_COMBINATIONS {
return CardNumber::BLANK as HandRankValue;
}
crate::lookups::UNIQUE_5[index]
crate::lookups::unique5::UNIQUE_5[index]
}

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

let hrv: HandRankValue = if self.is_flush() {
crate::lookups::FLUSHES[i]
crate::lookups::flushes::FLUSHES[i]
} else {
// Continue to evaluate if it's not a flush and the cards aren't
// unique (straight or high card).
Expand Down
6 changes: 1 addition & 5 deletions src/cards/two.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ impl Two {
pub fn get_gap(&self) -> u8 {
let s = self.sort();
let distance_between = s.first().get_card_rank() as u8 - s.second().get_card_rank() as u8;
if distance_between < 1 {
0
} else {
distance_between - 1
}
distance_between.saturating_sub(1)
}

#[must_use]
Expand Down
5 changes: 0 additions & 5 deletions src/lookups/examples.snip

This file was deleted.

242 changes: 242 additions & 0 deletions src/lookups/flushes.rs

Large diffs are not rendered by default.

418 changes: 0 additions & 418 deletions src/lookups/flushes.snip

This file was deleted.

14 changes: 4 additions & 10 deletions src/lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@
/// flushes and straight-flushes. entries containing a zero
/// mean that combination is not possible with a five-card
/// flush hand.
pub const FLUSHES: [u16; 7937] = include!("flushes.snip");

/// this is a table lookup for all non-flush hands consisting
/// of five unique ranks (i.e. either Straights or High Card
/// hands). it's similar to the above "flushes" array.
pub const UNIQUE_5: [u16; 7937] = include!("unique5.snip");

/// those two arrays are needed for original evaluator version
pub const PRODUCTS: [u32; 4888] = include!("products.snip");
pub const VALUES: [u16; 4888] = include!("values.snip");
pub mod flushes;
pub mod products;
pub mod unique5;
pub mod values;
359 changes: 359 additions & 0 deletions src/lookups/products.rs

Large diffs are not rendered by default.

629 changes: 0 additions & 629 deletions src/lookups/products.snip

This file was deleted.

249 changes: 249 additions & 0 deletions src/lookups/unique5.rs

Large diffs are not rendered by default.

426 changes: 0 additions & 426 deletions src/lookups/unique5.snip

This file was deleted.

258 changes: 258 additions & 0 deletions src/lookups/values.rs

Large diffs are not rendered by default.

448 changes: 0 additions & 448 deletions src/lookups/values.snip

This file was deleted.