Data-Biased Robust Counter-Strategy (cfr::dbr) als Heads-up-River-Spieler mit Read-Konfidenz je Knoten. Leiter gegen zaehl: -32.74 +-2.91 bb/100, alle gemessenen Profile verlieren, auch balancierte. Arm RIVER_DBR aus, aus = bit-identisch. Dazu: Zaehlungen je Read (COUNTS=1, eich_sim.py), Session-Memory-API, geparktes Check-Raise-Modell (RAISE_MODEL, aus). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
127 lines
5.7 KiB
Rust
127 lines
5.7 KiB
Rust
//! 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.
|
|
//!
|
|
//! | step | rule |
|
|
//! |---|---|
|
|
//! | trust | `w = hands / (hands + PRIOR_HANDS)`; no, negative or broken count: 0 |
|
|
//! | shrink | each known frequency `x` becomes `p + w * (x - p)` with the population `p` in `PRIOR` |
|
|
//! | absent | a missing frequency stays missing; a profile without `hands` is used as given |
|
|
|
|
use crate::exploit::profile::Profile;
|
|
|
|
/// Hands at which the sample and the population weigh the same (`trust` 0.5).
|
|
pub const PRIOR_HANDS: f64 = 30.0;
|
|
|
|
/// The population an unknown opponent is assumed to be: a regular of the stock. The HUD extras have
|
|
/// no population prior yet: a missing one leaves `shrink` to pass the measured value through, so a
|
|
/// field without a prior is never pulled off the client's number.
|
|
pub const PRIOR: Profile = Profile {
|
|
vpip: Some(0.28),
|
|
pfr: Some(0.18),
|
|
fold_to_bet: Some(0.45),
|
|
aggression: Some(0.35),
|
|
// No population prior for per-street aggression: a missing one lets `shrink` pass the measured
|
|
// value through unshrunk.
|
|
turn_aggression: None,
|
|
river_aggression: None,
|
|
street_fold_to_bet: [None; 3],
|
|
cbet: None,
|
|
fold_to_cbet: None,
|
|
three_bet: None,
|
|
fold_to_three_bet: None,
|
|
steal: None,
|
|
check_raise: None,
|
|
wtsd: None,
|
|
wsd: None,
|
|
confidence: None,
|
|
aggression_confidence: None,
|
|
river_bluff_share: None,
|
|
river_bluff_shown: None,
|
|
};
|
|
|
|
/// 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;
|
|
|
|
/// Weight of the sample in `[0, 1)`.
|
|
pub fn trust(hands: f64) -> f64 {
|
|
if hands.is_nan() || hands <= 0.0 {
|
|
return 0.0;
|
|
}
|
|
hands / (hands + PRIOR_HANDS)
|
|
}
|
|
|
|
fn pull(x: Option<f64>, p: Option<f64>, w: f64) -> Option<f64> {
|
|
match (x.filter(|v| !v.is_nan()), p) {
|
|
(Some(x), Some(p)) => Some(p + w * (x - p)),
|
|
(x, _) => x,
|
|
}
|
|
}
|
|
|
|
/// The profile as the engine should believe it after `hands` hands.
|
|
pub fn shrink(profile: &Profile, hands: f64) -> Profile {
|
|
let w = trust(hands);
|
|
Profile {
|
|
vpip: pull(profile.vpip, PRIOR.vpip, w),
|
|
pfr: pull(profile.pfr, PRIOR.pfr, w),
|
|
fold_to_bet: pull(profile.fold_to_bet, PRIOR.fold_to_bet, w),
|
|
aggression: pull(profile.aggression, PRIOR.aggression, w),
|
|
turn_aggression: pull(profile.turn_aggression, PRIOR.turn_aggression, w),
|
|
river_aggression: pull(profile.river_aggression, PRIOR.river_aggression, w),
|
|
street_fold_to_bet: profile.street_fold_to_bet,
|
|
cbet: pull(profile.cbet, PRIOR.cbet, w),
|
|
fold_to_cbet: pull(profile.fold_to_cbet, PRIOR.fold_to_cbet, w),
|
|
three_bet: pull(profile.three_bet, PRIOR.three_bet, w),
|
|
fold_to_three_bet: pull(profile.fold_to_three_bet, PRIOR.fold_to_three_bet, w),
|
|
steal: pull(profile.steal, PRIOR.steal, w),
|
|
check_raise: pull(profile.check_raise, PRIOR.check_raise, w),
|
|
wtsd: pull(profile.wtsd, PRIOR.wtsd, w),
|
|
wsd: pull(profile.wsd, PRIOR.wsd, w),
|
|
// The sample weight IS the read confidence (same half-life): a client profile with a hand
|
|
// count earns the gearbox's trust exactly as a session-memory read does. Keep an explicit
|
|
// confidence if one was already set.
|
|
confidence: profile.confidence.or(Some(w)),
|
|
aggression_confidence: profile.aggression_confidence,
|
|
river_bluff_share: profile.river_bluff_share,
|
|
river_bluff_shown: profile.river_bluff_shown,
|
|
}
|
|
}
|
|
|
|
/// The aggression read on its OWN sample: `raw` was measured over `actions` postflop moves (not over
|
|
/// the HUD's hands), so it is shrunk toward the population with that weight and carries it as
|
|
/// `aggression_confidence`. No usable count: the profile is returned unchanged.
|
|
pub fn shrink_aggression(profile: Profile, raw: Option<f64>, actions: f64) -> Profile {
|
|
if actions.is_nan() || actions < 0.0 {
|
|
return profile;
|
|
}
|
|
let w = actions / (actions + AGGRESSION_HALF);
|
|
Profile { aggression: pull(raw, PRIOR.aggression, w), aggression_confidence: Some(w), ..profile }
|
|
}
|
|
|
|
/// 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;
|
|
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
|
|
/// 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
|
|
/// 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> {
|
|
let raw = raw.filter(|x| !x.is_nan())?;
|
|
let pooled = pooled.filter(|x| !x.is_nan())?;
|
|
if n.is_nan() || n <= 0.0 {
|
|
return None;
|
|
}
|
|
Some((raw * n + STREET_PRIOR * pooled) / (n + STREET_PRIOR))
|
|
}
|