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
+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);
}
}