Files
pokerfreak/src/sim/opponent.rs
T
mmintelandClaude Opus 5.5 c03530a1c4 Welt-Population (Pillar 1): reiche synthetische Gegner, World-Memory-API, Welt-Leiter
Neue Gegner neben den alten (sim::welt): Sizing-Tells, Textur-/Positions-
frequenzen, Intra-Archetyp-Varianz, Pace-Tell, Showdown-Reveals, Kontrollarm
balanciert. sim::welt_memory + SessionMemory::world(): (Size,Staerke)-Paare,
Textur x Position-Zellen, Showdowns, Tank. Neue Leiter src/bin/welt_leiter.rs.
Alte Archetypen und nemesis_read bit-identisch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 13:40:58 +01:00

87 lines
3.4 KiB
Rust

use super::reader::{Rules, Style};
use super::welt::Persona;
use crate::rng::Rng;
/// What a fixed opponent sees: the price and, if raising is possible, its bounds
/// (total street amounts, like `minRaiseTo`/`maxRaiseTo`).
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct View {
pub to_call: f64,
pub min_raise_to: Option<f64>,
pub max_raise_to: Option<f64>,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Act {
Fold,
Check,
Call,
RaiseTo(f64),
}
/// Fixed opponents for the strength measurement. Only `Reader` and `Styled` look at their cards.
/// Not `Eq` because `Styled` carries f64 thresholds; `PartialEq`/`Copy` are enough everywhere it is used.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Opponent {
/// Calls every bet, never raises.
CallingStation,
/// Folds to any price, checks when it is free.
Folder,
/// Uniform among the legal options; a raise is uniform between min and max.
RandomLegal,
/// Plays its cards in a fixed style; the table hands it its reading (`Style::act`).
Reader(Style),
/// Plays its cards by an explicit drawn ruleset (`sim::population`): one individual opponent,
/// read-driven like `Reader` but with no named style and no authored oracle profile (the engine
/// must infer it). The table hands it its reading (`reader::act_with`).
Styled(Rules),
/// A drawn individual of the world population (`sim::welt`): size, texture, position and pace
/// tells, and showdown reveals into `SessionMemory::world`. The table plays it through `welt::act`.
Welt(Persona),
}
impl Opponent {
pub const ALL: [Opponent; 3] = [Opponent::CallingStation, Opponent::Folder, Opponent::RandomLegal];
pub fn name(self) -> &'static str {
match self {
Opponent::CallingStation => "calling station",
Opponent::Folder => "folder",
Opponent::RandomLegal => "random legal",
Opponent::Reader(style) => style.name(),
Opponent::Styled(_) => "drawn",
Opponent::Welt(p) => p.label,
}
}
pub fn act(self, view: View, rng: Rng) -> (Act, Rng) {
let facing = view.to_call > 0.0;
let passive = if facing { Act::Call } else { Act::Check };
match self {
// Without a reading there is nothing to play on; the table never asks these this way
// (it routes reading opponents through `Style::act` / `reader::act_with`).
Opponent::Reader(_) | Opponent::Styled(_) | Opponent::Welt(_) => (if facing { Act::Fold } else { Act::Check }, rng),
Opponent::CallingStation => (passive, rng),
Opponent::Folder => (if facing { Act::Fold } else { Act::Check }, rng),
Opponent::RandomLegal => {
let raise = view.min_raise_to.zip(view.max_raise_to);
let mut options = vec![passive];
if facing {
options.push(Act::Fold);
}
if let Some((min, _)) = raise {
options.push(Act::RaiseTo(min));
}
let (i, rng) = rng.below(options.len() as u64);
match (options[i as usize], raise) {
(Act::RaiseTo(_), Some((min, max))) => {
let (u, rng) = rng.unit();
(Act::RaiseTo(min + u * (max - min)), rng)
}
(act, _) => (act, rng),
}
}
}
}
}