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>
123 lines
5.0 KiB
Rust
123 lines
5.0 KiB
Rust
//! Stufe 0 of the synthetic lab: the EXPLOITATION GAP.
|
|
//!
|
|
//! Draw opponents from a `Population`, play the engine heads-up against each with NO oracle read
|
|
//! (`Opponent::Styled` has no authored profile), once blind and once with session memory. In memory
|
|
//! mode the engine must INFER the opponent from its observed actions (`sim::memory` →
|
|
//! `exploit::posterior`); blind mode is the same engine with nothing to read. The per-deal paired
|
|
//! difference `memory - blind`, over the SAME deals (card luck cancels) and pooled over the whole
|
|
//! field, is the bb/100 the engine's inference earns against a realistic population.
|
|
//!
|
|
//! On the fixed-bot ladder this number is structurally hidden: there the engine is handed the
|
|
//! converged oracle read (`sim::reads`), so there is nothing to infer and no exploitation to show.
|
|
//! Here the oracle is withheld by construction, so the gap is the real exploitation signal.
|
|
//!
|
|
//! The pooled paired CI reuses `sim::paired::compare`; an anytime CI from `sim::sequential` is
|
|
//! reported alongside — the first run of that confidence sequence on real (heavy-tailed) poker
|
|
//! samples instead of synthetic Gaussian ones.
|
|
|
|
use super::paired::compare;
|
|
use super::population::Population;
|
|
use super::sequential::ConfSeq;
|
|
use super::session::{deal_samples, ReadMode, Setup};
|
|
use crate::rng::Rng;
|
|
use std::collections::BTreeMap;
|
|
use std::thread;
|
|
|
|
const STACK_BB: f64 = 100.0;
|
|
const PLAYERS: u8 = 2;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct GapReport {
|
|
pub opponents: usize,
|
|
pub deals_each: u32,
|
|
/// Engine win rate against the field with no read.
|
|
pub blind_bb_per_100: f64,
|
|
/// Engine win rate against the field inferring from session memory.
|
|
pub memory_bb_per_100: f64,
|
|
/// memory - blind, pooled over all (opponent, deal) pairs.
|
|
pub gap_bb_per_100: f64,
|
|
/// Paired 95 % half width of the gap (`sim::paired`).
|
|
pub ci95: f64,
|
|
/// Anytime 95 % half width of the gap (`sim::sequential`) — valid under peeking; sanity cross-check.
|
|
pub anytime_ci95: f64,
|
|
/// Per hidden archetype: mean per-opponent gap and how many opponents.
|
|
pub by_label: BTreeMap<String, (f64, usize)>,
|
|
}
|
|
|
|
struct One {
|
|
label: &'static str,
|
|
blind: Vec<f64>,
|
|
memory: Vec<f64>,
|
|
}
|
|
|
|
fn run_one(pop: &Population, k: usize, deals: u32, seed: u64) -> One {
|
|
let (draw, _) = pop.sample(Rng::seeded(seed ^ (k as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15)));
|
|
let hand_seed = seed ^ (k as u64).wrapping_mul(0xD1B5_4A32_D192_ED03);
|
|
let blind = Setup {
|
|
players: PLAYERS,
|
|
opponent: draw.opponent(),
|
|
deals,
|
|
stack_bb: STACK_BB,
|
|
seed: hand_seed,
|
|
read: ReadMode::Blind,
|
|
};
|
|
let memory = Setup { read: ReadMode::Memory, ..blind };
|
|
One { label: draw.label, blind: deal_samples(&blind).0, memory: deal_samples(&memory).0 }
|
|
}
|
|
|
|
/// Measure the exploitation gap over `opponents` draws, `deals` deals each. Deterministic in `seed`.
|
|
pub fn exploitation_gap(pop: &Population, opponents: usize, deals: u32, seed: u64) -> GapReport {
|
|
let results: Vec<One> = thread::scope(|scope| {
|
|
let handles: Vec<_> =
|
|
(0..opponents).map(|k| scope.spawn(move || run_one(pop, k, deals, seed))).collect();
|
|
handles.into_iter().map(|h| h.join().expect("an opponent panicked")).collect()
|
|
});
|
|
|
|
let mut blind_all = Vec::new();
|
|
let mut mem_all = Vec::new();
|
|
let mut cs = ConfSeq::new(0.05, (opponents as u64 * deals as u64).max(1));
|
|
let mut by_label: BTreeMap<String, (f64, usize)> = BTreeMap::new();
|
|
for one in &results {
|
|
let g = 100.0 * (one.memory.iter().sum::<f64>() - one.blind.iter().sum::<f64>())
|
|
/ deals.max(1) as f64;
|
|
let e = by_label.entry(one.label.to_string()).or_insert((0.0, 0));
|
|
e.0 += g;
|
|
e.1 += 1;
|
|
for (b, m) in one.blind.iter().zip(&one.memory) {
|
|
blind_all.push(*b);
|
|
mem_all.push(*m);
|
|
cs.push(m - b);
|
|
}
|
|
}
|
|
let cmp = compare(&blind_all, &mem_all).expect("non-empty paired diffs");
|
|
let mean = |v: &[f64]| 100.0 * v.iter().sum::<f64>() / v.len().max(1) as f64;
|
|
GapReport {
|
|
opponents,
|
|
deals_each: deals,
|
|
blind_bb_per_100: mean(&blind_all),
|
|
memory_bb_per_100: mean(&mem_all),
|
|
gap_bb_per_100: cmp.delta_bb_per_100,
|
|
ci95: cmp.ci95,
|
|
anytime_ci95: 100.0 * cs.radius(),
|
|
by_label,
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn gap_runs_and_is_finite() {
|
|
// Tiny: this exercises the full engine decision path, so keep it small for `cargo test`.
|
|
let pop = Population::micro();
|
|
let r = exploitation_gap(&pop, 4, 25, 0x5EED_0001);
|
|
println!(
|
|
"blind {:+.1} memory {:+.1} gap {:+.2} +-{:.2} (anytime +-{:.2}) by {:?}",
|
|
r.blind_bb_per_100, r.memory_bb_per_100, r.gap_bb_per_100, r.ci95, r.anytime_ci95, r.by_label
|
|
);
|
|
assert!(r.gap_bb_per_100.is_finite() && r.ci95.is_finite());
|
|
assert_eq!(r.by_label.values().map(|(_, n)| n).sum::<usize>(), 4);
|
|
}
|
|
}
|