Files
pokerfreak/src/engine/bluff.rs
T
mmintel 04c8e6d3e0 Tournaments: tables left alone by cash rules, break modelled; thin value on turn and river
- A tournament table (tournament type or tournament lobby) is never sat out, left or closed by
  the cash runner: session end, schedule pause, empty table, no channel, over the table count
  (tests/turniertisch_spec.py).
- Clone tournament gets a break (isTourneyOnBreak, no hands, level clock stops); the runner sits
  through it and plays on (tests/turnier_kette_spec.py).
- Medium hands may bet thin on the turn and the river when checked to and the favourite at the
  table; EV decides, held back inside the EV error, small sizes (tests/engine_thin_value.rs).
- archiv/mitschrieb/TURNIERE.md: what works in the clone, what is missing at the real client.
2026-11-05 17:11:50 +01:00

92 lines
3.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::range_spec::Continuation;
use crate::exploit::street_continuation::continuations;
use crate::game::{Spot, Villain};
use crate::odds::ev::final_pot;
use crate::read::hand_read::HandRead;
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;
/// 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 }
}
/// 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.
pub fn bluff_catch_blocked(spot: &Spot, read: &HandRead) -> bool {
spot.to_call > 0.0
&& !has_real_draw(read, spot.street)
&& bettor(spot).is_some_and(|(_, c)| read.made < c.min_made && c.bluff_share < MIN_BLUFF_SHARE)
}