diff --git a/betrieb/kern_schalter.txt b/betrieb/kern_schalter.txt index f5d06d0a..0667f893 100644 --- a/betrieb/kern_schalter.txt +++ b/betrieb/kern_schalter.txt @@ -114,3 +114,9 @@ TISCHWAHL_AB=abba # Call-Schwelle hoechstens 5/Shove-bb, nie unter 3,5 %. Live-Beleg 179404400152: A9o callt 133 bb als "top 28 %", -82 BB. # Volles Tor ohne Verlierer (6-max +0,99, sonst bitgleich). ALLIN_TIEFE=1 + +# Orchestrator-Entscheid 17.11. (exploit-live a901b406): Luft-C-Bet heads-up als Vorflop-Aggressor am Flop. Harte Regel +# "reiner Bluff braucht P(fold) >= 0,45, darf aber nur 0,26-0,40 Pot" liess fast nie Luft c-betten (live C-Bet 31 %, +# Luft 4 %). Jetzt P(fold) >= 0,30, grosse Value-Groessen erlaubt, muss Check per EV schlagen; nur gegen Gegner mit +# gezaehltem Read "raist selten" (beleg-Rampe). Volles Tor ohne Verlierer: Leiter +0,55, pool-nl2-echt +0,62, pool-phh +0,24. +CBET_LUFT=flop,gross,beleg diff --git a/docs/notizen/PLAN-weltklasse.md b/docs/notizen/PLAN-weltklasse.md index 967c415f..f7030bd7 100644 --- a/docs/notizen/PLAN-weltklasse.md +++ b/docs/notizen/PLAN-weltklasse.md @@ -290,6 +290,8 @@ Zeit-Tells (≈ 1 bb/100), Turnier-Extras (Bubble-Versicherung, Rebuy, K-Poker-K **Stand 16.11. spät (Flussleck, Posten 1):** `WERT_BRETT=river` (River-Boden der Wett-Range als Stärke auf dem Brett statt Handklasse, erster Schritt von #1) hat das volle Tor bestanden (Leiter +2,42, Micro +4,47, 6-max +1,36, kein Verlierer) und behebt den Straßen-Call auf Vierflush. Der AJ-Jam (−108 BB) bleibt Ziel: auch read-gesteuert (`JAM_LESER`, nur gegen gelesene Vielfolder) verliert die engere Jam-Range im 6-max (−3,54 ±1,35); gegen die Sim-Gegner trägt die Fold-Equity den Jam. Auch mit an PHH geeichten River-Callern (`SIM_RIVERCALL=1`, ab jetzt Standard aller Engine-Tore) verlieren beide Formen (6-max −4,99 / −2,31); verworfen. Details in STAND. River-Value OOP (Drilling+ checkt): Ursache ist das Value-Tor in `options::raise_kind`, nicht `check_ev`; `FLUSS_WERT=1` hat das volle Tor bestanden (Micro und Lerner Gewinner, kein Verlierer) und ist seit 16.11. spät live (Merge defa8f45). Große Pots (höchste Priorität): Ein-Paar-Raise gegen eine Wette ist der größte offene Leck-Block; `PAAR_RAISE=gelesen` (Raise nur gegen passiv gelesene Gegner blocken) hat das volle Tor bestanden (Leiter +1,03, Lerner +1,97, kein Verlierer) und ist seit 16.11. nachts live; `PAAR_RAISE=nie/antwort/passiv` verworfen. River-Jam mit einem Paar: Rechenfehler (Jam ohne Call-Range, Board-Paar als two pair) behoben, `CALLED_JAM=gelesen` + `BRETT_PAAR=raise` hat das volle Tor bestanden (Leiter +2,23, Micro +3,51, kein Verlierer) und ist seit 17.11. nachts live; die breiten Formen (`=1`) verlieren gegen die Calling Station. `pool-nl2-echt` bildet den Live-Verlust dieser Linie nicht ab, auch nicht echt-hart: der Beleg ist live (16 Hände, −311 BB), Nachweis im nächsten Echtgeld-Lauf. **17.11. vormittags:** Rest-Leck führender Jam (178907801564) → `BRETT_PAAR=groesse` (nur River, höchstens Pot mit Board-Paar-two-pair) und preflop `ALLIN_TIEFE=1` (Call gegen tiefe Shoves enger) haben das volle Tor bestanden und sind live. Offen in der Familie: Raise-Jams mit Paar/Set gegen kleine Wetten, Jams knapp über Pot. +**Stand 17.11. (C-Bet, Live-Analyse):** Die 31 % C-Bet (echt) sind Faustregel #16 (`engine/bluff.rs`, harte Bluff-Sperre `PURE_BLUFF_MIN_FOLD` 0,45 bei Bluffgrößen, die nur 0,28 Fold bringen), nicht die Fold-Schätzung (deckt sich mit dem echten Pool 0,33/0,47). `CBET_LUFT=flop,gross,beleg` hat das volle Tor bestanden (Leiter +0,55 ±0,30, pool-nl2-echt +0,62, pool-phh +0,24, kein Verlierer, LBR bitgleich; STAND §20), Branch claude/cbet-luft, zum Live-Schalten an den Orchestrator. Fold gegen 3-Bet: kein Leck. + Nach Geld sortiert. Gemessen sind nur D4 (River ~11,5, Turn ~8,5, Preflop ~1,7 bb/100 Entscheidungsverlust) und die Live-Verluste, der Rest ist geschätzt. | # | Stelle | heute | Ersatz | Session | diff --git a/docs/notizen/STAND-weltklasse.md b/docs/notizen/STAND-weltklasse.md index c0784dd5..6930b7d6 100644 --- a/docs/notizen/STAND-weltklasse.md +++ b/docs/notizen/STAND-weltklasse.md @@ -380,3 +380,21 @@ Zweig `claude/gedaechtnis-pokerintel` (Worktree gedaechtnis-voll), nicht im Live | Rueck-Test All-in-Linie | Linie: wir erhoehen, er geht darueber all-in, wir callen. Echt 10 Faelle in 3304 Haenden (3,0 je 1000, −43 ±44 bb je Fall). pool-nl2: 0,9 je 1000, −36 ±21. pool-nl2-echt: 1,0 je 1000, −15 ±22. **Nicht reproduziert:** die Haeufigkeit liegt etwa dreimal zu niedrig, und die Linie ist mit echt billiger, weil seine All-ins zu wertlastig sind. Am Stack liegt es nicht (Median 104 bb) | | Nebenbefund Live-Leser | `spot_from_log` traegt viele Einsaetze mit Betrag 0 ein (15.11.: 232 von 544 Gegner-Einsaetzen); der echte betAmout folgt in einer spaeteren Bohne. Nicht behoben (nur in linien.py geflickt) | | Vorlage | Zeile `pool-nl2-echt` mit POOL_PERSONA=persona-nl2-echt.json, siehe messung/gedaechtnis/linien/README.md | + +## 20. Nachtrag 17.11.: Live-Analyse C-Bet und Fold gegen 3-Bet (Auftrag Orchestrator, exploit-live) + +Daten: `archiv/lauf/haende.jsonl` + `zuege.jsonl` (Live-Baum), NL 0,01/0,02 ab 14.11., 5386 Hände (Auftrag zählte 2651 bis zum Vormittag), netto −972 BB. Analyse-Skripte im Scratchpad, Probe `src/bin/probe_cbet.rs`. + +| Was | Ergebnis | +|---|---| +| C-Bet als Vorflop-Aggressor, heads-up | 148 Bet / 335 Check = **31 %**. Netto der Bet-Hände +533 BB, der Check-Hände −200 BB (dazu multiway Check −218). Check-Hände: Equity-Median 0,37 (Quartile 0,22–0,54), meist "air" und "middle pair"; Bet-Hände Median 0,73 → wir setzen fast nur Wert | +| Fold des echten Pools auf unsere Einsätze (heads-up, erste Aktion der Straße) | Flop **33 % unter 0,4 Pot (n 107), 47 % bei 0,6–0,8 Pot (n 112)**; Turn 31 % / 41 %; River 50 % / 48 %. Fold auf unsere C-Bet insgesamt 45 % (n 148) | +| Was die Engine annimmt | C-Bet-Fold aus `fold_base_cbet`: HUD-foldToCbet (Server, Tischmittel 0,33) über `hud_profile` zum foldToBet-Anker geschrumpft → Basis ≈ 0,46–0,50; Größenformel `1−(1−f)^(r/0,66)` gibt 0,28 bei 1/3 Pot, 0,47 bei 2/3 Pot. **Das deckt sich mit dem echten Pool** (0,33 / 0,47): die Fold-Schätzung ist nicht das Leck | +| Ursache der 31 % | Struktur: reiner Bluff braucht `P(fold) ≥ PURE_BLUFF_MIN_FOLD` 0,45 (`engine/bluff.rs`), seine Größen (`BLUFF_BAND` 33–50 % × Flop 0,8) erlauben nur 0,26–0,40 Pot, wo P(fold) ≈ 0,28 ist. **Eine Luft-C-Bet besteht damit nie** (außer gegen gelesene Folder). Bei 2/3 Pot und Fold 0,47 bringt sie ≈ 0,3 Pot gegen ≈ 0,2 Pot fürs Checken | +| Pool-Eichung verdrahtet? | `lesen/pool.py` zählt foldToCbet aus echten Händen (NL2 μ 0,488, 285 Spieler, Tor nicht bestanden), `GEGNER_POOL` ist aus; die Bet-Entscheidung sieht nur HUD + Kern-Anker. Für die C-Bet reicht das (s. o.) | +| Sim gegen echt (Probe, Live-Schalter, SIM_RIVERCALL=1, 10 000 Deals) | Engine-C-Bet pool-nl2-echt 32 %, pool-phh 36 % (echt 31 %), mit Luft 4 % / 6 % → **Sim reproduziert das Verhalten**. Fold der Sim-Gegner: pool-nl2-echt 61 % unter 0,4 Pot, 58 % ab 0,6 Pot (echt 33 / 47 %) → **pool-nl2-echt foldet zu oft**, ein Bet-Kandidat sieht in der Sim besser aus als live. pool-phh 14 % / 71 % (kleine n) | +| Kandidat `CBET_LUFT=flop,gross` (`engine/cbet_luft.rs`, Branch claude/cbet-luft) | Nur C-Bet heads-up als Vorflop-Aggressor (Flop, nichts zu callen): reiner Bluff braucht P(fold) ≥ 0,30 statt 0,45 und darf die Wertgrößen nehmen, die EV wählt; EV-Vorsprung `PURE_BLUFF_EDGE` bleibt. `flop` allein ist bitgleich (bei kleinen Größen bleibt P(fold) < 0,30). Probe: Luft-C-Bet 4 → 16 % (echt), 6 → 20 % (phh), C-Bet gesamt 32 → 40 %. Optional `turn` (Stab nach gechecktem Flop), nicht im Tor (Turn spielt meist `TURN_SPIEL=grund`). Volles Tor cb-* (9 Zellen je aus/an, eigenes Binary, SIM_RIVERCALL=1), Ergebnis unten | +| Tor 1 `CBET_LUFT=flop,gross` (cb-*) | Leiter +0,38 ±0,33, pool-nl2-echt +0,52 ±0,31, pool-phh +0,24, Lerner +0,57; **nemesis-2 −1,64 ±1,20 (Leiter) und nemesis-2@blind −3,26 ±1,73 Verlierer** (leichter Raiser hebt Luft-C-Bets aus) → verworfen | +| **Tor 2 bestanden `CBET_LUFT=flop,gross,beleg`** (cb2-*-an gg. cb-*-aus; `messung/cbet/TOR.md`) | `beleg`: nur soweit der gezählte ungegatete `raise_to_bet` unter dem Anker liegt (S2-Rampe 0,30→0,25; ohne Read aus). **Leiter +0,55 ±0,30 ohne Verlierer** (nemesis-1/2, station bitgleich; polar +2,30, umgekehrt +1,68, textur-cbet +1,37, 3bet-folder +1,12, fish +1,46), **Micro +0,17 ±0,15** (@blind bitgleich), pool-nl2 +0,49 ±0,51, **pool-nl2-echt +0,62 ±0,27**, echt-hart +0,62 ±0,27, **pool-phh +0,24 ±0,16**, Lerner +0,47 ±0,35, 6-max +0,03 ±0,03, LBR blind bitgleich. Klein in der Sim, weil die Rampe den Read braucht; live liegt der gezählte raiseToBet des Pools (μ 0,105) bald unter 0,25 | +| Fold gegen 3-Bet (Befund 3) | **Kein Leck.** Die 80–89 % (BB 94 %, SB 89 %, BTN 96 %) sind fast nur kalte Spots (ein anderer eröffnet, ein Dritter 3-bettet): Fold dort richtig. Nach eigenem Open folden wir 44–67 % je Position (gesamt 57 %, n 210), weiter mit 31 % Call / 10 % 4-Bet; die fortgesetzten Hände −129 BB auf 95 (Rauschen, 4-Bets +248). Pool 3-Bet 8,4 % (gezählt) = wertlastig. Kein Kandidat | +| Nebenbefund Tests | Volle `cargo test --lib` auf dem Live-Stand: 2 lerner-Bitgleich-Tests scheitern nur im Parallel-Lauf (einzeln grün, auch ohne Kandidat) | diff --git a/entscheiden/decide.py b/entscheiden/decide.py index 9d83878b..6eca307d 100644 --- a/entscheiden/decide.py +++ b/entscheiden/decide.py @@ -44,7 +44,7 @@ BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", " "TURN_RAISE_BLUFF", "TURN_RAISE_NUR", "STATION_POSTFLOP", "POKERINTEL", "REST_STACK", "FORTSETZUNG", "POOL_PRIOR", "POSTERIOR", "GEGNER_LINIEN", "PREFLOP_VOLL", "PREFLOP_OHNE_ANTE", "PREFLOP_MIKRO", "PREFLOP_VOLL_TEILE", - "WERT_BRETT", "FLUSS_WERT", "PAAR_RAISE", "BRETT_PAAR", "CALLED_JAM", "ALLIN_TIEFE", + "WERT_BRETT", "FLUSS_WERT", "PAAR_RAISE", "BRETT_PAAR", "CALLED_JAM", "ALLIN_TIEFE", "CBET_LUFT", "TISCHWAHL", "TISCHWAHL_AB", "SITZWAHL") # Schalter des LAEUFERS (betrieb/runner.py liest sie aus seiner eigenen Umgebung, nicht der Kern): aus der # Datei auch in os.environ, sonst schaltete ein Eintrag hier nichts. Eine ausdrueckliche Umgebung geht vor. diff --git a/messung/cbet/TOR.md b/messung/cbet/TOR.md new file mode 100644 index 00000000..ca123b1e --- /dev/null +++ b/messung/cbet/TOR.md @@ -0,0 +1,68 @@ +# CBET_LUFT Tor 17.11. (exploit-live) + +Runde 1 cb-* (flop,gross): nemesis-2 Leiter -1,64 +-1,20, nemesis-2@blind -3,26 +-1,73 VERLIERER -> verworfen. +Runde 2 cb2-*-an (flop,gross,beleg) gegen cb-*-aus, SIM_RIVERCALL=1, Live-Schalter: +``` +===== leiter +3bet-folder A +40.88 B +42.00 B-A +1.12 ± 0.86 (2000 Deals x 4) besser +balanciert A +51.58 B +52.02 B-A +0.45 ± 0.62 (2000 Deals x 4) +cbet-folder A +33.82 B +34.37 B-A +0.55 ± 2.09 (2000 Deals x 4) +check-raiser A +40.34 B +40.59 B-A +0.25 ± 3.31 (2000 Deals x 4) +fish A +105.94 B +107.40 B-A +1.46 ± 0.92 (4000 Deals x 4) besser +gto A -4.42 B -3.55 B-A +0.87 ± 1.26 (2000 Deals x 4) +maniac A +8.83 B +8.07 B-A -0.76 ± 1.84 (4000 Deals x 4) +nemesis-1 A +62.43 B +62.43 B-A +0.00 ± 0.00 (4000 Deals x 4) +nemesis-2 A +82.75 B +82.75 B-A +0.00 ± 0.00 (4000 Deals x 4) +nemesis-3 A +32.55 B +32.58 B-A +0.04 ± 0.22 (4000 Deals x 4) +nit A +61.52 B +61.84 B-A +0.32 ± 0.19 (4000 Deals x 4) besser +polar A +39.99 B +42.29 B-A +2.30 ± 1.77 (2000 Deals x 4) besser +position A +40.95 B +39.78 B-A -1.17 ± 1.67 (2000 Deals x 4) +reg A +42.15 B +42.79 B-A +0.64 ± 0.79 (4000 Deals x 4) +station A +346.70 B +346.70 B-A +0.00 ± 0.00 (4000 Deals x 4) +tanker A +49.06 B +49.86 B-A +0.80 ± 0.56 (2000 Deals x 4) besser +textur-cbet A +33.03 B +34.41 B-A +1.37 ± 1.02 (2000 Deals x 4) besser +umgekehrt A +88.48 B +90.16 B-A +1.68 ± 1.13 (2000 Deals x 4) besser +wert-sizer A +41.11 B +41.60 B-A +0.48 ± 1.05 (2000 Deals x 4) +Mittel B-A +0.55 ± 0.30 +===== micro +fish@blind A +75.08 B +75.08 B-A +0.00 ± 0.00 (4000 Deals x 4) +gto@blind A -20.59 B -20.59 B-A +0.00 ± 0.00 (2000 Deals x 4) +maniac@blind A +18.00 B +18.00 B-A +0.00 ± 0.00 (4000 Deals x 4) +micro-passiv A +72.78 B +74.14 B-A +1.36 ± 1.17 (2000 Deals x 4) besser +micro-passiv@blind A +59.76 B +59.76 B-A +0.00 ± 0.00 (2000 Deals x 4) +nemesis-2@blind A +89.71 B +89.71 B-A +0.00 ± 0.00 (4000 Deals x 4) +polar@blind A +26.26 B +26.26 B-A +0.00 ± 0.00 (2000 Deals x 4) +station@blind A +259.60 B +259.60 B-A +0.00 ± 0.00 (4000 Deals x 4) +Mittel B-A +0.17 ± 0.15 +===== nl2 +pool-nl2 A +61.21 B +61.71 B-A +0.49 ± 0.51 (2000 Deals x 4) +Mittel B-A +0.49 ± 0.51 +===== lerner +lerner A +54.99 B +55.34 B-A +0.35 ± 1.97 (2000 Deals x 4) +lerner-k-drei A +57.57 B +58.19 B-A +0.62 ± 0.69 (2000 Deals x 4) +lerner-k-flop A +58.96 B +59.72 B-A +0.76 ± 0.64 (2000 Deals x 4) besser +lerner-k-open A +61.11 B +61.96 B-A +0.85 ± 0.68 (2000 Deals x 4) besser +lerner-k-river A +59.06 B +59.82 B-A +0.76 ± 0.64 (2000 Deals x 4) besser +lerner-k-spaet A +52.41 B +53.20 B-A +0.79 ± 0.78 (2000 Deals x 4) besser +lerner-k-wert A +60.30 B +59.62 B-A -0.68 ± 1.70 (2000 Deals x 4) +lerner-n2 A +167.22 B +167.22 B-A +0.00 ± 0.00 (2000 Deals x 4) +lerner-nit A +60.11 B +60.31 B-A +0.20 ± 0.27 (2000 Deals x 4) +lerner-statisch A +59.06 B +59.82 B-A +0.76 ± 0.64 (2000 Deals x 4) besser +wechsler-fr A +96.69 B +97.06 B-A +0.38 ± 1.79 (2000 Deals x 4) +wechsler-mn A +76.60 B +75.69 B-A -0.92 ± 2.16 (2000 Deals x 4) +wechsler-nm A +42.51 B +44.13 B-A +1.62 ± 1.63 (2000 Deals x 4) +wechsler-rf A +96.08 B +97.19 B-A +1.11 ± 1.98 (2000 Deals x 4) +Mittel B-A +0.47 ± 0.35 +===== echt +pool-nl2-echt A +60.16 B +60.78 B-A +0.62 ± 0.27 (2000 Deals x 8) besser +Mittel B-A +0.62 ± 0.27 +===== phh +pool-phh A +63.92 B +64.16 B-A +0.24 ± 0.16 (2000 Deals x 8) besser +Mittel B-A +0.24 ± 0.16 +===== echthart +pool-nl2-echt A +60.50 B +61.12 B-A +0.62 ± 0.27 (2000 Deals x 8) besser +Mittel B-A +0.62 ± 0.27 +===== lbr blind (an - aus, Ausbeutung durch LBR; kleiner = besser) +0.00 ± 0.00 n 2000 bitgleich +===== sechs (6-max gemischt) +Mittel B-A +0.03 ± 0.03 +``` diff --git a/src/bin/probe_cbet.rs b/src/bin/probe_cbet.rs new file mode 100644 index 00000000..1c843b04 --- /dev/null +++ b/src/bin/probe_cbet.rs @@ -0,0 +1,125 @@ +//! Probe (c-bet analysis, 17.11.): how often hero c-bets as the preflop aggressor heads-up on the flop, +//! with which hands and sizes, and how often the simulated villain folds to it, per bet size. The live +//! numbers to compare against (2651+ NL2 hands since 14.11.): hero c-bets 31 % heads-up, the pool folds +//! 33 % to a bet under 0.4 pot and 47 % to 0.6..0.8 pot. +//! +//! Run: `probe_cbet [deals=2000]`, rows `PROBE_ROWS` (default `pool-nl2-echt,pool-phh,reg,nit`), pool rows +//! need `POOL_PERSONA` (a row `pool-x=` names its own persona). Track switches from the environment +//! (`sim::arm_env`). Threads from `POKERBENCH_THREADS` (default 2). +use rechner::game::{Choice, SeenAction, Street}; +use rechner::rng::Rng; +use rechner::sim::opponent::Opponent; +use rechner::sim::reader::Style; +use rechner::sim::session::{deal_trace_memory, ReadMode, Setup}; +use rechner::sim::welt::Persona; +use std::sync::Mutex; + +const KLASSIK_SEED: u64 = 0x5EED_0001; +const POOL_DRAW_SEED: u64 = 0x9001_D2A9_0000; +const POOL_SEED: u64 = 0x9001_5EED; + +fn row(name: &str) -> Option<(Opponent, u64)> { + let k = KLASSIK_SEED; + Some(match name { + "reg" => (Opponent::Reader(Style::Reg), k), + "nit" => (Opponent::Reader(Style::Nit), k), + "maniac" => (Opponent::Reader(Style::Maniac), k), + "gto" => (Opponent::Reader(Style::Gto), k), + "station" => (Opponent::CallingStation, k), + n if n.starts_with("pool-") => { + let (_, file) = n.split_once('=').map_or((n, None), |(a, b)| (a, Some(b.to_string()))); + let path = file.or_else(|| std::env::var("POOL_PERSONA").ok())?; + let text = std::fs::read_to_string(path).ok()?; + let m = Persona::from_pool_json(&text).ok()?; + (Opponent::Welt(Persona::draw_pool(m, Rng::seeded(POOL_DRAW_SEED)).0), POOL_SEED ^ 0x9E37_79B9) + } + _ => return None, + }) +} + +fn bucket(ratio: f64) -> usize { + if ratio < 0.4 { + 0 + } else if ratio < 0.6 { + 1 + } else { + 2 + } +} + +fn main() { + rechner::sim::arm_env::apply_env(); + let deals: u32 = std::env::args().nth(1).and_then(|x| x.parse().ok()).unwrap_or(2000); + let threads: usize = std::env::var("POKERBENCH_THREADS").ok().and_then(|x| x.parse().ok()).unwrap_or(2).max(1); + let rows: Vec = std::env::var("PROBE_ROWS") + .unwrap_or_else(|_| "pool-nl2-echt,pool-phh,reg,nit".into()) + .split(',') + .map(|s| s.trim().to_string()) + .collect(); + let out = Mutex::new(Vec::new()); + let next = std::sync::atomic::AtomicUsize::new(0); + std::thread::scope(|sc| { + for _ in 0..threads.min(rows.len()) { + sc.spawn(|| { + rechner::sim::arm_env::apply_env(); + loop { + let j = next.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let Some(name) = rows.get(j) else { break }; + let Some((opp, seed)) = row(name) else { + out.lock().unwrap().push(format!("{name:14} unbekannt")); + continue; + }; + let setup = Setup { players: 2, opponent: opp, deals, stack_bb: 100.0, seed, read: ReadMode::Memory }; + // chances, bets, air chances, air bets, [bucket][bets, folds], net bb of the chance hands + let (mut chances, mut bets, mut air, mut air_bets) = (0u32, 0u32, 0u32, 0u32); + let mut by = [[0u32; 2]; 3]; + let mut net = [0.0f64; 2]; + deal_trace_memory(&setup, |_, _, _, result, trace| { + let Some((k, d)) = trace.iter().enumerate().find(|(_, d)| { + d.street == Street::Flop + && d.to_call == 0.0 + && rechner::game::line::cbet_spot(&d.spot.history, d.spot.hero_seat, Street::Flop) + }) else { + return; + }; + chances += 1; + let is_air = d.reason.starts_with("air") || d.reason.starts_with("board only"); + air += is_air as u32; + let Choice::Raise { to } = d.choice else { + net[0] += result.hero_net; + return; + }; + bets += 1; + air_bets += is_air as u32; + net[1] += result.hero_net; + let b = bucket(to / d.pot.max(1e-9)); + by[b][0] += 1; + // Folded: no later hero decision and the villain's flop answer is not on record. + let hero = d.spot.hero_seat; + let answered = trace[k + 1..].iter().any(|n| { + n.spot.history.iter().any(|r| r.street == Street::Flop && r.seat != hero && r.seat != 0 && r.action != SeenAction::Check) + || n.street != Street::Flop + }); + by[b][1] += (!answered) as u32; + }); + let q = |a: u32, b: u32| a as f64 / b.max(1) as f64; + let mut line = format!( + "{name:14} chancen {chances} cbet {:.2} luft {:.2} luft-cbet {:.2} | netto/chance check {:+.2} bet {:+.2} bb", + q(bets, chances), + q(air, chances), + q(air_bets, air), + net[0] / (chances - bets).max(1) as f64, + net[1] / bets.max(1) as f64 + ); + for (i, label) in ["<0.4", "0.4-0.6", ">=0.6"].iter().enumerate() { + line += &format!(" | {label} n {} fold {:.2}", by[i][0], q(by[i][1], by[i][0])); + } + out.lock().unwrap().push(line); + } + }); + } + }); + for l in out.into_inner().unwrap() { + println!("{l}"); + } +} diff --git a/src/engine/cbet_luft.rs b/src/engine/cbet_luft.rs new file mode 100644 index 00000000..300353ba --- /dev/null +++ b/src/engine/cbet_luft.rs @@ -0,0 +1,120 @@ +//! C-bet and stab with air (`CBET_LUFT`, off by default; live analysis 17.11.). +//! +//! Live (NL2, 5386 hands since 14.11.): as the preflop aggressor heads-up, hero c-bets 31 % and air +//! almost never. The cause is structural. A pure bluff needs `P(fold) >= PURE_BLUFF_MIN_FOLD` (0.45), +//! but its size band (`size_policy::BLUFF_BAND`, 33-50 % pot, flop x 0.8) only allows 0.26-0.40 pot, +//! where the fold model gives about 0.28 (base 0.45, `fold_chance::sized_fold`). So a flop bluff +//! passes only against a read folder. The real pool folds 33 % to our bets under 0.4 pot and 47 % to +//! 0.6-0.8 pot heads-up; the model (0.28 / 0.45) is right, and so is the EV: an air c-bet at 2/3 pot +//! wins `0.47 pot` uncalled against a check that realises about `0.2 pot`. +//! +//! The switch lifts that gate where it is a c-bet or a stab: hero bets first heads-up with nothing in +//! front, on the flop as the preflop aggressor, and with `turn` also on the turn after a flop checked +//! through. There a pure bluff needs only `min_fold` (and still its EV edge over checking, +//! `PURE_BLUFF_EDGE`), and with `gross` it may use the value sizes, so the EV picks the size. +//! +//! `beleg`: only as far as the counted read shows a villain who rarely raises against bets +//! (`glaube::evidence_weight` on the ungated `raise_to_bet`, full at 0,25, none at the anchor 0,30 or +//! without a read; needs `POSTERIOR=bluff`, which keeps the ungated profile). The least fold chance +//! slides from `PURE_BLUFF_MIN_FOLD` to `min_fold` with that weight, the value sizes need a weight +//! above 0. Gate 17.11. without it: nemesis-2 (light raiser) −1,64 on the ladder, −3,26 @blind. +//! +//! `CBET_LUFT=`, comma separated: `flop` (on), `turn` (also the turn stab), `min:` (least +//! fold chance, default `MIN_FOLD_DEFAULT`), `gross` (value sizes allowed), `beleg` (see above). +//! Anything unparsable: off. + +use crate::game::{line, Spot, Street}; +use std::cell::Cell; + +/// Least P(fold) of a c-bet/stab bluff when the switch names none. +pub const MIN_FOLD_DEFAULT: f64 = 0.30; + +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Mode { + pub turn: bool, + pub min_fold: f64, + pub wide: bool, + pub evidence: bool, +} + +thread_local! { + static OVERRIDE: Cell>> = const { Cell::new(None) }; +} + +pub fn parse(s: &str) -> Option { + let mut m = Mode { turn: false, min_fold: MIN_FOLD_DEFAULT, wide: false, evidence: false }; + let mut on = false; + for t in s.split(',').map(str::trim).filter(|t| !t.is_empty()) { + match t { + "flop" | "1" => on = true, + "turn" => { + on = true; + m.turn = true; + } + "gross" => m.wide = true, + "beleg" => m.evidence = true, + _ => { + let x = t.strip_prefix("min:")?.parse::().ok().filter(|x| (0.0..=1.0).contains(x))?; + m.min_fold = x; + } + } + } + on.then_some(m) +} + +/// The switch, `None` when off. +pub fn mode() -> Option { + use std::sync::OnceLock; + static MODE: OnceLock> = OnceLock::new(); + OVERRIDE.with(|o| o.get()).unwrap_or_else(|| *MODE.get_or_init(|| std::env::var("CBET_LUFT").ok().and_then(|s| parse(&s)))) +} + +/// Force the switch for this thread (`Some(None)` = off), `None` = back to the environment. +pub fn set_override(mode: Option>) { + OVERRIDE.with(|o| o.set(mode)); +} + +/// The switch when this spot is a c-bet or stab it covers: heads-up, nothing to call, and on the flop +/// hero is the preflop aggressor with no flop bet yet, on the turn (`turn`) nobody bet the flop or +/// the turn yet. +pub fn applies(spot: &Spot) -> Option { + let m = mode()?; + if spot.to_call > 0.0 || spot.live_villains().count() != 1 { + return None; + } + let quiet = |s: Street| !spot.history.iter().any(|r| r.street == s && r.action.is_aggressive()); + let hit = match spot.street { + Street::Flop => line::cbet_spot(&spot.history, spot.hero_seat, Street::Flop), + Street::Turn => m.turn && quiet(Street::Flop) && quiet(Street::Turn), + _ => false, + }; + if !hit { + return None; + } + if !m.evidence { + return Some(m); + } + let seat = spot.live_villains().next()?.seat; + let w = super::glaube::raw_profile(seat).as_ref().map_or(0.0, super::glaube::evidence_weight); + (w > 0.0).then(|| { + let top = super::bluff::PURE_BLUFF_MIN_FOLD; + Mode { min_fold: top - w * (top - m.min_fold.min(top)), ..m } + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_the_tokens() { + assert_eq!(parse("flop"), Some(Mode { turn: false, min_fold: 0.30, wide: false, evidence: false })); + assert_eq!(parse("flop,turn,min:0.35,gross"), Some(Mode { turn: true, min_fold: 0.35, wide: true, evidence: false })); + assert_eq!(parse("turn"), Some(Mode { turn: true, min_fold: 0.30, wide: false, evidence: false })); + assert_eq!(parse("flop,gross,beleg").map(|m| m.evidence), Some(true)); + assert_eq!(parse("gross"), None); + assert_eq!(parse("flop,min:x"), None); + assert_eq!(parse("0"), None); + assert_eq!(parse(""), None); + } +} diff --git a/src/engine/glaube.rs b/src/engine/glaube.rs index 12422d33..84495dde 100644 --- a/src/engine/glaube.rs +++ b/src/engine/glaube.rs @@ -94,6 +94,11 @@ pub fn note_raw(raw: &Spot) { RAW.with(|x| *x.borrow_mut() = kept); } +/// The ungated profile of `seat` kept by `note_raw` for the current decision (only under S2). +pub fn raw_profile(seat: u8) -> Option { + RAW.with(|x| x.borrow().iter().find(|(s, _)| *s == seat).map(|(_, p)| *p)) +} + /// `POSTERIOR=fold` or `fold:` (comma list of stages; unknown stages are ignored). Else off. pub fn mode() -> Option { use std::sync::OnceLock; diff --git a/src/engine/mod.rs b/src/engine/mod.rs index 9e720791..761a7666 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -6,6 +6,7 @@ pub mod audit_turn; pub mod bluff; pub mod called; pub mod called_equity; +pub mod cbet_luft; pub mod decide; pub mod double_board; pub mod effective; diff --git a/src/engine/options.rs b/src/engine/options.rs index 2a1c5900..2d47a36d 100644 --- a/src/engine/options.rs +++ b/src/engine/options.rs @@ -312,7 +312,7 @@ pub fn scored( RaiseKind::Value | RaiseKind::ThinValue => true, RaiseKind::Semibluff => b.fold > 0.0 && b.total > 0.0 && b.total > floor, RaiseKind::Bluff => { - fe >= PURE_BLUFF_MIN_FOLD + fe >= super::cbet_luft::applies(spot).map_or(PURE_BLUFF_MIN_FOLD, |m| m.min_fold.min(PURE_BLUFF_MIN_FOLD)) && b.total > 0.0 && b.total >= floor + PURE_BLUFF_EDGE * crate::rake::live::net(spot.pot) } diff --git a/src/engine/size_policy.rs b/src/engine/size_policy.rs index b8c5c1c7..dd9e1584 100644 --- a/src/engine/size_policy.rs +++ b/src/engine/size_policy.rs @@ -118,6 +118,8 @@ fn band(spot: &Spot, kind: RaiseKind, share: f64, read: &HandRead) -> (f64, f64) && spot.live_villains().any(|v| v.profile.is_some_and(|p| p.fold_only)); let base = match kind { RaiseKind::Semibluff | RaiseKind::Bluff if fold_read => (BLUFF_BAND.0, VALUE_BAND.1), + // CBET_LUFT=..,gross: a c-bet/stab bluff may take the value sizes, the EV picks. + RaiseKind::Bluff if super::cbet_luft::applies(spot).is_some_and(|m| m.wide) => (BLUFF_BAND.0, VALUE_BAND.1), RaiseKind::Semibluff | RaiseKind::Bluff | RaiseKind::ThinValue => BLUFF_BAND, RaiseKind::Value if t == Tier::Medium => BLUFF_BAND, RaiseKind::Value if t == Tier::Monster && late && share >= NUT_SHARE => NUT_BAND,