From 23a6fe6ed282d40e080eb17e50b9961c249830df Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 6 Nov 2026 18:30:50 +0100 Subject: [PATCH] Leiter: Engine bekommt Gegner-Reads (Benchmark-Treue) Die Leiter testete die Engine blind - Villains hatten kein Profil, also war die ganze Ausbeutungslogik auf dem Pruefstand aus. Jetzt fuettert der Tisch jeder Villain den Read, den ein eingespieltes HUD zeigen wuerde (sim/reads), je Gegner-Archetyp. Vertrag per Test: jeder Stil klassifiziert korrekt (Fish/Station -> breit-schwach, Maniac -> loose-aggressiv, Reg/Nit sauber). Nur Sim/Benchmark, nicht der Request-Pfad - kein Einfluss auf den Live-Bot. --- src/sim/mod.rs | 1 + src/sim/reads.rs | 35 +++++++++++++++++++++++++++++++++++ src/sim/table.rs | 5 ++++- tests/sim_reads.rs | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/sim/reads.rs create mode 100644 tests/sim_reads.rs diff --git a/src/sim/mod.rs b/src/sim/mod.rs index 5b5d7e60..6ece4351 100644 --- a/src/sim/mod.rs +++ b/src/sim/mod.rs @@ -7,5 +7,6 @@ pub mod luck; pub mod opponent; pub mod paired; pub mod reader; +pub mod reads; pub mod session; pub mod table; diff --git a/src/sim/reads.rs b/src/sim/reads.rs new file mode 100644 index 00000000..5d7f6036 --- /dev/null +++ b/src/sim/reads.rs @@ -0,0 +1,35 @@ +//! The read a converged HUD would show for each fixed opponent. The ladder plays the engine against +//! behavioural opponents; to measure the EXPLOIT brain the engine must also SEE them, the way it sees +//! vpip/pfr/foldToBet/aggression at a real table. These are representative, stable profiles for each +//! archetype (a long session converges to them, since the sim opponents are fixed-style), so the +//! engine's opponent classification (`exploit::style::classify`) lands on the matching style. +//! +//! `RandomLegal` has no coherent style, so it carries no read (the engine plays it blind). + +use super::opponent::Opponent; +use super::reader::Style; +use crate::exploit::profile::Profile; + +fn p(vpip: f64, pfr: f64, fold_to_bet: f64, aggression: f64) -> Option { + Some(Profile { + vpip: Some(vpip), + pfr: Some(pfr), + fold_to_bet: Some(fold_to_bet), + aggression: Some(aggression), + }) +} + +/// The HUD read the engine is handed for this opponent, or `None` when the opponent has no readable +/// style. Values mirror the opponent's behaviour: the calling station almost never folds and never +/// raises; the fish calls far too light; the maniac is loose and very aggressive; the nit is tight. +pub fn opponent_profile(opponent: Opponent) -> Option { + match opponent { + Opponent::CallingStation => p(0.75, 0.00, 0.03, 0.03), + Opponent::Folder => p(0.02, 0.00, 0.95, 0.00), + Opponent::RandomLegal => None, + Opponent::Reader(Style::Fish) => p(0.55, 0.05, 0.15, 0.10), + Opponent::Reader(Style::Reg) => p(0.26, 0.19, 0.50, 0.50), + Opponent::Reader(Style::Nit) => p(0.13, 0.10, 0.72, 0.35), + Opponent::Reader(Style::Maniac) => p(0.55, 0.38, 0.25, 0.90), + } +} diff --git a/src/sim/table.rs b/src/sim/table.rs index e0af895d..91c497e4 100644 --- a/src/sim/table.rs +++ b/src/sim/table.rs @@ -172,9 +172,12 @@ impl Table<'_> { if view.min_raise_to.is_some() { legal.push(ActionKind::Raise); } + // The engine sees the opponents the way a converged HUD would (`sim::reads`), so the ladder + // measures the exploit brain instead of playing it blind. + let read = super::reads::opponent_profile(self.setup.opponent); let villains = (0..self.players()) .filter(|j| *j != i) - .map(|j| Villain { seat: j as u8 + 1, stack: self.stack[j], folded: self.folded[j], profile: None }) + .map(|j| Villain { seat: j as u8 + 1, stack: self.stack[j], folded: self.folded[j], profile: read }) .collect(); let decision_seed = self.setup.seed ^ (self.result.hero_decisions as u64 + 1).wrapping_mul(0x9E37_79B9_7F4A_7C15); Spot { diff --git a/tests/sim_reads.rs b/tests/sim_reads.rs new file mode 100644 index 00000000..5fc38f1a --- /dev/null +++ b/tests/sim_reads.rs @@ -0,0 +1,36 @@ +//! Benchmark-Treue: der Read, den die Leiter der Engine je Gegner gibt, muss auf den PASSENDEN +//! Ausbeutungs-Stil klassifizieren - sonst misst die Leiter das Falsche. Besonders der Riegel gegen +//! das Zocken: ein Maniac darf NIE als breit-schwach (Calling Station) durchgehen. + +use rechner::exploit::style::{classify, Style}; +use rechner::sim::opponent::Opponent; +use rechner::sim::reader::Style as SimStyle; +use rechner::sim::reads::opponent_profile; + +fn stil(o: Opponent) -> Style { + classify(&opponent_profile(o).expect("Gegner mit lesbarem Stil")) +} + +#[test] +fn calling_station_und_fisch_sind_breit_schwach() { + assert_eq!(stil(Opponent::CallingStation), Style::CallingStation); + assert_eq!(stil(Opponent::Reader(SimStyle::Fish)), Style::CallingStation); +} + +#[test] +fn der_maniac_ist_loose_aggressiv_nicht_breit_schwach() { + // Kernregel: gegen Aggression wird NICHT erleichtert - der Maniac darf nie als Station zaehlen. + assert_eq!(stil(Opponent::Reader(SimStyle::Maniac)), Style::LooseAggressive); +} + +#[test] +fn reg_ist_regular_nit_ist_nit() { + assert_eq!(stil(Opponent::Reader(SimStyle::Reg)), Style::Regular); + assert_eq!(stil(Opponent::Reader(SimStyle::Nit)), Style::Nit); +} + +#[test] +fn der_folder_ist_ein_nit_das_random_legal_ohne_read() { + assert_eq!(stil(Opponent::Folder), Style::Nit); + assert!(opponent_profile(Opponent::RandomLegal).is_none()); +}