Files
pokerfreak/tests/position_advise.rs
T
mmintel 04d5251acf Welt ohne fremden Namen: Pruefordner vollstaendig mitkopieren, Engine nur im eigenen Baum
Die Welt nannte 'pokerfreak' nur noch in zwei Harness-Zeilen - der Rest waren veraltete
Rust-Pruefungen im Pruefordner, die der Aufbau nie auffrischte.
2026-11-01 23:37:11 +01:00

66 lines
2.2 KiB
Rust

mod position_fixture;
use rechner::exploit::thresholds::Thresholds;
use rechner::game::{ActionRecord, Spot};
use rechner::preflop::advise::advise;
use rechner::preflop::position::Position;
use rechner::preflop::seat_position::seat_position;
use position_fixture::{post_bb, post_sb, spot};
fn unopened(hero: u8, villains: &[u8], button: Option<u8>, history: Vec<ActionRecord>) -> Spot {
Spot { button_seat: button, ..spot(6, hero, villains, history) }
}
#[test]
fn seat_position_uses_the_explicit_button() {
let s = unopened(0, &[1], Some(3), vec![]);
assert_eq!(seat_position(&s, 0), Position::Early);
assert_eq!(seat_position(&s, 3), Position::Button);
assert_eq!(seat_position(&s, 5), Position::BigBlind);
}
#[test]
fn seat_position_uses_the_inferred_button() {
let s = unopened(0, &[1], None, vec![post_sb(4), post_bb(5)]);
assert_eq!(seat_position(&s, 3), Position::Button);
assert_eq!(seat_position(&s, 4), Position::SmallBlind);
assert_eq!(seat_position(&s, 2), Position::Cutoff);
}
#[test]
fn seat_position_stays_unknown_without_any_hint() {
let s = unopened(0, &[1], None, vec![]);
assert_eq!(seat_position(&s, 2), Position::Unknown);
}
#[test]
fn advise_reasons_name_the_inferred_position() {
let inferred = unopened(3, &[0], None, vec![post_sb(4), post_bb(5)]);
let plan = advise(&inferred, &Thresholds::BASE);
assert!(plan.reason.starts_with("BTN "), "{}", plan.reason);
}
#[test]
fn advise_with_an_inferred_button_equals_advise_with_the_explicit_one() {
for hero in 0..6u8 {
let hist = vec![post_sb(4), post_bb(5)];
let a = unopened(hero, &[0, 5], None, hist.clone());
let b = unopened(hero, &[0, 5], Some(3), hist);
assert_eq!(advise(&a, &Thresholds::BASE), advise(&b, &Thresholds::BASE));
}
}
#[test]
fn advise_without_button_or_history_keeps_the_unknown_label() {
let s = unopened(3, &[0], None, vec![]);
let plan = advise(&s, &Thresholds::BASE);
assert!(plan.reason.starts_with("pos? "), "{}", plan.reason);
}
#[test]
fn explicit_button_beats_a_conflicting_history() {
let s = unopened(3, &[0], Some(1), vec![post_sb(4), post_bb(5)]);
let plan = advise(&s, &Thresholds::BASE);
assert!(!plan.reason.starts_with("BTN "), "{}", plan.reason);
}