73 lines
2.7 KiB
Rust
73 lines
2.7 KiB
Rust
//! Sanity: exploiter vs the exact push/fold equilibrium (~0) and vs a perturbed copy (large).
|
|
|
|
use bench::bp::CoarseBucketer;
|
|
use exploit::abr::{AbrConfig, Exploiter, Extract};
|
|
use exploit::eval::evaluate;
|
|
use exploit::game::{ActionSpace, PushFold};
|
|
use exploit::pushfold::{self, Matrix};
|
|
use std::sync::Arc;
|
|
use std::time::Instant;
|
|
|
|
fn train_and_eval(
|
|
strat: pushfold::Strategy,
|
|
name: &str,
|
|
stack: i32,
|
|
iters: u64,
|
|
deals: u64,
|
|
) -> (f64, f64) {
|
|
let target = pushfold::arc(name, strat);
|
|
let cfg = pushfold::config(stack);
|
|
let b: exploit::abr::Buck = Arc::new(CoarseBucketer);
|
|
let mut c = AbrConfig::new(cfg, vec![0, 1], iters, 7);
|
|
c.capacity = 1 << 16;
|
|
c.max_infosets = 1 << 12;
|
|
let sp: Arc<dyn ActionSpace> = Arc::new(PushFold);
|
|
let ex = Exploiter::new(c, sp.clone(), sp, target.clone(), b.clone(), b);
|
|
ex.train(|_, _, _| {});
|
|
let pol = ex.policy("abr", Extract::Average);
|
|
let r = evaluate(&cfg, pol, target, &[0, 1], deals, 99);
|
|
println!(
|
|
"{name}: exploiter wins {} mbb/g (raw {}) by seat {:?}",
|
|
r.avg,
|
|
r.raw,
|
|
r.by_seat
|
|
.iter()
|
|
.map(|s| s.map(|e| e.mbb.round()))
|
|
.collect::<Vec<_>>()
|
|
);
|
|
(r.avg.mbb, 1.96 * r.avg.se)
|
|
}
|
|
|
|
#[test]
|
|
fn exploiter_is_zero_vs_equilibrium_and_large_vs_perturbed() {
|
|
let t = Instant::now();
|
|
let stack = 1000; // 10 bb: shove ranges are wide and non-trivial
|
|
let m = Matrix::compute(stack, 25_000, 1);
|
|
println!("equity matrix {:.1}s", t.elapsed().as_secs_f32());
|
|
let eq = m.solve(20_000);
|
|
let exact = m.exploitability_mbb(&eq.shove, &eq.call);
|
|
let bad = eq.perturbed(0.4);
|
|
let exact_bad = m.exploitability_mbb(&bad.shove, &bad.call);
|
|
println!(
|
|
"shove freq {:.3}; exact exploitability: eq {exact:.6} mbb, perturbed {exact_bad:.1} mbb",
|
|
eq.shove_freq(&m)
|
|
);
|
|
assert!(exact < 0.5, "CFR+ should solve the matrix game: {exact}");
|
|
assert!(exact_bad > 100.0);
|
|
|
|
let (z, zci) = train_and_eval(eq, "equilibrium", stack, 400_000, 200_000);
|
|
let (p, pci) = train_and_eval(bad, "perturbed", stack, 400_000, 200_000);
|
|
println!("total {:.1}s", t.elapsed().as_secs_f32());
|
|
// Equilibrium: measured exploitation within noise + equity-matrix MC error of the exact value.
|
|
assert!(
|
|
z.abs() < 25.0,
|
|
"exploiter wins {z} +- {zci} vs equilibrium (exact {exact})"
|
|
);
|
|
// Perturbed: large, and close to the exact exploitability of the perturbed strategy.
|
|
assert!(
|
|
p > 0.7 * exact_bad - pci,
|
|
"exploiter wins {p} +- {pci}, exact {exact_bad}"
|
|
);
|
|
assert!(p > 10.0 * z.abs());
|
|
}
|