ZEIGT_KIPP (Plan D3) aus pool-nl2-echt 3cd9fc9c uebernommen: gezeigte River-Haende kippen die River-Range je Preflop-Klasse; aus = bitgleich

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 17:33:05 +01:00
co-authored by Claude Opus 5.5
parent d0c928dca1
commit ddf0ba02a9
18 changed files with 361 additions and 14 deletions
+2
View File
@@ -29,6 +29,7 @@ const WEAK_PLAYER: Profile = Profile {
river_bluff_share: None,
river_bluff_shown: None,
flop_aggression: None,
shown_river: None,
fold_to_steal: None,
fold_to_raise: None,
raise_to_bet: None,
@@ -70,6 +71,7 @@ pub fn with_mark(measured: Option<Profile>, mark: &str) -> Option<Profile> {
river_bluff_share: known.river_bluff_share,
river_bluff_shown: known.river_bluff_shown,
flop_aggression: known.flop_aggression,
shown_river: known.shown_river,
fold_to_steal: known.fold_to_steal,
fold_to_raise: known.fold_to_raise,
raise_to_bet: known.raise_to_bet,
+6
View File
@@ -70,6 +70,12 @@ pub struct Profile {
pub river_bluff_shown: Option<f64>,
/// Aggression frequency on the FLOP only (memory handover `reads.flopAggression`). `None` without it.
pub flop_aggression: Option<f64>,
/// Shown hands on the river (plan D3, `profile.shown.linien` of the memory handover): the
/// preflop-class distribution (`range_spec::chen_class`) of what this player holds when he reaches
/// showdown after betting/raising the river (`[0]`, "river-aggr") or after checking/calling it
/// (`[1]`, "river-passiv"). Hierarchical: the line population is the prior, the player's own shown
/// hands pull it by their sample (`lesen/uebergabe._klassen_feld`). Used by `ZEIGT_KIPP=1` only.
pub shown_river: Option<[[f64; crate::exploit::range_spec::CLASSES]; 2]>,
/// How often the player, in a blind, folds to a steal raise (`reads.foldToSteal`).
pub fold_to_steal: Option<f64>,
/// How often the player folds after betting/raising a postflop street and being raised (`reads.foldToRaise`).
+25 -1
View File
@@ -68,9 +68,33 @@ pub fn range_spec(spot: &Spot, villain: &Villain) -> RangeSpec {
if spot.history.iter().any(|r| r.seat == villain.seat) {
let (raw_lo, raw_hi) = preflop_band(spot, villain);
let (lo, hi) = bounded(raw_lo, raw_hi);
RangeSpec { lo, hi, continues: continuations(spot, villain) }
RangeSpec { lo, hi, continues: continuations(spot, villain), class_target: shown_tilt(spot, villain) }
} else {
RangeSpec::top(top_fraction(spot, villain))
}
}
/// Messschalter (einmal gelesen) `ZEIGT_KIPP=1`: 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 {
use std::sync::OnceLock;
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| std::env::var("ZEIGT_KIPP").as_deref() == Ok("1"))
}
/// 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]> {
use crate::game::SeenAction as A;
if !shown_tilt_on() || spot.street != crate::game::Street::River {
return None;
}
let shown = villain.profile.as_ref()?.shown_river?;
let mut acted = false;
let mut aggr = false;
for r in spot.history.iter().filter(|r| r.seat == villain.seat && r.street == crate::game::Street::River) {
acted = true;
aggr |= matches!(r.action, A::Bet | A::Raise | A::AllIn);
}
acted.then(|| shown[if aggr { 0 } else { 1 }])
}
+72 -1
View File
@@ -10,6 +10,64 @@ pub struct RangeSpec {
pub lo: f64,
pub hi: f64,
pub continues: Vec<Continuation>,
/// 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]>,
}
/// Preflop classes of `chen_class` (= `lesen/zeigt_eval.py` KLASSEN).
pub const CLASSES: usize = 5;
/// Chen number of a two-card hand (= `lesen/zeigt_eval.chen`).
pub fn chen(hand: &[crate::card::Card]) -> f64 {
let (mut a, mut b) = (hand[0], hand[1]);
if b.rank.value() > a.rank.value() {
std::mem::swap(&mut a, &mut b);
}
let (ra, rb) = (a.rank.value() as i32, b.rank.value() as i32);
let points = |r: i32| match r {
14 => 10.0,
13 => 8.0,
12 => 7.0,
11 => 6.0,
_ => r as f64 / 2.0,
};
let mut p = points(ra);
if ra == rb {
return (2.0 * p).max(5.0);
}
if a.suit == b.suit {
p += 2.0;
}
let gap = ra - rb - 1;
p -= match gap {
0 => 0.0,
1 => 1.0,
2 => 2.0,
3 => 4.0,
_ => 5.0,
};
if gap <= 1 && ra < 12 {
p += 1.0;
}
p
}
/// 0 premium, 1 strong, 2 medium, 3 speculative, 4 weak (= `lesen/zeigt_eval.klasse`).
pub fn chen_class(hand: &[crate::card::Card]) -> usize {
let c = chen(hand);
if c >= 12.0 {
0
} else if c >= 9.0 {
1
} else if c >= 7.0 {
2
} else if c >= 5.0 {
3
} else {
4
}
}
/// "Villain bet or raised when the board had `board_len` cards": only hands at least
@@ -42,6 +100,19 @@ pub struct Continuation {
impl RangeSpec {
/// The best `top` fraction of starting hands, no postflop filter.
pub fn top(top: f64) -> RangeSpec {
RangeSpec { lo: 0.0, hi: top, continues: Vec::new() }
RangeSpec { lo: 0.0, hi: top, continues: Vec::new(), class_target: None }
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::card::Card;
#[test]
fn chen_classes_match_zeigt_eval() {
let k = |s: &str| chen_class(&Card::parse_list(s).unwrap());
// lesen/zeigt_eval.klasse: AA 0, AKs 0, 72o 4, T9s 2, KJo 2
assert_eq!([k("Ah Ad"), k("Ah Kh"), k("7h 2d"), k("Th 9h"), k("Kd Jc")], [0, 0, 4, 2, 2]);
}
}
+2
View File
@@ -40,6 +40,7 @@ pub const PRIOR: Profile = Profile {
river_bluff_share: None,
river_bluff_shown: None,
flop_aggression: None,
shown_river: None,
fold_to_steal: None,
fold_to_raise: None,
raise_to_bet: None,
@@ -97,6 +98,7 @@ pub fn shrink(profile: &Profile, hands: f64) -> Profile {
river_bluff_share: profile.river_bluff_share,
river_bluff_shown: profile.river_bluff_shown,
flop_aggression: profile.flop_aggression,
shown_river: profile.shown_river,
fold_to_steal: profile.fold_to_steal,
fold_to_raise: profile.fold_to_raise,
raise_to_bet: profile.raise_to_bet,