Files
pokerfreak/src/engine/bluff.rs
T
mmintelandClaude Opus 5.5 ff418fe005 River-DBR (Roadmap #1) gemessen: Verlierer, Arm bleibt aus
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>
2026-11-13 22:45:51 +01:00

176 lines
7.9 KiB
Rust

//! Bluffing and bluff catching: when a raise without a value hand pays, and when a call
//! with a hand that only beats bluffs is allowed.
//!
//! | rule | value |
//! |---|---|
//! | two branches | `EV = P(fold) * pot + (1 - P(fold)) * (called share * final pot - added)` |
//! | semibluff | real draw (`semibluff::has_real_draw`), at most two villains, fold branch > 0, EV > 0 and above the best passive line |
//! | pure bluff | weak hand without a real draw, heads-up, P(fold) >= 0.35, EV > 0 and at least 0.03 pot above the best passive line |
//! | never bluff | no semibluff or bluff when any villain's foldToBet is at most 0.12 |
//! | never bluff-catch | facing a bet without a real draw, a hand below the bettor's value floor may not call when their bluff share is under 0.05 |
use super::semibluff::has_real_draw;
use crate::exploit::bluff_share::bluff_share;
use crate::exploit::profile::Profile;
use crate::exploit::range_spec::Continuation;
use crate::exploit::sample::CHECK_RAISE_ANCHOR;
use crate::exploit::street_continuation::continuations;
use crate::game::{line, Spot, Villain};
use crate::odds::break_even::break_even;
use crate::odds::ev::final_pot;
use crate::read::hand_read::HandRead;
use crate::read::made::Made;
use crate::read::tier::{tier, Tier};
/// A villain with foldToBet at or below this never folds: no bluffs against them.
pub const NEVER_FOLDS: f64 = 0.12;
/// A pure bluff needs at least this chance that everyone folds.
pub const PURE_BLUFF_MIN_FOLD: f64 = 0.45;
/// A pure bluff must beat the passive line by this share of the pot.
pub const PURE_BLUFF_EDGE: f64 = 0.03;
/// Below this bluff share a betting range counts as pure value.
pub const MIN_BLUFF_SHARE: f64 = 0.05;
/// A made pair below the bettor's value floor still beats a value range at least this often
/// (outs to two pair or trips, the odd thin value it already has beaten). When the price asks
/// for less equity than this, the pot odds make the call correct no matter how rarely the
/// bettor bluffs - only a cheap bet qualifies. Without this the no-bluff read folded a priced-in
/// call (live 8.11.: bottom/middle pair into a tiny bet at 17:1, "EV call +807" -> FOLD).
pub const BLUFF_CATCH_PRICED_IN: f64 = 0.20;
/// Why a raise is made.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RaiseKind {
Value,
/// A medium hand betting thin on the turn or the river (`thin_value`).
ThinValue,
Semibluff,
Bluff,
}
/// The two branches of a raise to `to` and their sum, in chips relative to folding now.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Branches {
/// `P(fold) * pot`: everyone folds, hero takes the pot.
pub fold: f64,
/// `(1 - P(fold)) * (called share * final pot - added)`: hero is called.
pub called: f64,
pub total: f64,
}
/// `fold` = P(every villain folds), `called_share` = hero's (realised) share against the
/// calling range. Hero adds `to` (nothing committed on this street, see `odds::ev`).
pub fn branches(spot: &Spot, to: f64, fold: f64, called_share: f64) -> Branches {
let fold_branch = fold * spot.pot;
let called = (1.0 - fold) * (called_share * final_pot(spot.pot, spot.to_call, to) - to);
Branches { fold: fold_branch, called, total: fold_branch + called }
}
/// Villain's check-raise as a multiple of hero's bet (model assumption: the standard 3x raise).
pub const CHECK_RAISE_MULTIPLE: f64 = 3.0;
static RAISE_MODEL: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
/// Switch the check-raise response model on or off (ladder arm until proven). Default off.
pub fn set_raise_model(on: bool) {
RAISE_MODEL.store(on, std::sync::atomic::Ordering::Relaxed);
}
fn raise_model_on() -> bool {
RAISE_MODEL.load(std::sync::atomic::Ordering::Relaxed)
}
/// Heads-up, betting into a villain who checked this street: its check-raise rate (the read, else
/// the population's `CHECK_RAISE_ANCHOR`) and its profile. `None` elsewhere or with the model off.
pub fn check_raise_rate(spot: &Spot) -> Option<(f64, Option<Profile>)> {
if !raise_model_on() {
return None;
}
let mut live = spot.live_villains();
let (Some(v), None) = (live.next(), live.next()) else { return None };
if !line::checked_to(&spot.history, v.seat, spot.street) {
return None;
}
let rho = v.profile.and_then(|p| p.check_raise).filter(|x| !x.is_nan()).unwrap_or(CHECK_RAISE_ANCHOR);
Some((rho.clamp(0.0, 1.0), v.profile))
}
/// A bet of `to` into a check, with the check-raise in the tree. The fold read counts folds over
/// folds and calls (raises are not in it, `sim::memory`, `lesen/zaehler.py`), so with a raise rate
/// `rho` the villain folds `(1 - rho) * fold`, calls `(1 - rho) * (1 - fold)` and raises `rho`;
/// against the raise hero plays its best response (`raise_response`). Ignoring the raise - as
/// `branches` does - overstates the fold branch by `1 / (1 - rho)` and drops the raise branch.
pub fn branches_vs_raise(
spot: &Spot,
to: f64,
fold: f64,
called_share: f64,
kind: RaiseKind,
rho: f64,
profile: Option<&Profile>,
) -> Branches {
let keep = 1.0 - rho;
let fold_branch = keep * fold * spot.pot;
let called = keep * (1.0 - fold) * (called_share * final_pot(spot.pot, spot.to_call, to) - to)
+ rho * raise_response(spot, to, kind, profile);
Branches { fold: fold_branch, called, total: fold_branch + called }
}
/// Hero's best response to a check-raise to `CHECK_RAISE_MULTIPLE * to`, in chips relative to
/// folding now: fold loses the bet; thin value beats the raise's bluffs (share `bluff_share` of the
/// raising range at that size) and calls when that pays. Bluffs and semibluffs fold (a draw's
/// equity against a value raise is not priced here - conservative).
pub fn raise_response(spot: &Spot, to: f64, kind: RaiseKind, profile: Option<&Profile>) -> f64 {
let fold = -to;
match kind {
RaiseKind::ThinValue => {
let raise_to = CHECK_RAISE_MULTIPLE * to;
let ratio = (raise_to - to) / (spot.pot + 2.0 * to);
let beats = bluff_share(profile, Some(ratio), spot.street);
let call = beats * (spot.pot + 2.0 * raise_to) - raise_to;
call.max(fold)
}
_ => fold,
}
}
/// Some villain never folds (foldToBet at or below `NEVER_FOLDS`).
pub fn never_folds(spot: &Spot) -> bool {
spot.live_villains()
.any(|v| v.profile.and_then(|p| p.fold_to_bet).is_some_and(|f| f <= NEVER_FOLDS))
}
/// A hand to bluff with: weak and without a real draw.
pub fn is_bluff_hand(read: &HandRead, spot: &Spot) -> bool {
tier(read.made) == Tier::Weak && !has_real_draw(read, spot.street)
}
/// The villain who made the last bet or raise on this street, with their
/// continuation there.
fn bettor(spot: &Spot) -> Option<(&Villain, Continuation)> {
let seat = spot
.history
.iter()
.rev()
.find(|r| r.street == spot.street && r.action.is_aggressive())
.map(|r| r.seat)?;
let villain = spot.live_villains().find(|v| v.seat == seat)?;
let here = continuations(spot, villain)
.into_iter()
.find(|c| c.board_len == spot.street.board_len())?;
Some((villain, here))
}
/// Calling would be a bluff catch against a range without bluffs: hero faces a bet,
/// holds no real draw, sits below the bettor's value floor, and the bettor's bluff share
/// is under `MIN_BLUFF_SHARE`. Unknown bettor (no history): never blocked. A made pair
/// getting a price under `BLUFF_CATCH_PRICED_IN` is never blocked either - the pot odds call
/// it regardless of the bettor's bluffs (the no-bluff read must not fold a priced-in call).
pub fn bluff_catch_blocked(spot: &Spot, read: &HandRead) -> bool {
let priced_in = read.made >= Made::Underpair
&& break_even(spot.pot, spot.to_call) < BLUFF_CATCH_PRICED_IN;
spot.to_call > 0.0
&& !priced_in
&& !has_real_draw(read, spot.street)
&& bettor(spot).is_some_and(|(_, c)| read.made < c.min_made && c.bluff_share < MIN_BLUFF_SHARE)
}