/// Observed opponent tendencies, all frequencies in `[0, 1]`. Every field optional. /// Wire shape (extension): /// `"profile": {"vpip": 0.45, "pfr": 0.08, "foldToBet": 0.3, "aggression": 0.4}`. /// /// The fields below `aggression` are the HUD numbers the client already delivers but the core did /// not read before (`lesen/profil.py` DURCHGEREICHT). They carry their client names on the wire /// (`src/wire/decode_villain.rs`) and reach the engine per villain. No exploit rule reads them yet: /// every new read must first earn its place on the ladder benchmark (`read_gate`), which no /// candidate has so far. They stand ready for the opponent memory and future, ladder-proven rules. #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct Profile { /// Voluntarily put money in pot, preflop. pub vpip: Option, /// Preflop raise frequency. pub pfr: Option, /// How often the player folds to a bet postflop. pub fold_to_bet: Option, /// Share of the player's postflop actions that are bets or raises (aggression /// frequency). Steers how much of their betting range is a bluff (`bluff_share`). pub aggression: Option, /// Aggression frequency on the TURN only (bets+raises over the player's turn actions). `None` /// until the memory/HUD has turn data. The turn gearbox (`engine::turn_subgame`) prefers it over /// the pooled `aggression`: a player who barrels turns but checks flops reads as a turn bluffer /// here, so the defensive veto does not fold a good call against them. pub turn_aggression: Option, /// Aggression frequency on the RIVER only. `None` until the memory/HUD has river data. The river /// gearbox (`engine::river_subgame`) prefers it over the pooled `aggression`, since river bluffing /// tendency differs from flop/turn barreling. pub river_aggression: Option, /// Fold-to-bet split by street `[flop, turn, river]`, already shrunk toward the pooled /// `fold_to_bet` by the street's own sample size (`sim::memory`), so a thin street stays at the /// pooled read and a well-sampled one moves to its own rate. `None` per street = no data. Read /// only by `fold_chance::fold_chance_on` (hero's fold equity on that street). pub street_fold_to_bet: [Option; 3], /// How often the player continuation-bets the flop as the preflop aggressor. pub cbet: Option, /// How often the player folds to a continuation bet. pub fold_to_cbet: Option, /// Preflop three-bet frequency. pub three_bet: Option, /// How often the player folds to a three-bet. pub fold_to_three_bet: Option, /// How often the player attempts to steal the blinds from late position. pub steal: Option, /// How often the player check-raises. pub check_raise: Option, /// Went to showdown: how often the player reaches showdown once seeing the flop. A high /// value marks a sticky, showdown-happy opponent. pub wtsd: Option, /// Won at showdown: how often the player wins once at showdown. pub wsd: Option, /// Confidence in this read, in `[0, 1)`: 0 without data, rising with the observed postflop /// sample (half at `sim::memory::CONFIDENCE_HALF` actions). Not a tendency — it says how far the /// read may be trusted. The river gearbox (`engine::river_subgame`) turns it into the KL trust /// radius λ: strong read → exploit far, weak read → stay near GTO. `None` = no confidence signal /// (treated as 0 by the gearbox). No classify/gate rule reads it; it only scales exploitation. pub confidence: Option, /// Confidence of the AGGRESSION read alone, in `[0, 1)`. Live the client HUD has no aggression: /// it comes from the few postflop moves this session saw (`lesen/profil.py`), while `confidence` /// comes from the HUD hand count, so the two can disagree by orders of magnitude (500 HUD hands, /// 2 seen moves). `None` = the aggression read is as good as `confidence` (the session memory, /// where both come from the same postflop sample). Read through `bluff_read_confidence`. pub aggression_confidence: Option, /// River showdown read: of the player's river bets/raises that were SHOWN DOWN, the share that was /// air (equity below `AIR_STRENGTH` vs a random hand on the final board). Unbiased evidence of the /// river betting range: whether hero calls depends on hero's cards, not the bettor's. The river /// gearbox blends it into its bluff belief by `river_bluff_shown` (`engine::river_subgame`). pub river_bluff_share: Option, /// How many river bets/raises `river_bluff_share` rests on. pub river_bluff_shown: Option, /// Aggression frequency on the FLOP only (memory handover `reads.flopAggression`). `None` without it. pub flop_aggression: Option, /// 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, /// How often the player folds after betting/raising a postflop street and being raised (`reads.foldToRaise`). pub fold_to_raise: Option, /// How often the player RAISES when facing a postflop bet (raises over folds + calls + raises facing /// a bet). Sim memory only so far (`RERAISE_TIEFE` gate); `None` without it. pub raise_to_bet: Option, /// How many chances (`reads.raiseToBet.n`) `raise_to_bet` rests on; `None` without a counted read. /// Used by `POSTERIOR=...,fluss:` (thin reads keep the incoming bluff share on flop/turn). pub raise_to_bet_n: Option, /// How often the player RE-RAISES when raised after their own postflop bet/raise on that street /// (aggressive over fold + call + aggressive in that spot). Drives the `RERAISE_TIEFE` narrowing /// per raise level; `None` without it (pool value). pub reraise_to_raise: Option, /// How strongly the player's bet size tells their strength, as a gain on the population's /// size notch (`exploit::size_notch`): 1 = the population (bigger is stronger, as assumed), 0 = no /// tell, negative = reverse sizing, 2 = a pure value-sizer. From the shown (size, strength) pairs, /// shrunk toward 1. Sim memory only so far; used under `GROESSE_LESEN=1`. pub size_gain: Option, /// Set by `engine::read_gate` (switch `ANGRIFF_FOLD`) on the reduced profile of an untrusted style: /// only the fold reads were kept, so the profile has no style (`exploit::style::classify` = /// Unknown) and only the fold chance of hero's bets uses it. Never on the wire. pub fold_only: bool, /// Set by `engine::read_gate` (switch `POOL_PRIOR`) on the stake's pool baseline of an unread or /// gated villain: only the pool's passive fold reads, faded by the villain's own sample. No style /// (`classify` = Unknown); the bet over-bluff prior of an unread villain still applies /// (`exploit::bluff_share`). Never on the wire. pub pool_baseline: bool, /// With `pool_baseline`: the villain's raises carry the pool's value share (no population /// over-bluff prior on a raise), because his own raise read is not wider than the anchor. pub pool_raise_value: bool, /// Counted open-bet frequency per postflop street (flop, turn, river): `(bets, chances)` when the /// player was to act with no bet on the street yet (check or bet). Calls are not in it, unlike /// `aggression`. Drives the bluff share of an open bet under `EINSATZ_BLUFF` (`exploit::bet_open`). pub bet_open: [Option<(f64, f64)>; 3], /// Groessenaufgeloeste Reads (`VORWISSEN_KERN=1`, siehe `Vorwissen`); leer = nichts geliefert. pub vorwissen: Vorwissen, } /// Ein gezaehlter Read einer Zelle: `k` Treffer in `n` Chancen, dazu das gelieferte Beta-Prior `(a, b)`. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Zaehlung { pub k: f64, pub n: f64, pub prior: Option<(f64, f64)>, } impl Zaehlung { /// Schrumpfmittel `(k + a) / (n + a + b)`; ohne Prior `None` (der Aufrufer nimmt dann den Pool-Wert der Zelle). pub fn mittel(&self, pool: f64) -> f64 { let (a, b) = self.prior.unwrap_or((pool * PRIOR_OHNE, (1.0 - pool) * PRIOR_OHNE)); ((self.k + a) / (self.n + a + b)).clamp(0.0, 1.0) } /// Eigene Konfidenz `n / (n + a + b)` in `[0, 1)`. pub fn konfidenz(&self) -> f64 { let s = self.prior.map_or(PRIOR_OHNE, |(a, b)| a + b); if self.n > 0.0 { self.n / (self.n + s) } else { 0.0 } } } /// Pseudo-Chancen, wenn kein Prior geliefert wurde. const PRIOR_OHNE: f64 = 15.0; /// Groessenklassen der Reads: k <= 0,4, m <= 0,8, g <= 1,2, u darueber (`bettor::answer_of`). pub const KLASSEN: [char; 4] = ['k', 'm', 'g', 'u']; /// Index der Groessenklasse zu einem Einsatz von `ratio` Toepfen (`None`: unbekannt). pub fn klasse_index(ratio: f64) -> Option { let c = crate::exploit::bettor::answer_of(Some(ratio), false)?; KLASSEN.iter().position(|k| *k == c) } /// Schalter `VORWISSEN_KERN=1` (einmal gelesen; aus = bitgleich): der Kern liest die groessenaufgeloesten Reads /// (`wett_kurve`, `street_continuation`). pub fn vorwissen_an() -> bool { vorwissen_fold_an() || vorwissen_bluff_an() != 0 } fn schalter_an(name: &str) -> bool { std::env::var(name).as_deref() == Ok("1") } /// Kanal Fold (Obergrenze K1/K3): die Fold-Kurve auf Heros Einsatz je Strasse x Groesse geht als Antwortfrequenz in /// den Solve (`wett_kurve`). An mit `VORWISSEN_FOLD=1` oder `VORWISSEN_KERN=1`. pub fn vorwissen_fold_an() -> bool { vorwissen_fold_art() != 0 } /// Art des Fold-Kanals: 0 aus, 1 ueberall (`VORWISSEN_FOLD=1` / `VORWISSEN_KERN=1`), 2 nur in Entscheidungen ohne /// offenen Einsatz (`VORWISSEN_FOLD=setzen`: Heros Einsatz-Knoten; vor einem Einsatz bleibt alles wie aus), /// 3 wie 2 und nur mit Wert-Hand (`VORWISSEN_FOLD=wert`: Perzentil der Hand gegen alle Zwei-Karten-Haende >= 0,5). /// Das Tor je Entscheidung setzt `wett_kurve::setze_lage`. pub fn vorwissen_fold_art() -> u8 { use std::sync::OnceLock; static AN: OnceLock = OnceLock::new(); *AN.get_or_init(|| match std::env::var("VORWISSEN_FOLD").as_deref() { Ok("1") => 1, Ok("setzen") => 2, Ok("wert") => 3, _ if schalter_an("VORWISSEN_KERN") => 1, _ => 0, }) } /// Kanal Bluff (Obergrenze K4): River-Bluffanteil je Groesse. 0 = aus, 1 = absolut eingemischt (`VORWISSEN_KERN=1`, /// Verlierer auf dev), 2 = relativ im Logit gegen das Prior-Mittel (`VORWISSEN_BLUFF=1`, hat Vorrang), 3 = relativ aus /// dem Showdown-Verlust des Setzers `riverVerlust_` (`VORWISSEN_BLUFF=verlust`, beide Richtungen: mehr /// Calls gegen Viel-Verlierer, mehr Folds gegen Wenig-Verlierer). pub fn vorwissen_bluff_an() -> u8 { use std::sync::OnceLock; static AN: OnceLock = OnceLock::new(); *AN.get_or_init(|| match std::env::var("VORWISSEN_BLUFF").as_deref() { Ok("verlust") => 3, Ok("1") => 2, _ if schalter_an("VORWISSEN_KERN") => 1, _ => 0, }) } /// Die groessenaufgeloesten Reads eines Gegners (Draht `FoldToBet_`, `riverBluffShown_`). #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct Vorwissen { /// Fold gegen Einsatz/Raise je Strasse (Flop, Turn, River) und Groessenklasse (`KLASSEN`). pub fold: [[Option; 4]; 3], /// Luft-Anteil gezeigter River-Einsaetze je Groessenklasse. pub bluff_river: [Option; 4], /// Anteil verlorener Showdowns, wenn er am River setzt und gecallt wird (Topfzuteilung), je Groessenklasse. pub verlust_river: [Option; 4], /// Rohe Haende des Spielers im Jahresprofil (Draht `profile.vorwissen.roh`); nur `SPAET_FOLD` liest sie (Typ reg/selten). pub haende_roh: Option, } impl Vorwissen { pub const LEER: Vorwissen = Vorwissen { fold: [[None; 4]; 3], bluff_river: [None; 4], verlust_river: [None; 4], haende_roh: None }; } /// Equity vs a random hand on the river below which a shown river bet counts as air (a bluff): the /// lower two strength bands (`sim::welt_memory::STRENGTH_BANDS`). pub const AIR_STRENGTH: f64 = 0.4; impl Profile { /// How far a read about this player's BLUFFING may be trusted: the weaker of the overall read /// and the aggression read. `None` = no confidence signal (the gearbox treats it as 0). pub fn bluff_read_confidence(&self) -> Option { let ok = |x: Option| x.filter(|c| !c.is_nan()); match (ok(self.confidence), ok(self.aggression_confidence)) { (Some(c), Some(a)) => Some(c.min(a)), (c, _) => c, } } }