rs_poker 3.0.1

A library to help with any Rust code dealing with poker. This includes card values, suits, hands, hand ranks, 5 card hand strength calculation, 7 card hand strength calulcation, and monte carlo game simulation helpers.
Documentation
use crate::arena::{GameState, Historian};

/// A historian that will always fail to record an action
/// and will return an error.
///
/// This historian is useful for testing the behavior of the simulation
pub struct FailingHistorian;

impl Historian for FailingHistorian {
    fn record_action(
        &mut self,
        _id: u128,
        _game_state: &GameState,
        _action: crate::arena::action::Action,
    ) -> Result<(), crate::arena::historian::HistorianError> {
        Err(crate::arena::historian::HistorianError::UnableToRecordAction)
    }
}

#[cfg(test)]
mod tests {
    use crate::arena::{HoldemSimulationBuilder, agent::CallingAgent};

    use super::*;

    #[test]
    #[should_panic]
    fn test_panic_fail_historian() {
        let historian = Box::new(FailingHistorian);

        let stacks = vec![100.0; 3];
        let game_state = GameState::new_starting(stacks, 10.0, 5.0, 0.0, 0);
        let mut rng = rand::rng();

        let mut sim = HoldemSimulationBuilder::default()
            .game_state(game_state)
            .agents(vec![
                Box::new(CallingAgent {}),
                Box::new(CallingAgent {}),
                Box::new(CallingAgent {}),
            ])
            .panic_on_historian_error(true)
            .historians(vec![historian])
            .build()
            .unwrap();

        // This should panic since panic_on_historian_error is set to true
        // and the historian will always fail to record an action
        sim.run(&mut rng);
    }
}