FORTSETZUNG: Mehrstrassen-Kosten im Called-Zweig vor dem River (Bluff, Semibluff, Thin Value); aus bitgleich. LESE_VERTRAUEN=nit,reg,lag Messschalter fuer read_gate
Der Called-Zweig einer Bet vor dem River zaehlte nur eine Strasse. Jetzt verliert der realisierte Anteil je Folgestrasse p_bet * min(1, 0.66 (1-2e)/e), p_bet = Folge-Aggression + (1-a) * P(fold) * 0.5. Ausgenommen: Value, River, All-in, nicht foldende Stationen (foldToBet <= 0.30). Pilot (300/4000 Deals): nemesis-1 +36.5, nemesis-2 +28.2, maniac +20.2, reg +8.6, station +0.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
//! Continuation cost of a called bet before the river (`FORTSETZUNG`, off by default).
|
||||
//!
|
||||
//! `bluff::branches` values the called branch of a bet as if the hand ended at showdown after this
|
||||
//! street: `called share * final pot - added`. Before the river it does not. The villains who call
|
||||
//! are the top `1 - P(fold)` of their range, and on each later street they bet often. A hand that is
|
||||
//! behind them then either folds (giving up its equity share) or calls and pays a bet it is behind
|
||||
//! for. Counting only one street overstates the called branch of bluffs, semibluffs and thin value.
|
||||
//! That is the shared root of over-barrelling, raise wars and the nit-read loss.
|
||||
//!
|
||||
//! The model per later street: the continuing range bets with probability `p_bet`, a bet of
|
||||
//! `BET_SHARE` pot. Hero with share `e` against that range picks the cheaper response. Folding loses
|
||||
//! `e * pot`; calling loses `bet * (1 - 2e)` (nothing when `e >= 0.5`). So the realised share drops by
|
||||
//! the factor `1 - p_bet * min(1, BET_SHARE * (1 - 2e)+ / e)` per street left, compounded.
|
||||
//!
|
||||
//! `p_bet` is the villain's aggression on the next street (its read, else `AGGRESSION_ANCHOR`), raised
|
||||
//! by the narrowness of the continuing range: `a + (1 - a) * P(fold) * NARROW`. Value raises, the
|
||||
//! river, all-ins and tables of over-callers only (`Style::CallingStation`) are untouched.
|
||||
|
||||
use super::bluff::RaiseKind;
|
||||
use crate::game::{Spot, Street};
|
||||
use std::cell::Cell;
|
||||
|
||||
/// Size of a later-street bet as a share of the pot (the common two-thirds bet).
|
||||
pub const BET_SHARE: f64 = 0.66;
|
||||
/// Next-street aggression of a villain without a read.
|
||||
pub const AGGRESSION_ANCHOR: f64 = 0.35;
|
||||
/// Default weight of the continuing range's narrowness in its betting rate (`FORTSETZUNG=1`).
|
||||
pub const NARROW_DEFAULT: f64 = 0.5;
|
||||
|
||||
/// The switch when on: the narrowness weight and whether thin value is discounted too.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Mode {
|
||||
pub narrow: f64,
|
||||
pub thin_value: bool,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static OVERRIDE: Cell<Option<Option<Mode>>> = const { Cell::new(None) };
|
||||
}
|
||||
|
||||
/// The switch, `None` when off. `FORTSETZUNG=1`: bluffs, semibluffs and thin value with
|
||||
/// `NARROW_DEFAULT`; `FORTSETZUNG=bluff`: bluffs and semibluffs only; `eng:<x>` / `bluff:<x>` the
|
||||
/// same with weight `x`. Anything else is off.
|
||||
pub fn mode() -> Option<Mode> {
|
||||
use std::sync::OnceLock;
|
||||
static MODE: OnceLock<Option<Mode>> = OnceLock::new();
|
||||
OVERRIDE.with(|o| o.get()).unwrap_or_else(|| {
|
||||
*MODE.get_or_init(|| std::env::var("FORTSETZUNG").ok().and_then(|s| parse(&s)))
|
||||
})
|
||||
}
|
||||
|
||||
fn parse(s: &str) -> Option<Mode> {
|
||||
let weight = |x: &str| x.parse::<f64>().ok().filter(|x| x.is_finite());
|
||||
match s {
|
||||
"1" => Some(Mode { narrow: NARROW_DEFAULT, thin_value: true }),
|
||||
"bluff" => Some(Mode { narrow: NARROW_DEFAULT, thin_value: false }),
|
||||
_ => {
|
||||
if let Some(x) = s.strip_prefix("eng:") {
|
||||
weight(x).map(|narrow| Mode { narrow, thin_value: true })
|
||||
} else {
|
||||
s.strip_prefix("bluff:").and_then(weight).map(|narrow| Mode { narrow, thin_value: false })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Force the switch for this thread (`Some(None)` = off, `Some(Some(m))` = on with `m`),
|
||||
/// `None` = back to the environment. For node diagnosis and tests.
|
||||
pub fn set_override(mode: Option<Option<Mode>>) {
|
||||
OVERRIDE.with(|o| o.set(mode));
|
||||
}
|
||||
|
||||
/// Streets still to come after this one.
|
||||
fn streets_left(street: Street) -> i32 {
|
||||
match street {
|
||||
Street::Flop => 2,
|
||||
Street::Turn => 1,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Probability that the range continuing against a bet that folds `fold` bets the next street.
|
||||
fn bet_rate(spot: &Spot, fold: f64, narrow: f64) -> f64 {
|
||||
let next = |p: &crate::exploit::profile::Profile| match spot.street {
|
||||
Street::Flop => p.turn_aggression.or(p.aggression),
|
||||
_ => p.river_aggression.or(p.aggression),
|
||||
};
|
||||
let a = spot
|
||||
.live_villains()
|
||||
.filter_map(|v| v.profile.as_ref().and_then(next))
|
||||
.filter(|x| x.is_finite())
|
||||
.fold(None, |m: Option<f64>, x| Some(m.map_or(x, |m| m.max(x))))
|
||||
.unwrap_or(AGGRESSION_ANCHOR)
|
||||
.clamp(0.0, 1.0);
|
||||
(a + (1.0 - a) * fold.clamp(0.0, 1.0) * narrow).clamp(0.0, 1.0)
|
||||
}
|
||||
|
||||
/// Every live villain is read as a non-folding over-caller (`Style::CallingStation` with foldToBet at
|
||||
/// most `STATION_FOLD_TO_BET`): what continues is nearly its whole wide range, not the narrow betting
|
||||
/// range the model prices (pilot 15.11.: station -1,3 bb/100 with the discount, foldToBet read 0,25).
|
||||
/// A loose player who still folds (ladder maniac 0,39, reg) is read as a station too and gains from it
|
||||
/// (maniac +20, reg +9); aggression does not separate them (read 0,32 vs 0,35).
|
||||
fn over_callers_only(spot: &Spot) -> bool {
|
||||
use crate::exploit::style::{classify, Style, STATION_FOLD_TO_BET};
|
||||
let passive_station = |p: &crate::exploit::profile::Profile| {
|
||||
classify(p) == Style::CallingStation && p.fold_to_bet.is_some_and(|f| f.is_finite() && f <= STATION_FOLD_TO_BET)
|
||||
};
|
||||
let mut live = spot.live_villains().peekable();
|
||||
live.peek().is_some() && live.all(|v| v.profile.as_ref().is_some_and(passive_station))
|
||||
}
|
||||
|
||||
/// Share of `against` hero keeps over the later streets, per the model above. 1 when off.
|
||||
pub fn realisation(spot: &Spot, kind: RaiseKind, to: f64, fold: f64, against: f64) -> f64 {
|
||||
let Some(Mode { narrow, thin_value }) = mode() else { return 1.0 };
|
||||
let n = streets_left(spot.street);
|
||||
let untouched = kind == RaiseKind::Value || (kind == RaiseKind::ThinValue && !thin_value);
|
||||
if n == 0 || untouched || to >= spot.hero_stack || against <= 0.0 || against >= 0.5 {
|
||||
return 1.0;
|
||||
}
|
||||
if over_callers_only(spot) {
|
||||
return 1.0;
|
||||
}
|
||||
let p = bet_rate(spot, fold, narrow);
|
||||
let loss = p * (BET_SHARE * (1.0 - 2.0 * against) / against).min(1.0);
|
||||
(1.0 - loss).clamp(0.0, 1.0).powi(n)
|
||||
}
|
||||
|
||||
/// `against` after the continuation cost.
|
||||
pub fn discounted(spot: &Spot, kind: RaiseKind, to: f64, fold: f64, against: f64) -> f64 {
|
||||
against * realisation(spot, kind, to, fold, against)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn loss_crosses_over_at_the_call_price() {
|
||||
// e = BET_SHARE / (1 + 2 BET_SHARE): folding and calling cost the same.
|
||||
let e = BET_SHARE / (1.0 + 2.0 * BET_SHARE);
|
||||
assert!((BET_SHARE * (1.0 - 2.0 * e) / e - 1.0).abs() < 1e-12);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_the_variants() {
|
||||
assert_eq!(parse("1"), Some(Mode { narrow: NARROW_DEFAULT, thin_value: true }));
|
||||
assert_eq!(parse("bluff:0.8"), Some(Mode { narrow: 0.8, thin_value: false }));
|
||||
assert_eq!(parse("0"), None);
|
||||
assert_eq!(parse("eng:x"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn off_is_identity() {
|
||||
set_override(Some(None));
|
||||
assert_eq!(mode(), None);
|
||||
set_override(None);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ pub mod decide;
|
||||
pub mod double_board;
|
||||
pub mod effective;
|
||||
pub mod flop_spieler;
|
||||
pub mod fortsetzung;
|
||||
pub mod frist;
|
||||
pub mod from_plan;
|
||||
pub mod multiway;
|
||||
|
||||
@@ -133,6 +133,7 @@ pub fn scored(
|
||||
.filter_map(|to| {
|
||||
let fe = table_fold(spot, to, thresholds.fold_equity_scale);
|
||||
let against = realized_share(called.share_at(to, share), eff.villains);
|
||||
let against = super::fortsetzung::discounted(spot, kind, to, fe, against);
|
||||
let b = match (kind, check_raise_rate(spot)) {
|
||||
(RaiseKind::Value, _) | (_, None) => branches(spot, to, fe, against),
|
||||
(k, Some((rho, profile))) => branches_vs_raise(spot, to, fe, against, k, rho, profile.as_ref()),
|
||||
|
||||
+18
-3
@@ -43,14 +43,29 @@ pub fn earned_trust(style: Style) -> f64 {
|
||||
// (`mdf_floor::floor` on the raw spot in `engine::decide`); this gate governs only the
|
||||
// OFFENSIVE adjustments, which over-fire into strong ranges. So every non-over-caller stays
|
||||
// blind until the bluff-EV models the multi-street cost of a called barrel (BEFUND-nit-read-leck).
|
||||
Style::Regular => 0.0,
|
||||
Style::Nit => 0.0,
|
||||
Style::LooseAggressive => 0.0,
|
||||
// `LESE_VERTRAUEN` (measuring switch, off = bit-identical) opens the gate per style once the
|
||||
// bluff-EV prices the later streets (`engine::fortsetzung`, `FORTSETZUNG`).
|
||||
Style::Regular => trusted_by_switch("reg"),
|
||||
Style::Nit => trusted_by_switch("nit"),
|
||||
Style::LooseAggressive => trusted_by_switch("lag"),
|
||||
// No usable read.
|
||||
Style::Unknown => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Messschalter (einmal gelesen): `LESE_VERTRAUEN=nit,reg,lag` (eine beliebige Teilmenge) gibt
|
||||
/// diesen Stilen volles Vertrauen. Vorgabe: leer (alt, bit-identisch).
|
||||
fn trusted_by_switch(tag: &str) -> f64 {
|
||||
use std::sync::OnceLock;
|
||||
static LIST: OnceLock<Vec<String>> = OnceLock::new();
|
||||
let list = LIST.get_or_init(|| {
|
||||
std::env::var("LESE_VERTRAUEN")
|
||||
.map(|s| s.split(',').map(|t| t.trim().to_ascii_lowercase()).filter(|t| !t.is_empty()).collect())
|
||||
.unwrap_or_default()
|
||||
});
|
||||
if list.iter().any(|t| t == tag) { 1.0 } else { 0.0 }
|
||||
}
|
||||
|
||||
/// A read is acted on only when its style has earned trust on the ladder - the classes the exploit
|
||||
/// logic is measured to beat blind play against. Every other style falls back to blind.
|
||||
pub fn exploit_worthy(style: Style) -> bool {
|
||||
|
||||
@@ -22,7 +22,7 @@ const NIT_VPIP: f64 = 0.15;
|
||||
const NIT_FOLD_TO_BET: f64 = 0.65;
|
||||
/// Fold-to-bet claims about a "nit" only count if the player is not clearly loose.
|
||||
const NIT_MAX_VPIP_WITH_FOLDS: f64 = 0.25;
|
||||
const STATION_FOLD_TO_BET: f64 = 0.30;
|
||||
pub const STATION_FOLD_TO_BET: f64 = 0.30;
|
||||
const STATION_MIN_VPIP: f64 = 0.28;
|
||||
/// A calling station is loose AND postflop-passive. Above this postflop aggression frequency a
|
||||
/// loose-but-not-raising player is not a station — it only looks loose preflop. Sits between the
|
||||
@@ -119,7 +119,7 @@ pub fn classify(profile: &Profile) -> Style {
|
||||
classify_with(profile, station_postflop())
|
||||
}
|
||||
|
||||
fn classify_with(profile: &Profile, station_gate: bool) -> Style {
|
||||
pub fn classify_with(profile: &Profile, station_gate: bool) -> Style {
|
||||
let (vpip, pfr, fold, aggr) = (
|
||||
frequency(profile.vpip),
|
||||
frequency(profile.pfr),
|
||||
|
||||
Reference in New Issue
Block a user