Files
pokerfreak/src/engine/decide.rs
T
mmintelandClaude Opus 4.8 1492fb6a38 Synthetik-Labor: Population, Zwillings-Tor, adaptive Liga, Optimizer, Sim-to-Real
Ersetzt die irrefuehrende Oracle-Leiter durch eine ehrliche Messmethodik
(Oracle aus, Read via Memory/Posterior gegen eine gezogene Gegner-Population).

Stufen:
- 0 Exploitation-Luecke: +18.98 bb/100 gegen die gezogene Population
- 1 Kalibrierung an echte HUD-Daten (lesen/kalibrierung.py)
- 2 Zwillings-Tor (EGTA + Exploitability-Waechter): Offense +43.95,
  Boden gto -36.25 (verliert gegen Balancierte - die Oracle-verdeckte Wurzel)
- 3 Adaptive Liga L0-L3 (reaktiv / modellierend / Liga)
- 4 Sim-to-Real: HUD-Gap (sim::simreal) + Outcome-Abgleich (lesen/liveabgleich.py):
  real -266.75 vs Sim +43.95 => Gap -311; A/B-Pipeline + Runbook fertig,
  nur der geldechte Live-Lauf unter beiden Armen bleibt offen
- 5 Optimizer (Diagonal-CMA-ES, parallel): Nemesis -414.81 bb/100

Befunde und Architektur in docs/notizen/. Lab-Tests gruen
(Rust lib 92/0, python liveabgleich/kalibrierung/gegnersignal gruen).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-11 09:57:32 +01:00

140 lines
6.6 KiB
Rust

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, Spot, Street};
use crate::guard::enforce::enforce;
use crate::icm::lage::Turnierlage;
use crate::icm::risk::{call_premium, jam_pressure, jam_width_factor, width_factor};
use crate::preflop::advise::advise_widened;
use crate::preflop::plan::PreflopPlan;
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) -> 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<HandFilter> = 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<Card> = 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<VillainRange> = 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);
crate::exploit::mdf_floor::floor(raw, hand_read.made, base).with_equity(equity.share)
}
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
}
}
fn think(spot: &Spot, premium: f64, jam_widen: f64, raw: &Spot) -> Decision {
let profiles: Vec<Profile> = spot.live_villains().filter_map(|v| v.profile).collect();
let thresholds = with_premium(adjust(Thresholds::BASE, &profiles), premium);
match spot.street {
Street::Preflop => {
let plan = advise_widened(spot, &thresholds, jam_widen);
// 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),
}
}
/// 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 {
// 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);
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.
let jam_widen = lage.and_then(|l| jam_pressure(spot, l)).map(jam_width_factor).unwrap_or(1.0);
let decision = enforce(spot, think(spot, premium, jam_widen, raw));
match crate::hand::showdown::best(spot.rules().hole_usage, &spot.hero_cards, &spot.board) {
Ok(strength) => decision.with_category(strength.category),
Err(_) => decision,
}
}