Files
pokerfreak/src/exploit/bluff_share.rs
T
mmintelandClaude Opus 5.5 fe244c9868 Information schadet nie: STEAL_BREITE=wert, INFO_KONSISTENT=paar|bluff|1
- STEAL_BREITE=wert: ein niedriger foldToBet macht die Oeffnungsbreite nie enger als blind
  (gegen Caller zaehlt der Wert, nicht der Steal). Leiter gg. Live +2,80 +-0,43, station +24,
  micro-passiv +0,58, kein Verlierer.
- INFO_KONSISTENT: Aggressions-Schwellen lesen den Read als Posterior. Der Read schrumpft auf
  den Prior 0,35, die Schwellen (0,45) sind in Orakel-Einheiten geeicht; ein Read ohne
  Stichprobe war so "passiver als blind". Mit Schalter steht der Prior-Teil auf dem neutralen
  Wert der Schwelle (sample::aggression_at), ein voller Read bleibt gleich.
  =paar: PAAR_RAISE-Riegel (maniac +5,9 offen, sonst 0 Deals). =bluff: Bluff-Anteil,
  Verlierer (fish -8,2, micro-passiv -8,7), nicht live.
- gedaechtnis_station: DIAG_A=blind|orakel, DIAG_B=orakel|hud|gezaehlt, maniac/nem2, DIAG_SPEC.

Alles aus = bitgleich, Lib-Specs gruen.

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

104 lines
4.8 KiB
Rust

//! What part of an opponent's betting range is a bluff.
//!
//! | step | rule |
//! |---|---|
//! | base | `s / (1 + 2s)` for a bet of `s` pots: the river share at which a caller is indifferent (Chen/Ankenman, "The Mathematics of Poker"); unknown or broken size counts as 0.66 |
//! | street | river 1.0, turn 0.6, flop 0.5 (earlier, draws do the bluffing and already stay in the range), preflop 0 |
//! | style | nit 0.4, calling station 0.5 (passive players bet for value), loose-aggressive 1.5, otherwise 1.0 |
//! | aggression | when the profile gives it, `aggression / 0.45` (0.45 = an average aggression frequency) replaces the style factor, clamped to [0, 2] |
//! | cap | at most 0.6 |
use super::profile::Profile;
use super::style::{classify, Style};
use crate::game::Street;
pub const NEUTRAL_RATIO: f64 = 0.66;
pub const MAX_BLUFF_SHARE: f64 = 0.6;
const AVERAGE_AGGRESSION: f64 = 0.45;
const MAX_FACTOR: f64 = 2.0;
/// Populations-Ueber-Bluff-Prior gegen einen UNGELESENEN Gegner: der Micro-Pool c-bettet/barrelt
/// weit ueber GTO-Balance, also bekommt eine unbekannte (auch auf blind gegatete) Range auf
/// Flop/Turn mindestens diesen Bluff-Anteil. River bleibt dem MDF-Boden ueberlassen.
/// Micro-Prior; spaeter stake-skaliert.
const POP_BLUFF_PRIOR: [f64; 4] = [0.0, 0.40, 0.35, 0.0]; // preflop, flop, turn, river
fn street_factor(street: Street) -> f64 {
match street {
Street::Preflop => 0.0,
Street::Flop => 0.5,
Street::Turn => 0.6,
Street::River => 1.0,
}
}
pub use super::sample::{aggression_at, info_konsistent};
fn style_factor(profile: Option<&Profile>) -> f64 {
let Some(p) = profile else { return 1.0 };
if info_konsistent() {
if let Some(a) = aggression_at(p, AVERAGE_AGGRESSION) {
return (a / AVERAGE_AGGRESSION).clamp(0.0, MAX_FACTOR);
}
}
match p.aggression.filter(|a| !a.is_nan()) {
Some(a) => (a.clamp(0.0, 1.0) / AVERAGE_AGGRESSION).clamp(0.0, MAX_FACTOR),
None => match classify(p) {
Style::Nit => 0.4,
Style::CallingStation => 0.5,
Style::LooseAggressive => 1.5,
Style::Regular | Style::Unknown => 1.0,
},
}
}
/// Bluff share of the range that bet `ratio` pots on `street`. Always in `[0, MAX_BLUFF_SHARE]`.
pub fn bluff_share(profile: Option<&Profile>, ratio: Option<f64>, street: Street) -> f64 {
let s = ratio.filter(|r| r.is_finite() && *r > 0.0).unwrap_or(NEUTRAL_RATIO);
let balanced = s / (1.0 + 2.0 * s);
(balanced * street_factor(street) * style_factor(profile)).clamp(0.0, MAX_BLUFF_SHARE)
}
/// Lift the population over-bluff prior onto a base bluff share. It applies ONLY to an UNREAD
/// villain (`profile` None - including a read gated to blind) on a FIRST barrel: a sustained
/// multi-street line (`sustained`, the villain already bet/raised an earlier street) is
/// value-weighted even in the micro pool, so it gets no bump. River and preflop carry no prior
/// (the river is the MDF floor's job). Never exceeds `MAX_BLUFF_SHARE`.
pub fn with_pop_prior(profile: Option<&Profile>, street: Street, sustained: bool, base: f64) -> f64 {
with_pop_prior_on(profile, street, sustained, false, base)
}
/// Messschalter (einmal gelesen): `RAISE_PRIOR=0` gibt einer ERHOEHUNG (Raise/All-in gegen einen
/// Einsatz) keinen Populations-Bluff-Prior mehr - nur der erste Einsatz behaelt ihn.
/// Live 14.11. (996 Haende 0.01/0.02): Hero setzt, ein ungelesener Gegner erhoeht, Hero spielt
/// weiter - 12 von 13 Mal, -391 BB; die Equity fiel nach der Erhoehung im Mittel nur 0.64 -> 0.52,
/// weil die Erhoehung mit 40 % (Flop) / 35 % (Turn) Bluffs gerechnet wurde. Vorgabe: an (alt).
pub fn raise_prior_enabled() -> bool {
use std::sync::OnceLock;
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| std::env::var("RAISE_PRIOR").as_deref() != Ok("0"))
}
/// Wie `with_pop_prior`, aber weiss, ob die Aggression eine Erhoehung war (`raised`).
pub fn with_pop_prior_on(
profile: Option<&Profile>,
street: Street,
sustained: bool,
raised: bool,
base: f64,
) -> f64 {
// A pool baseline (`POOL_PRIOR`) counts as unread; its raises carry the pool's value share.
let pool_value = profile.is_some_and(|p| p.pool_baseline && p.pool_raise_value);
let prior_allowed = !raised || (raise_prior_enabled() && !pool_value);
let unread = profile.is_none_or(|p| p.pool_baseline);
let prior = if unread && !sustained && prior_allowed {
POP_BLUFF_PRIOR[street as usize]
} else if info_konsistent() && !sustained && prior_allowed {
// Gelesen: der Teil ohne Aggressions-Stichprobe glaubt, was blind glaubt (Populations-Prior).
profile.and_then(super::sample::aggression_weight).map_or(0.0, |w| (1.0 - w) * POP_BLUFF_PRIOR[street as usize])
} else {
0.0
};
base.max(prior).min(MAX_BLUFF_SHARE)
}