PokerIntel je Feld gewichtet hinter POKERINTEL (aus = bitgleich), Sim-Lesemodus @hud

Schaetzer (lesen/pokerintel.py): vpip/pfr tragen ~60 Motorhaende, foldToBet ~8 statt pauschal 20.
hud_profile teilt Draht und Sim; ReadMode::Hud zieht verrauschte PokerIntel-Zahlen (Beta, gemessenes m)
aus einer Vorsession und liest sie wie der Draht.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 12:44:04 +01:00
co-authored by Claude Opus 5.5
parent a448443a63
commit 1229ded0b9
10 changed files with 1529 additions and 1252 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ QUELLE = os.environ.get("COINPOKER_KERN_QUELLE", os.path.join(BASE, ".."))
SCHALTER_DATEI = os.path.join(BASE, "..", "betrieb", "kern_schalter.txt")
BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "GRUNDSTRATEGIE", "OPEN_JAM",
"SOLVER_RIVER", "SOLVER_TURN", "SOLVER_FLOP", "SOLVER_RIVER3", "SOLVER_TURN3", "SOLVER_FLOP3",
"RAKE_LIVE")
"RAKE_LIVE", "POKERINTEL")
# Pfade gehoeren nicht in die Arm-Marke.
OHNE_MARKE = ("GRUNDSTRATEGIE",)
+691 -691
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -161,6 +161,7 @@ fn read_of(name: &str) -> (&str, ReadMode) {
match name.split_once('@') {
Some((base, "blind")) => (base, ReadMode::Blind),
Some((base, "oracle")) => (base, ReadMode::Oracle),
Some((base, "hud")) => (base, ReadMode::Hud),
Some((_, other)) => panic!("unbekannter Lesemodus @{other}"),
None => (name, ReadMode::Memory),
}
+129 -4
View File
@@ -1,4 +1,4 @@
//! How much a profile is worth: its sample. Opponent statistics come without a hand count, so
//! How much a profile is worth: its sample. Opponent statistics come without a hand count, so
//! the caller sends one (`villains[].profile.hands`, extension, not in VERTRAG.md). Few hands
//! mean the numbers are mostly noise; they are pulled toward the population before anything
//! reads them.
@@ -41,7 +41,7 @@ pub const PRIOR: Profile = Profile {
river_bluff_shown: None,
};
/// Postflop moves at which an aggression read and the population weigh the same — the session
/// Postflop moves at which an aggression read and the population weigh the same — the session
/// memory's half-life (`sim::memory::CONFIDENCE_HALF`), so a live read earns trust as fast as a
/// simulated one.
pub const AGGRESSION_HALF: f64 = 30.0;
@@ -101,6 +101,74 @@ pub fn shrink_aggression(profile: Profile, raw: Option<f64>, actions: f64) -> Pr
Profile { aggression: pull(raw, PRIOR.aggression, w), aggression_confidence: Some(w), ..profile }
}
/// Share of a HUD's hands in which the player faces a c-bet / a 3-bet after opening / a bet after
/// checking (rough 6-max frequencies): the effective sample of each line stat.
pub const CBET_SPOT_SHARE: f64 = 0.15;
pub const THREE_BET_SPOT_SHARE: f64 = 0.04;
pub const CHECK_RAISE_SPOT_SHARE: f64 = 0.10;
/// The base sample `lesen/profil.py` gives a believable client HUD (`GLAUBHAFT`): the wire's `hands` is
/// this plus the hands we saw ourselves.
pub const GLAUBHAFT: f64 = 20.0;
/// Measured worth of the PokerIntel numbers in engine hands (`lesen/pokerintel.py`, STAND §16): the
/// hand count that gives the engine's trust `h/(h+30)` the weight the data earn against the population.
/// vpip/pfr are worth far more than the flat 20 (fitted weight 0.76–0.88, lower 95 % bound >= 0.57 →
/// 60 hands = weight 0.67), the fold-to-bet number far less (weight 0.07–0.22 → 8 hands = 0.21). The
/// other fields stay at the flat base: their intervals reach 0 and 1, the data do not carry a change.
pub const PI_HANDS_VPIP: f64 = 60.0;
pub const PI_HANDS_PFR: f64 = 60.0;
pub const PI_HANDS_FOLD: f64 = 8.0;
/// Switch `POKERINTEL=1` (read once): the HUD fields get their measured weights (`hud_profile`).
/// Off (default): the flat `GLAUBHAFT` base for every field, bit-identical to before.
pub fn pokerintel_on() -> bool {
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*ON.get_or_init(|| std::env::var("POKERINTEL").as_deref() == Ok("1"))
}
/// The sample one field rests on when the client base `GLAUBHAFT` is worth `base` hands for it: our own
/// hands on top count as they are; a thin profile (below the base, `lesen/profil.py DUENN`) is scaled.
pub fn field_hands(hands: f64, base: f64) -> f64 {
if hands.is_nan() || hands <= 0.0 {
return hands;
}
if hands >= GLAUBHAFT {
hands - GLAUBHAFT + base
} else {
hands * base / GLAUBHAFT
}
}
/// A client HUD with a hand count, as the engine believes it: `shrink` over `hands`, then the line stats
/// (foldToCbet, foldToThreeBet, checkRaise) over the fraction of hands their spot arises in, toward their
/// anchors (as the sim memory does), so 40 HUD hands are not 40 c-bets. With `POKERINTEL=1`
/// (`hud_profile_weighted`) vpip, pfr and fold-to-bet carry their measured worth instead of the flat
/// base, and the fold/range read's `confidence` is the fold-to-bet trust.
pub fn hud_profile(raw: &Profile, hands: f64) -> Profile {
hud_profile_with(raw, hands, pokerintel_on())
}
pub fn hud_profile_with(raw: &Profile, hands: f64, weighted: bool) -> Profile {
let mut p = shrink(raw, hands);
if weighted {
let w = |base: f64| trust(field_hands(hands, base));
let w_fold = w(PI_HANDS_FOLD);
p.vpip = pull(raw.vpip, PRIOR.vpip, w(PI_HANDS_VPIP));
p.pfr = pull(raw.pfr, PRIOR.pfr, w(PI_HANDS_PFR));
p.fold_to_bet = pull(raw.fold_to_bet, PRIOR.fold_to_bet, w_fold);
p.confidence = raw.confidence.or(Some(w_fold));
}
let line = |x: Option<f64>, share: f64, anchor: Option<f64>| shrink_street(x, hands * share, anchor);
let cbet_anchor = p.fold_to_bet.or(Some(crate::exploit::fold_chance::DEFAULT_FOLD_TO_BET));
Profile {
fold_to_cbet: line(p.fold_to_cbet, CBET_SPOT_SHARE, cbet_anchor),
fold_to_three_bet: line(p.fold_to_three_bet, THREE_BET_SPOT_SHARE, Some(FOLD_TO_THREE_BET_ANCHOR)),
check_raise: line(p.check_raise, CHECK_RAISE_SPOT_SHARE, Some(CHECK_RAISE_ANCHOR)),
..p
}
}
/// Anchors of the line reads that have no pooled read to shrink toward (a regular's HUD): fold to
/// 3-bet and check-raise. Shared by the sim memory and the wire.
pub const FOLD_TO_THREE_BET_ANCHOR: f64 = 0.55;
@@ -108,12 +176,12 @@ pub const CHECK_RAISE_ANCHOR: f64 = 0.08;
/// Prior strength of the check-raise read in pseudo-chances (Beta(mu*kappa, (1-mu)*kappa)).
pub const CHECK_RAISE_KAPPA: f64 = 15.0;
/// Street samples at which one street's own read and the pooled read weigh the same — the session
/// Street samples at which one street's own read and the pooled read weigh the same — the session
/// memory's `sim::memory::STREET_FOLD_PRIOR`, so a live street read earns trust as a simulated one.
pub const STREET_PRIOR: f64 = 15.0;
/// One street's read (`raw`, measured over `n` moves on that street) pulled toward the `pooled` read of
/// all streets: `(raw·n + STREET_PRIOR·pooled) / (n + STREET_PRIOR)`. A few river moves barely move
/// all streets: `(raw·n + STREET_PRIOR·pooled) / (n + STREET_PRIOR)`. A few river moves barely move
/// the river belief off the pooled one. No street sample, a broken count or no pooled read to anchor
/// on: `None`, so the engine falls back to the pooled read (never a raw 0/1 from one move).
pub fn shrink_street(raw: Option<f64>, n: f64, pooled: Option<f64>) -> Option<f64> {
@@ -124,3 +192,60 @@ pub fn shrink_street(raw: Option<f64>, n: f64, pooled: Option<f64>) -> Option<f6
}
Some((raw * n + STREET_PRIOR * pooled) / (n + STREET_PRIOR))
}
#[cfg(test)]
mod tests {
use super::*;
fn hud() -> Profile {
Profile {
vpip: Some(0.45),
pfr: Some(0.08),
fold_to_bet: Some(0.70),
aggression: Some(0.2),
fold_to_cbet: Some(0.8),
fold_to_three_bet: Some(0.3),
check_raise: Some(0.2),
..Profile::default()
}
}
/// Switch off: exactly the old wire (shrink over `hands`, line stats over their spot share).
#[test]
fn off_is_the_old_wire() {
for hands in [0.0, 5.0, 20.0, 44.0, 300.0, f64::NAN] {
let raw = hud();
let p = shrink(&raw, hands);
let anchor = p.fold_to_bet.or(Some(crate::exploit::fold_chance::DEFAULT_FOLD_TO_BET));
let old = Profile {
fold_to_cbet: shrink_street(p.fold_to_cbet, hands * CBET_SPOT_SHARE, anchor),
fold_to_three_bet: shrink_street(p.fold_to_three_bet, hands * THREE_BET_SPOT_SHARE, Some(FOLD_TO_THREE_BET_ANCHOR)),
check_raise: shrink_street(p.check_raise, hands * CHECK_RAISE_SPOT_SHARE, Some(CHECK_RAISE_ANCHOR)),
..p
};
let new = hud_profile_with(&raw, hands, false);
assert_eq!(format!("{old:?}"), format!("{new:?}"), "hands {hands}");
}
}
/// Switch on: vpip/pfr believed more, fold-to-bet less, by the measured effective samples.
#[test]
fn on_reweights_by_field() {
let raw = hud();
let (off, on) = (hud_profile_with(&raw, 24.0, false), hud_profile_with(&raw, 24.0, true));
let d = |x: Option<f64>, p: f64| (x.unwrap() - p).abs();
assert!(d(on.vpip, 0.28) > d(off.vpip, 0.28));
assert!(d(on.pfr, 0.18) > d(off.pfr, 0.18));
assert!(d(on.fold_to_bet, 0.45) < d(off.fold_to_bet, 0.45));
assert!(on.confidence.unwrap() < off.confidence.unwrap());
assert_eq!(on.aggression, off.aggression);
}
#[test]
fn field_hands_maps_the_default_and_counts_own_hands_fully() {
assert_eq!(field_hands(GLAUBHAFT, 60.0), 60.0);
assert_eq!(field_hands(GLAUBHAFT + 10.0, 8.0), 18.0);
assert_eq!(field_hands(10.0, 60.0), 30.0);
assert_eq!(field_hands(0.0, 60.0), 0.0);
}
}
+109
View File
@@ -0,0 +1,109 @@
//! The client HUD a live seat carries (PokerIntel), for the `ReadMode::Hud` ladder rows.
//!
//! Live, 95 % of seats arrive with PokerIntel numbers whose effective sample is far below the hands
//! they claim (`lesen/pokerintel.py`, STAND §16: vpip ~12 chances, fold ~4). The sim reproduces that:
//! a pre-session on its own seed measures the opponent's true rates (`SessionMemory::raw_profile`),
//! then each field is drawn from Beta(m·θ, m·(1−θ)) with the measured m. The engine then reads that
//! HUD exactly like the live wire (`SessionMemory::hud_read` → `sample::hud_profile`).
use super::memory::SessionMemory;
use super::population::normal;
use crate::exploit::profile::Profile;
use crate::rng::Rng;
/// Deals of the truth pre-session.
pub const HUD_VOR: u32 = 800;
/// Effective chances per field (`messung_gedaechtnis/pokerintel.json`, fit with fixed mean).
pub const M_VPIP: f64 = 12.1;
pub const M_PFR: f64 = 10.0;
pub const M_FOLD: f64 = 4.0;
pub const M_FOLD_TO_CBET: f64 = 3.1;
pub const M_FOLD_TO_THREE_BET: f64 = 30.0;
pub const M_CHECK_RAISE: f64 = 12.5;
/// Gamma(shape, 1) by Marsaglia–Tsang (shape < 1 via the boost u^(1/shape)).
fn gamma(shape: f64, rng: Rng) -> (f64, Rng) {
if shape < 1.0 {
let (g, rng) = gamma(shape + 1.0, rng);
let (u, rng) = rng.unit();
return (g * u.max(1e-300).powf(1.0 / shape), rng);
}
let d = shape - 1.0 / 3.0;
let c = 1.0 / (9.0 * d).sqrt();
let mut rng = rng;
loop {
let (z, r) = normal(rng);
let (u, r) = r.unit();
rng = r;
let v = (1.0 + c * z).powi(3);
if v > 0.0 && u.max(1e-300).ln() < 0.5 * z * z + d - d * v + d * v.ln() {
return (d * v, rng);
}
}
}
/// One draw of a rate measured over `m` chances whose truth is `theta`.
pub fn noisy(theta: f64, m: f64, rng: Rng) -> (f64, Rng) {
let t = theta.clamp(0.005, 0.995);
let (a, rng) = gamma(m * t, rng);
let (b, rng) = gamma(m * (1.0 - t), rng);
(a / (a + b), rng)
}
/// The HUD a seat shows: every known truth field drawn noisily, unknown fields stay `None`.
pub fn draw(truth: &Profile, rng: Rng) -> Profile {
let mut rng = rng;
let mut f = |x: Option<f64>, m: f64| {
x.map(|t| {
let (v, r) = noisy(t, m, rng);
rng = r;
v
})
};
Profile {
vpip: f(truth.vpip, M_VPIP),
pfr: f(truth.pfr, M_PFR),
fold_to_bet: f(truth.fold_to_bet, M_FOLD),
fold_to_cbet: f(truth.fold_to_cbet, M_FOLD_TO_CBET),
fold_to_three_bet: f(truth.fold_to_three_bet, M_FOLD_TO_THREE_BET),
check_raise: f(truth.check_raise, M_CHECK_RAISE),
..Profile::default()
}
}
/// The truth of a pre-session memory, as the HUD source.
pub fn truth(memory: &SessionMemory) -> Profile {
memory.raw_profile()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn noisy_has_the_right_mean_and_spread() {
let (n, theta, m) = (20000, 0.3, 10.0);
let mut rng = Rng::seeded(7);
let mut xs = Vec::with_capacity(n);
for _ in 0..n {
let (x, r) = noisy(theta, m, rng);
rng = r;
xs.push(x);
}
let mean = xs.iter().sum::<f64>() / n as f64;
let var = xs.iter().map(|x| (x - mean).powi(2)).sum::<f64>() / n as f64;
assert!((mean - theta).abs() < 0.01, "mean {mean}");
let want = theta * (1.0 - theta) / (m + 1.0);
assert!((var / want - 1.0).abs() < 0.08, "var {var} want {want}");
}
#[test]
fn small_shapes_stay_in_range() {
let mut rng = Rng::seeded(3);
for _ in 0..2000 {
let (x, r) = noisy(0.02, 3.0, rng);
rng = r;
assert!((0.0..=1.0).contains(&x));
}
}
}
+581 -529
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -8,6 +8,7 @@ pub mod benchmark;
pub mod exploit_pop;
pub mod exploit_river;
pub mod gto;
pub mod hud;
pub mod league;
pub mod luck;
pub mod memory;
+1 -1
View File
@@ -356,7 +356,7 @@ pub fn play_block(setup: &Setup6, b: u32) -> Vec<Row> {
reads[s] = match setup.read {
ReadMode::Oracle => opponent_profile(*o),
ReadMode::Blind => None,
ReadMode::Memory => memory[m].read(),
ReadMode::Memory | ReadMode::Hud => memory[m].read(),
};
}
let hand = HandSetup {
+11 -1
View File
@@ -17,6 +17,9 @@ pub enum ReadMode {
/// Build the read from the opponent's observed actions over the session (`sim::memory`): starts
/// blind, converges toward the oracle. Lands between `Blind` and `Oracle` on the ladder.
Memory,
/// Live-like: the seat carries a noisy client HUD (`sim::hud`, PokerIntel's measured effective
/// sample) and the memory counts on top of it, read like the live wire (`SessionMemory::hud_read`).
Hud,
}
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -144,6 +147,12 @@ fn deal_samples_at(setup: &Setup, cost: TableCost) -> (Vec<f64>, Vec<f64>, Measu
let mut rake = 0.0;
// The memory accumulates across every hand of the session, in order; unused in the other modes.
let mut memory = SessionMemory::new();
// Hud: the truth from a pre-session on its own seed, then one noisy HUD for the whole session.
let hud = (setup.read == ReadMode::Hud).then(|| {
let pre = Setup { read: ReadMode::Memory, deals: super::hud::HUD_VOR, seed: setup.seed ^ 0x4855_4400_0000_0001, ..*setup };
let (_, _, _, seen) = deal_samples_at(&pre, cost);
super::hud::draw(&super::hud::truth(&seen), Rng::seeded(mix(setup.seed, 0x4855_4402)))
});
for d in 0..setup.deals {
let (cards, _) = deal(players as usize, Rng::seeded(mix(setup.seed, d as u64)));
let (mut sum, mut raw) = (0.0, 0.0);
@@ -153,6 +162,7 @@ fn deal_samples_at(setup: &Setup, cost: TableCost) -> (Vec<f64>, Vec<f64>, Measu
ReadMode::Oracle => HandRead::Oracle,
ReadMode::Blind => HandRead::Given(None),
ReadMode::Memory => HandRead::Given(memory.read()),
ReadMode::Hud => HandRead::Given(memory.hud_read(hud.as_ref().expect("hud"))),
};
let hand = HandSetup {
deal: &cards,
@@ -163,7 +173,7 @@ fn deal_samples_at(setup: &Setup, cost: TableCost) -> (Vec<f64>, Vec<f64>, Measu
read,
};
// Only the memory mode feeds the hand back into the accumulator afterwards.
let track = (setup.read == ReadMode::Memory).then_some(&mut memory);
let track = matches!(setup.read, ReadMode::Memory | ReadMode::Hud).then_some(&mut memory);
let r = play_hand_tracked(&hand, cost, track);
rake += r.rake;
sum += r.hero_net - r.luck;
+4 -25
View File
@@ -1,6 +1,6 @@
use crate::exploit::mark::with_mark;
use crate::exploit::profile::Profile;
use crate::exploit::sample::{shrink, shrink_aggression, shrink_street, CHECK_RAISE_ANCHOR, FOLD_TO_THREE_BET_ANCHOR};
use crate::exploit::sample::{hud_profile, shrink_aggression, shrink_street};
use crate::fault::Fault;
use crate::game::Villain;
use crate::json::field::{at, join, optional, text};
@@ -37,9 +37,10 @@ fn profile(villain: &Value, path: &str) -> Result<Option<Profile>, Fault> {
river_bluff_share: None,
river_bluff_shown: None,
};
// `hands` (extension, exploit::sample): with it, few hands count little
// `hands` (extension, exploit::sample): with it, few hands count little; the line stats rest on
// the fraction of hands their spot arises in (`hud_profile`, shared with the sim's HUD mode).
let shrunk = match opt_number_member(object, &at_profile, "hands")? {
Some(hands) => shrink(&raw, hands),
Some(hands) => hud_profile(&raw, hands),
None => raw,
};
// `aggressionActions` (extension, lesen/profil.py): the postflop moves the aggression was measured
@@ -51,12 +52,6 @@ fn profile(villain: &Value, path: &str) -> Result<Option<Profile>, Fault> {
streets(object, &at_profile, pooled).map(Some)
}
/// Share of a HUD's hands in which the player faces a c-bet / a 3-bet after opening / a bet after
/// checking (rough 6-max frequencies): the effective sample of each line stat.
const CBET_SPOT_SHARE: f64 = 0.15;
const THREE_BET_SPOT_SHARE: f64 = 0.04;
const CHECK_RAISE_SPOT_SHARE: f64 = 0.10;
/// Per-street reads (extension, lesen/profil.py `strassen`): the rate seen on one street and the moves
/// it rests on, each pulled toward the pooled (already shrunk) read by `shrink_street`. The engine
/// already plays them (turn/river subgame, fold_chance); the session memory fills them in the sim.
@@ -67,19 +62,6 @@ fn streets(object: &Value, path: &str, pooled: Profile) -> Result<Profile, Fault
None => None,
})
};
// The HUD's line stats (foldToCbet, foldToThreeBet, checkRaise) come with the hand count only. Each
// rests on a fraction of those hands (the spot must arise): shrink them over that effective sample
// toward their anchor, as the sim memory does (`sim::memory`), so 40 HUD hands are not 40 c-bets.
let hands = opt_number_member(object, path, "hands")?;
// Without a hand count the profile is used as given (as `shrink` does).
let line = |x: Option<f64>, share: f64, anchor: Option<f64>| match hands {
Some(h) => shrink_street(x, h * share, anchor),
None => x,
};
let cbet_anchor = pooled.fold_to_bet.or(Some(crate::exploit::fold_chance::DEFAULT_FOLD_TO_BET));
let fold_to_cbet = line(pooled.fold_to_cbet, CBET_SPOT_SHARE, cbet_anchor);
let fold_to_three_bet = line(pooled.fold_to_three_bet, THREE_BET_SPOT_SHARE, Some(FOLD_TO_THREE_BET_ANCHOR));
let check_raise = line(pooled.check_raise, CHECK_RAISE_SPOT_SHARE, Some(CHECK_RAISE_ANCHOR));
let turn_aggression = read("turnAggression", "turnAggressionActions", pooled.aggression)?;
let river_aggression = read("riverAggression", "riverAggressionActions", pooled.aggression)?;
let street_fold_to_bet = [
@@ -88,9 +70,6 @@ fn streets(object: &Value, path: &str, pooled: Profile) -> Result<Profile, Fault
read("riverFoldToBet", "riverFacingBet", pooled.fold_to_bet)?,
];
Ok(Profile {
fold_to_cbet,
fold_to_three_bet,
check_raise,
turn_aggression: turn_aggression.or(pooled.turn_aggression),
river_aggression: river_aggression.or(pooled.river_aggression),
street_fold_to_bet,