ZEIGT_KIPP=richtung: gezeigte Haende kippen die Aggressiv-Linie nur staerker, die Passiv-Linie nur schwaecher (nie gegen einen Station-Read); =aggr/=passiv zur Diagnose; =1 und aus unveraendert. Leck-Finder: --zusatz und --gezeigt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::card::{deck, Card};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use crate::exploit::range_spec::{chen_class, Continuation, RangeSpec, CLASSES};
|
||||
use crate::exploit::range_spec::{chen_class, ClassTilt, Continuation, RangeSpec, CLASSES};
|
||||
use crate::preflop::hand_percentile::percentile;
|
||||
use crate::read::draw::Draw;
|
||||
use crate::read::glance::glance;
|
||||
@@ -204,8 +204,10 @@ const CLASS_SALT: usize = 0x6_0000;
|
||||
/// Keep chance per class so the kept range has the class shares of `target`: the I-projection of the
|
||||
/// untilted range onto that class marginal is a per-class factor target_c / r_c (r = class shares of the
|
||||
/// untilted range), scaled so the largest factor keeps all. A class the range lacks stays out; `None`
|
||||
/// for Omaha, an empty range, or a target without mass.
|
||||
fn class_keep(target: &[f64; CLASSES], kept: &Kept) -> Option<[f64; CLASSES]> {
|
||||
/// for Omaha, an empty range, or a target without mass. With a direction (`ClassTilt::dir`) a target
|
||||
/// whose mean class moves the range the other way leaves it untilted (`None`).
|
||||
fn class_keep(tilt: &ClassTilt, kept: &Kept) -> Option<[f64; CLASSES]> {
|
||||
let target = &tilt.target;
|
||||
if kept.rules.hole_cards != 2 {
|
||||
return None;
|
||||
}
|
||||
@@ -220,6 +222,14 @@ fn class_keep(target: &[f64; CLASSES], kept: &Kept) -> Option<[f64; CLASSES]> {
|
||||
if n <= 0.0 || t <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
if tilt.dir != 0 {
|
||||
let mean_r: f64 = (0..CLASSES).map(|c| c as f64 * r[c] / n).sum();
|
||||
let mean_t: f64 = (0..CLASSES).filter(|&c| target[c].is_finite() && target[c] > 0.0).map(|c| c as f64 * target[c] / t).sum();
|
||||
// +1 = only stronger: the target's mean class must lie below the range's (0 = premium)
|
||||
if (mean_t - mean_r) * tilt.dir as f64 >= 0.0 {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
let mut f = [0.0; CLASSES];
|
||||
for c in 0..CLASSES {
|
||||
if r[c] > 0.0 && target[c].is_finite() && target[c] > 0.0 {
|
||||
|
||||
@@ -74,19 +74,42 @@ pub fn range_spec(spot: &Spot, villain: &Villain) -> RangeSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/// Messschalter (einmal gelesen) `ZEIGT_KIPP=1`: thin the villain's river range per preflop class toward
|
||||
/// Messschalter (einmal gelesen) `ZEIGT_KIPP`: thin the villain's river range per preflop class toward
|
||||
/// what he showed on his river line (`Profile::shown_river`). Off = no tilt, bit-identical.
|
||||
pub fn shown_tilt_on() -> bool {
|
||||
/// `1` both lines either way; `richtung` the aggressive line only stronger, the passive line only
|
||||
/// weaker (shown hands never argue a checking/calling range stronger = never against a station read);
|
||||
/// `aggr` / `passiv` one line only (diagnosis).
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
enum TiltMode {
|
||||
Off,
|
||||
Both,
|
||||
Direction,
|
||||
AggrOnly,
|
||||
PassiveOnly,
|
||||
}
|
||||
|
||||
fn tilt_mode() -> TiltMode {
|
||||
use std::sync::OnceLock;
|
||||
static ON: OnceLock<bool> = OnceLock::new();
|
||||
*ON.get_or_init(|| std::env::var("ZEIGT_KIPP").as_deref() == Ok("1"))
|
||||
static MODE: OnceLock<TiltMode> = OnceLock::new();
|
||||
*MODE.get_or_init(|| match std::env::var("ZEIGT_KIPP").as_deref() {
|
||||
Ok("1") => TiltMode::Both,
|
||||
Ok("richtung") => TiltMode::Direction,
|
||||
Ok("aggr") => TiltMode::AggrOnly,
|
||||
Ok("passiv") => TiltMode::PassiveOnly,
|
||||
_ => TiltMode::Off,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn shown_tilt_on() -> bool {
|
||||
tilt_mode() != TiltMode::Off
|
||||
}
|
||||
|
||||
/// The class target of the villain's range (`RangeSpec::class_target`): on the river, once he acted
|
||||
/// there, the shown-hand distribution of his line (aggressive = he bet/raised the river, else passive).
|
||||
fn shown_tilt(spot: &Spot, villain: &Villain) -> Option<[f64; super::range_spec::CLASSES]> {
|
||||
fn shown_tilt(spot: &Spot, villain: &Villain) -> Option<super::range_spec::ClassTilt> {
|
||||
use crate::game::SeenAction as A;
|
||||
if !shown_tilt_on() || spot.street != crate::game::Street::River {
|
||||
let mode = tilt_mode();
|
||||
if mode == TiltMode::Off || spot.street != crate::game::Street::River {
|
||||
return None;
|
||||
}
|
||||
let shown = villain.profile.as_ref()?.shown_river?;
|
||||
@@ -96,5 +119,13 @@ fn shown_tilt(spot: &Spot, villain: &Villain) -> Option<[f64; super::range_spec:
|
||||
acted = true;
|
||||
aggr |= matches!(r.action, A::Bet | A::Raise | A::AllIn);
|
||||
}
|
||||
acted.then(|| shown[if aggr { 0 } else { 1 }])
|
||||
if !acted || (mode == TiltMode::AggrOnly && !aggr) || (mode == TiltMode::PassiveOnly && aggr) {
|
||||
return None;
|
||||
}
|
||||
let dir = match mode {
|
||||
TiltMode::Direction if aggr => 1,
|
||||
TiltMode::Direction => -1,
|
||||
_ => 0,
|
||||
};
|
||||
Some(super::range_spec::ClassTilt { target: shown[if aggr { 0 } else { 1 }], dir })
|
||||
}
|
||||
|
||||
@@ -13,7 +13,16 @@ pub struct RangeSpec {
|
||||
/// Shown-hand tilt (`ZEIGT_KIPP`, plan D3): the preflop-class distribution (`chen_class`, 0 premium
|
||||
/// .. 4 weak) the hands of this range have in what the villain showed on this line. The range is
|
||||
/// thinned per class toward it (`engine::range_filter`); `None` = no tilt (as before).
|
||||
pub class_target: Option<[f64; CLASSES]>,
|
||||
pub class_target: Option<ClassTilt>,
|
||||
}
|
||||
|
||||
/// The shown-hand tilt of a range (`RangeSpec::class_target`): the class target, and the only direction
|
||||
/// the tilt may move the range (`ZEIGT_KIPP=richtung`): `+1` only stronger (mean preflop class falls),
|
||||
/// `-1` only weaker, `0` either way (`ZEIGT_KIPP=1`). A tilt the wrong way is not applied.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct ClassTilt {
|
||||
pub target: [f64; CLASSES],
|
||||
pub dir: i8,
|
||||
}
|
||||
|
||||
/// Preflop classes of `chen_class` (= `lesen/zeigt_eval.py` KLASSEN).
|
||||
|
||||
Reference in New Issue
Block a user