use super::called_equity::called_equity; use super::from_plan::{from_plan, MIN_CERTAINTY}; use super::passive::cheapest_continue; use super::postflop::choose_postflop_with; use super::range_combos::{as_ranges, combos}; use super::range_filter::{range_filter, HandFilter}; use crate::card::Card; use crate::equity::monte_carlo::estimate; use crate::equity::query::Query; use crate::equity::villain_range::VillainRange; use crate::exploit::adjust::adjust; use crate::exploit::profile::Profile; use crate::exploit::range_model::range_spec; use crate::exploit::thresholds::Thresholds; use crate::game::{Decision, SeenAction, Spot, Street}; use crate::guard::enforce::enforce; use crate::icm::lage::Turnierlage; use crate::icm::push_fold::push_fold; use crate::icm::risk::{call_premium, jam_depth_gate, jam_pressure, jam_width_factor, width_factor}; use crate::preflop::advise::{advise_widened_read, scale_for}; use crate::preflop::certainty::certainty; use crate::preflop::exploit_border::exploit_border; use crate::preflop::hand_percentile::percentile; use crate::preflop::plan::{ChartAction, PreflopPlan}; use crate::preflop::situation_of::situation_of; use crate::read::hand_read::read; use crate::rng::Rng; const TRIALS_TWO_CARD: u32 = 3000; const TRIALS_OMAHA: u32 = 1500; fn trials(spot: &Spot) -> u32 { if spot.rules().hole_cards >= 4 { TRIALS_OMAHA } else { TRIALS_TWO_CARD } } /// Postflop: read the hand, model each villain's range, simulate against it and /// against the hands that would call each raise, choose. fn postflop(spot: &Spot, thresholds: &Thresholds, raw: &Spot, premium: f64) -> Decision { let rules = spot.rules(); let hand_read = match read(&rules, &spot.hero_cards, &spot.board) { Ok(r) => r, Err(fault) => return Decision::abstain(format!("hand read unavailable: {fault}")), }; let filters: Vec = spot .live_villains() .map(|v| range_filter(&range_spec(spot, v), rules, spot.variant, &spot.board)) .collect(); if filters.is_empty() { return cheapest_continue(spot).map_or_else( || Decision::abstain("no live opponent and nothing to continue with"), |choice| Decision::new(choice, 0.5, "no live opponents: cheapest continuing action"), ); } let dead: Vec = spot.hero_cards.iter().chain(&spot.board).copied().collect(); let lists: Vec<_> = filters.iter().map(|f| combos(&rules, f, &dead)).collect(); // Stage A river-subgame solver is NOT wired here. Proven exactly unexploitable (0.0 bb/100) vs a // correct GTO belief in `sim::exploit_river`, but with a SYMMETRIC prior it plays balanced poker // against players who must be exploited: wiring it live cost -43 bb/100 GESAMT, concentrated on // the calling station / fish / maniac (BEFUND-river-solver-balanced-vs-exploitable). It returns // to the live path only once the belief is opponent-aware (posterior -> range) and trust-gated // (crown: KL ball around GTO, lambda from read confidence). Until then the heuristic EV line below // keeps the exploit edge the whole ladder depends on. let ranges: Vec = as_ranges(&filters, &lists); let query = Query { rules, hero: &spot.hero_cards, board: &spot.board, villains: &ranges, trials: trials(spot), }; match estimate(&query, Rng::seeded(spot.seed)) { Ok((equity, _)) => { // GTO-Boden UEBER dem Modell, aber unter der Exploit-Range: ein modellgetriebener // River-Fold einer verteidigungswuerdigen Made-Hand wird zum MDF-Call. `raw` traegt die // UNGEGATETEN Reads - der Boden darf den Gegner-Bluffanteil defensiv lesen (gegen einen // bewiesenen Nicht-Bluffer mehr folden), was `read_gate` dem Range-Modell verwehrt. let base = choose_postflop_with(spot, &equity, &called_equity(spot), thresholds, &hand_read); let floored = crate::exploit::mdf_floor::floor(raw, hand_read.made, base).with_equity(equity.share); // Defensive river veto (the belief+trust gearbox, CASH ONLY): a confident read that the // villain UNDER-bluffs its river bet turns a heuristic call into a fold. This is the one // place the gearbox is a proven edge — the heuristic over-calls under-bluffed overbets // (nemesis-3); its OFFENSE (thin value, light calls vs real bluffers) stays untouched, // because replacing that with a KL-GTO line bled EV on the ladder. Never overrides an // ICM-driven line (premium > 0): chip-EV must not override a tournament fold/call. // // The TURN veto (`turn_subgame::turn_fold_veto`, Stage B) stays OUT of the live path. Two // measurements now agree it regresses the hardest value-heavy nemesis (nemesis-1, bluff // 0.068): pooled belief -7.77, per-street-aggression belief -25.93 (worse). The root is NOT // belief granularity — per-street aggression fixed nemesis-2 but made nemesis-1 worse. It is // the draw-BLIND turn bucket: the veto folds bluff-catchers whose river equity the // current-strength ladder undervalues, so a defensive turn fold forfeits realized equity the // river veto never does (the river is final). Fixing it needs draw-aware turn bucketing or // the offline/value-function form, not a live fold-veto. The turn solver + per-street belief // stay as tested primitives. See BEFUND-stage-b-turn-river-solver.md. if premium <= 0.0 { // Arm (off by default, RIVER_DBR): the data-biased robust counter-strategy plays the // heads-up river whenever the read is strong enough (`river_subgame::dbr_decision`). if let Some(d) = super::river_subgame::dbr_decision(raw) { return d.with_equity(equity.share); } // Stage A, solver everywhere (off by default, SOLVER_RIVER): the heads-up river decided // by an equilibrium solve over real combos, ranges from the line (`engine::river_spieler`). if let Some(d) = super::river_spieler::river_spieler_decision(raw) { return d.with_equity(equity.share); } // Multiway river (off by default, SOLVER_RIVER3): 3- and 4-handed rivers decided by // Monte-Carlo CFR over real combos (`engine::river3_spieler`). if let Some(d) = super::river3_spieler::river3_decision(raw) { return d.with_equity(equity.share); } // Arm (off by default, TURN_SPIEL=grund): the turn+river game with ranges from the // blueprint (`engine::turn_game`); `None` while the switch is off. Stage B supersedes it // when on (same game, blueprint ranges where recognised, hero's hand always kept, inside // the turn deadline): E3 first would spend the deadline and then hand pruned hands to the // heuristic. let e3 = if super::turn_game::turn_ueberall() { None } else { super::turn_game::turn_game_decision(raw) }; if let Some(d) = e3 { return d.with_equity(equity.share); } // Stage B, solver everywhere (off by default, SOLVER_TURN): every heads-up turn. if let Some(d) = super::turn_game::turn_solver_decision(raw) { return d.with_equity(equity.share); } // Multiway turn and flop (off by default, SOLVER_TURN3 / SOLVER_FLOP3): 3- and 4-handed // spots decided by Monte-Carlo CFR over the remaining streets (`engine::multi3_spieler`). if let Some(d) = super::multi3_spieler::multi3_decision(raw) { return d.with_equity(equity.share); } // Stage C, solver everywhere (off by default, SOLVER_FLOP): every heads-up flop. if let Some(d) = super::flop_spieler::flop_spieler_decision(raw) { return d.with_equity(equity.share); } // Bounded exploitation of the non-station reads (`read_exploit`, switch GEGNER_BREIT, off). return super::read_exploit::postflop(raw, &hand_read, super::river_subgame::fold_veto(raw, floored)); } floored } Err(fault) => Decision::abstain(format!("equity unavailable: {fault}")), } } /// Thresholds with the tournament risk premium (`icm::risk`) added: calls need more equity, /// the preflop width narrows. No premium: unchanged. fn with_premium(thresholds: Thresholds, premium: f64) -> Thresholds { if premium <= 0.0 { return thresholds; } Thresholds { call_margin: thresholds.call_margin + premium, range_width_scale: thresholds.range_width_scale * width_factor(premium), ..thresholds } } /// Tournament short stack (`icm::push_fold`): the jam/call-or-fold answer of the ICM push/fold /// equilibrium, its border moved only by the EXPLOIT width (`scale_for` on the thresholds WITHOUT the /// ICM premium - the premium is already inside the prize-money terminals, counting it twice would /// over-tighten). `None` where the jam game does not model the spot: the chip chart path stays. fn icm_push_fold_plan(spot: &Spot, lage: &Turnierlage, exploit: &Thresholds) -> Option { let answer = push_fold(spot, lage)?; let hand = percentile(spot.variant, &spot.hero_cards); let scale = scale_for(spot, situation_of(spot), exploit, None); let (aggressive, verb) = if answer.facing_jam { (ChartAction::Call, "call") } else { (ChartAction::Jam, "jam") }; let equilibrium = if answer.continue_ { aggressive } else { ChartAction::Fold }; let action = exploit_border(equilibrium, aggressive, hand, answer.width, scale); let said = if action == ChartAction::Fold { "fold" } else { verb }; let moved = if action == equilibrium { String::new() } else { format!(", exploit width {scale:.2} -> {said}") }; Some(PreflopPlan { action, percentile: hand, certainty: certainty(hand, &[answer.width * scale]), reason: format!( "ICM push/fold {:.1}bb vs {} {}: {} (equilibrium {verb}s {:.0}%, ICM edge {:+.4}){moved}", answer.depth_bb, answer.callers, if answer.callers == 1 { "caller" } else { "callers" }, if answer.continue_ { verb } else { "fold" }, 100.0 * answer.width, answer.edge, ), }) } /// Hero acts first in (no raise yet): the open-jam half of the push/fold game. fn first_in(spot: &Spot) -> bool { !spot.history.iter().any(|r| { r.street == Street::Preflop && matches!(r.action, SeenAction::Raise | SeenAction::AllIn | SeenAction::Bet) }) } fn think(spot: &Spot, premium: f64, jam_widen: f64, raw: &Spot, lage: Option<&Turnierlage>) -> Decision { let profiles: Vec = spot.live_villains().filter_map(|v| v.profile).collect(); let exploit = adjust(Thresholds::BASE, &profiles); let thresholds = with_premium(exploit, premium); match spot.street { Street::Preflop => { // Bounded light 3-bet vs openers the gate plays blind (`read_exploit`, switch GEGNER_BREIT); // cash only: with an ICM premium the raw read stays out. let read = (premium <= 0.0).then_some(raw); let chip = advise_widened_read(spot, read, &thresholds, jam_widen); // First-in WEITET der Push/Fold-Solver den Chip-Plan nur (Fold -> Jam), er engt ihn nie ein: // sein Gleichgewicht unterstellt einen Caller, der ICM-genau breit callt; ein echter Gegner // callt nach Chip-Staerke enger (Leiter covered-reg: Solver-Fold statt Chip-Jam -9.1 +-7.0 // je 100). Eroeffnet der Chip-Pfad kleiner (Raise/Limp), bleibt sein reicheres Spiel. Gegen // einen Jam (Call/Fold) gilt der Solver ganz: dort zaehlt das eigene Bust-Risiko. let plan = match lage.and_then(|l| icm_push_fold_plan(spot, l, &exploit)) { Some(icm) if first_in(spot) && !(icm.action == ChartAction::Jam && chip.action == ChartAction::Fold) => chip, Some(icm) => icm, None => chip, }; // Eine Grenzhand folgt ihrer Seite der Tabelle (Raise bleibt Raise, Call bleibt Call): // nahe der Grenze ist jede Linie fast gleich viel wert, Aussetzen ist die schlechteste. let certainty = plan.certainty.max(MIN_CERTAINTY); from_plan(spot, &PreflopPlan { certainty, ..plan }) } Street::Flop | Street::Turn | Street::River => postflop(spot, &thresholds, raw, premium), } } /// Full decision for a validated spot (preflop chart or postflop read/equity/EV), /// always passed through `guard::enforce::enforce`. Die Handkategorie wird nur /// zur Nachprüfung angehängt. pub fn decide(spot: &Spot) -> Decision { decide_with(spot, None) } /// `decide` with an optional tournament situation (`icm`). Without one: cash. With one /// that cannot be priced: ABSTAIN. pub fn decide_with(spot: &Spot, lage: Option<&Turnierlage>) -> Decision { // RAKE_LIVE (`rake::live`, off by default): a cash spot prices every pot net of the room's rake; // a tournament pays none, also a chip-linear one that plays the cash path below // (the scope is decided on the original situation). Off: no scope, nothing changes. let _rake = match lage { None => crate::rake::live::cash_scope(spot.big_blind), Some(_) => crate::rake::live::enabled().then(crate::rake::live::Scope::none), }; // Chip-lineares Geld (der Sieger nimmt alles, alle Verbliebenen gleich bezahlt, p1 > p2 = ... = pn): // ICM IST Chip-EV, also genau der Cash-Pfad. Eine unbepreisbare Lage bleibt ein Aussetzen. let lage = lage.filter(|l| !(l.is_usable() && l.is_chip_linear())); super::frist::begin(); // Only act on reads we are proven to beat blind play with (`read_gate`); competent and // aggressive opponents are played blind until the exploit logic earns them on the ladder. let gated = super::read_gate::gate_reads(spot); crate::exploit::street_continuation::note_raw_reads(spot); let raw = spot; // ungated reads, used ONLY by the defensive MDF floor (mdf_floor::floor) let spot = &gated; let premium = match lage.map(|l| call_premium(spot, l)) { None => 0.0, Some(Some(p)) => p, Some(None) => return Decision::abstain("tournament situation unusable: no money EV"), }; // Open-Jam-Weitung an der Bubble (`icm::risk::jam_pressure`): nur bei Turnierlage, sonst neutral. // Unpricebar -> 1.0 (keine Weitung), nie ein Abbruch - der Riegel liegt bei `premium`/Calls. // Tiefen-gegated (`jam_depth_gate`): die Weitung ist ein Kurzstack-Hebel; ein tiefer Deckler // weitet NICHT (sonst oeffnet er Muell aus der Tiefe - gemessen: cover-short -12.5 ICM$/100). let jam_widen = lage .and_then(|l| jam_pressure(spot, l)) .map(jam_width_factor) .map(|w| 1.0 + (w - 1.0) * jam_depth_gate(spot.hero_stack / spot.big_blind)) .unwrap_or(1.0); let decision = enforce(spot, think(spot, premium, jam_widen, raw, lage)); // Measurement only (GEGNER_BREIT_DIAG): why the reading layer left this decision blind. let decision = if super::read_exploit::diag_on() { let why = super::read_exploit::diagnose(raw, &decision, premium); Decision { reason: format!("{} | {why}", decision.reason), ..decision } } else { decision }; match crate::hand::showdown::best(spot.rules().hole_usage, &spot.hero_cards, &spot.board) { Ok(strength) => decision.with_category(strength.category), Err(_) => decision, } }