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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pkcore"
description = "Prototype core poker library."
version = "0.0.28"
version = "0.0.29"
rust-version = "1.91.0"
edition = "2024"
authors = ["electronicpanopticon <gaoler@electronicpanopticon.com>"]
Expand Down
18 changes: 7 additions & 11 deletions examples/bcrepl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use pkcore::PKError;
use pkcore::play::stages::deal_eval::DealEval;
use pkcore::prelude::HoleCards;
use pkcore::util::terminal::Terminal;
use std::collections::HashMap;

/// OK, this makes me sad. My new shiny pkcore library takes over twice as long to run a single calc
///
Expand All @@ -27,14 +28,15 @@ use pkcore::util::terminal::Terminal;
/// `A♠ A♥ A♦ A♣`
fn main() {
env_logger::init();
let mut cache: HashMap<HoleCards, DealEval> = HashMap::new();
loop {
read_input();
read_input(&mut cache);
}
}

fn read_input() {
fn read_input(cache: &mut HashMap<HoleCards, DealEval>) {
match Terminal::receive_cards_in_twos("hole cards> ") {
Ok(twos) => match work(twos) {
Ok(twos) => match work(twos, cache) {
Ok(_) => {}
Err(e) => println!("{:?}", e),
},
Expand All @@ -44,18 +46,12 @@ fn read_input() {
}
}

fn work(hands: HoleCards) -> Result<(), PKError> {
fn work(hands: HoleCards, cache: &mut HashMap<HoleCards, DealEval>) -> Result<(), PKError> {
let now = std::time::Instant::now();

let results = DealEval::new(hands);
let results = cache.entry(hands).or_insert_with_key(|h| DealEval::new(h.clone()));

// let case_events = hands.bcm_case_evals()?;
// let case_events = hands.bcm_case_evals()?;
// let case_events = hands.bcm_rayon_case_evals()?;
// let wins = case_events.wins();
// let results = WinResults::from_wins(&wins, hands.len());
println!("{results}");

println!("Elapsed: {:.2?}", now.elapsed());
Ok(())
}
2 changes: 1 addition & 1 deletion src/play/hole_cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use std::vec::IntoIter;
/// is fleeting.
///
/// TODO: Refactor to Two;
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)]
pub struct HoleCards(Vec<Two>);

impl HoleCards {
Expand Down