PREFLOP_OHNE_ANTE: Open-Tabellen ohne Antes (Schalter, Vorgabe aus)

Die eingefrorenen Tabellen rechnen 0,96 bb Antes; live Micro hat keine
(2703/2703 Haende). chartgen charts --ohne-ante --nur-open loest die 15
Open-Spiele ohne Antes (63 min, 2 Threads Idle). Mit dem Schalter liest
generated_lookup diese Tabellen; multi_lookup liest die ante-freien
Multi-/Tiefen-Dateien, solange sie leer sind die alten (Lauf eingereiht).
Push/Fold bleibt mit Antes (Turnier).

- BB-Verteidigung (Anteil aller Haende) z. B. vs BTN 100bb 72 % -> 44 %,
  vs SB 100bb 84 % -> 53 %; Opens je Sitz 6-9 Punkte enger.
- Aus: bit-identisch zum Live-Kern auf 2776 echten Spots.
- An: 102/2776 Aktionen kippen (3,7 %), meist BB vs open CALL->FOLD
  (35, live -137 bb in diesen Haenden); messung_preflop/replay_ohneante.md.
- Schalter in decide.py/roentgen.py BEKANNTE_SCHALTER; tests/preflop_ohne_ante.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 00:48:41 +01:00
co-authored by Claude Opus 5.5
parent 242b21c696
commit f0d1254179
17 changed files with 2081 additions and 12 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ QUELLE = os.environ.get("COINPOKER_KERN_QUELLE", os.path.join(BASE, ".."))
# Hand in haende.jsonl, mit welchem Engine-Stand sie gespielt wurde (runner.py liest den Arm nach
# diesem Import).
SCHALTER_DATEI = os.path.join(BASE, "..", "betrieb", "kern_schalter.txt")
BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "GRUNDSTRATEGIE", "OPEN_JAM", "PREFLOP_VOLL")
BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "GRUNDSTRATEGIE", "OPEN_JAM", "PREFLOP_VOLL", "PREFLOP_OHNE_ANTE")
# Pfade gehoeren nicht in die Arm-Marke.
OHNE_MARKE = ("GRUNDSTRATEGIE",)
+1 -1
View File
@@ -58,7 +58,7 @@ KLASSEN_NAME = {
"heuristik": "Heuristik", "enthaltung": "Enthaltung",
}
# Gleiche Liste wie entscheiden/decide.py: nur Messschalter, keine beliebige Umgebung.
BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "GRUNDSTRATEGIE", "OPEN_JAM", "PREFLOP_VOLL")
BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "GRUNDSTRATEGIE", "OPEN_JAM", "PREFLOP_VOLL", "PREFLOP_OHNE_ANTE")
OHNE_MARKE = ("GRUNDSTRATEGIE",)
IDLE_PRIORITY_CLASS = 0x00000040
KERN_KOPIE = "pokerbench-roentgen-nachspiel" + (".exe" if sys.platform == "win32" else "")
+2
View File
@@ -7,3 +7,5 @@ anfragen.jsonl
haende.jsonl
generated_teilspiel.rs
cargo_test*.log
tief/*.rs
tief/*.tmp
+12
View File
@@ -0,0 +1,12 @@
"""Echte Preflop-Anfragen (anfragen.jsonl) durch einen Kern, Idle-Prioritaet.
python messung_preflop/kern_lauf.py <kern.exe> <aus.jsonl> [ENV=WERT ...]"""
import os, subprocess, sys
exe, aus, *paare = sys.argv[1:]
env = dict(os.environ)
env.update(MDF_UNREAD='0', TURN_SPIEL='grund', OPEN_JAM='1',
GRUNDSTRATEGIE=r'D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten')
for p in paare:
k, v = p.split('=', 1); env[k] = v
with open('messung_preflop/anfragen.jsonl', 'rb') as ein, open(aus, 'wb') as raus:
subprocess.run([os.path.abspath(exe)], stdin=ein, stdout=raus, env=env, check=True, creationflags=0x40)
print(aus, sum(1 for _ in open(aus, 'rb')))
+32
View File
@@ -0,0 +1,32 @@
"""Replay zweier Kern-Ausgaben auf den 2776 echten Preflop-Spots: welche Aktionen kippen, je Klasse.
python messung_preflop/replay2.py <aus_basis.jsonl> <aus_arm.jsonl>"""
import json, collections, sys
a_path, b_path = sys.argv[1:3]
aus=[json.loads(l) for l in open(a_path,encoding='utf-8')]
an=[json.loads(l) for l in open(b_path,encoding='utf-8')]
rows=[json.loads(l) for l in open('messung_preflop/nachher.jsonl',encoding='utf-8')]
spots=[json.loads(l) for l in open('messung_preflop/spots.jsonl',encoding='utf-8')]
netto={}
for l in open('messung_preflop/haende.jsonl',encoding='utf-8'):
h=json.loads(l)
if h.get('bb'): netto[str(h['hand'])]=h['netto']/h['bb']
def grob(r):
k=r['klasse'].replace(' [all-in]','')
if k.startswith('first-in'): k='first-in'+(' '+r.get('pos','') if r.get('pos') else '')
elif k.startswith('vs open HU-linie'): k=k
return k+(' >100bb' if (r.get('tiefe') or 0)>100 else '')
n=collections.Counter(); kipp=collections.Counter(); wege=collections.defaultdict(collections.Counter); bb=collections.defaultdict(float)
gesamt=0
for a,b,r,s in zip(aus,an,rows,spots):
k=grob(r); n[k]+=1
if a['action']!=b['action']:
gesamt+=1; kipp[k]+=1; wege[k][f"{a['action']}->{b['action']}"]+=1; bb[k]+=netto.get(str(s['hand']),0)
print(f"{a_path} -> {b_path}\n\nAktion gekippt: {gesamt}/{len(aus)} = {100*gesamt/len(aus):.1f} %\n")
print("| Klasse | Spots | gekippt | Richtungen | Live BB der Haende (vorher gespielt) |\n|---|---|---|---|---|")
for k,c in sorted(kipp.items(),key=lambda kv:-kv[1]):
w=', '.join(f"{x} {m}" for x,m in wege[k].most_common(4))
print(f"| {k} | {n[k]} | {c} | {w} | {bb[k]:+.1f} |")
tot=collections.Counter()
for k in wege:
for x,m in wege[k].items(): tot[x]+=m
print("\nRichtungen gesamt:", dict(tot.most_common()))
+21
View File
@@ -0,0 +1,21 @@
messung_preflop/aus_b.jsonl -> messung_preflop/aus_ohneante.jsonl
Aktion gekippt: 102/2776 = 3.7 %
| Klasse | Spots | gekippt | Richtungen | Live BB der Haende (vorher gespielt) |
|---|---|---|---|---|
| vs open HU-linie BB | 192 | 29 | CALL->FOLD 20, CALL->RAISE 5, RAISE->CALL 3, RAISE->FOLD 1 | -120.0 |
| vs open HU-linie BB >100bb | 74 | 21 | CALL->FOLD 15, RAISE->CALL 4, CALL->RAISE 1, RAISE->FOLD 1 | -17.0 |
| first-in EP >100bb | 202 | 12 | RAISE->FOLD 12 | +8.0 |
| first-in MP >100bb | 104 | 11 | RAISE->FOLD 11 | +17.5 |
| vs open HU-linie SB >100bb | 74 | 5 | RAISE->CALL 2, CALL->FOLD 2, CALL->RAISE 1 | +13.5 |
| first-in SB | 121 | 4 | RAISE->FOLD 4 | +7.0 |
| first-in CO >100bb | 170 | 4 | RAISE->FOLD 4 | +7.5 |
| first-in SB >100bb | 43 | 4 | RAISE->FOLD 4 | -4.0 |
| opener vs 3-bet | 83 | 3 | RAISE->CALL 2, RAISE->FOLD 1 | +108.5 |
| vs open + caller (squeeze/overcall) >100bb | 46 | 3 | CALL->FOLD 3 | -31.0 |
| first-in BTN >100bb | 120 | 3 | RAISE->FOLD 3 | -0.5 |
| vs open + caller (squeeze/overcall) | 80 | 2 | CALL->FOLD 2 | -62.0 |
| opener vs 3-bet >100bb | 22 | 1 | CALL->FOLD 1 | -11.0 |
Richtungen gesamt: {'CALL->FOLD': 43, 'RAISE->FOLD': 41, 'RAISE->CALL': 11, 'CALL->RAISE': 7}
+15
View File
@@ -0,0 +1,15 @@
messung_preflop/aus_an.jsonl -> messung_preflop/aus_voll_ohneante.jsonl
Aktion gekippt: 48/2776 = 1.7 %
| Klasse | Spots | gekippt | Richtungen | Live BB der Haende (vorher gespielt) |
|---|---|---|---|---|
| vs open HU-linie BB | 192 | 23 | CALL->FOLD 16, CALL->RAISE 4, RAISE->CALL 2, RAISE->FOLD 1 | -150.5 |
| vs open HU-linie BB >100bb | 74 | 9 | CALL->FOLD 6, CALL->RAISE 1, RAISE->CALL 1, RAISE->FOLD 1 | -18.0 |
| first-in SB | 121 | 4 | RAISE->FOLD 4 | +7.0 |
| first-in SB >100bb | 43 | 4 | RAISE->FOLD 4 | -4.0 |
| opener vs 3-bet | 83 | 3 | RAISE->CALL 2, RAISE->FOLD 1 | +108.5 |
| vs open + caller (squeeze/overcall) >100bb | 46 | 3 | CALL->FOLD 3 | -31.0 |
| vs open + caller (squeeze/overcall) | 80 | 2 | CALL->FOLD 2 | -62.0 |
Richtungen gesamt: {'CALL->FOLD': 27, 'RAISE->FOLD': 11, 'CALL->RAISE': 5, 'RAISE->CALL': 5}
@@ -0,0 +1,4 @@
charts: 0 push/fold + 15 open spots on 2 threads
charts: push/fold done at 0.0 s
charts: all done in 3798.3 s
chartgen: tief\generated_charts_ohne_ante.rs written
+72 -8
View File
@@ -70,9 +70,29 @@ fn option<T: std::str::FromStr>(args: &[String], name: &str) -> Option<T> {
fn threads(args: &[String]) -> usize {
option(args, "--threads")
.or_else(|| std::env::var("POKERBENCH_THREADS").ok().and_then(|v| v.parse().ok()))
.unwrap_or_else(|| std::thread::available_parallelism().map_or(1, |n| n.get()))
}
/// `--ohne-ante`: the same games without the table's antes (live micro cash has none; switch
/// `PREFLOP_OHNE_ANTE`, `preflop::ante`).
fn ohne_ante(args: &[String]) -> bool {
args.iter().any(|a| a == "--ohne-ante")
}
fn umwelt(args: &[String], env: Environment) -> Environment {
if ohne_ante(args) { Environment { antes: 0.0, ..env } } else { env }
}
/// Header of an ante-free file: its own command, and no antes in the assumptions.
fn ohne_ante_kopf(text: String, befehl: &str, neu: &str) -> String {
text.replacen(befehl, neu, 1).replacen(
"//! Antes of six seats are dead money in every pot; the winner of a fold takes them too.",
"//! NO antes (`--ohne-ante`, switch `PREFLOP_OHNE_ANTE`): the live micro cash tables have none.",
1,
)
}
fn deck(args: &[String]) -> ChartDeck {
match option::<String>(args, "--deck").as_deref() {
Some("short") => ChartDeck::Short,
@@ -99,10 +119,12 @@ fn equity(args: &[String]) -> Result<String, Fault> {
fn charts(args: &[String]) -> Result<String, Fault> {
let deck = deck(args);
let env = Environment::frozen_for(deck);
let env = umwelt(args, Environment::frozen_for(deck));
// `--nur-open`: no push / fold spots (the ante-free file only carries the open games).
let nur_open = args.iter().any(|a| a == "--nur-open");
let push_iterations: Option<u32> = option(args, "--push-iterations");
let open_iterations: Option<u32> = option(args, "--open-iterations");
let (push_plan, open_plan) = (push_fold_plan(), open_plan());
let (push_plan, open_plan) = (if nur_open { Vec::new() } else { push_fold_plan() }, open_plan());
let started = Instant::now();
eprintln!(
"charts: {} push/fold + {} open spots on {} threads",
@@ -122,7 +144,16 @@ fn charts(args: &[String]) -> Result<String, Fault> {
eprintln!("charts: all done in {:.1} s", started.elapsed().as_secs_f64());
let push = push.into_iter().collect::<Result<Vec<_>, _>>()?;
let open = open.into_iter().collect::<Result<Vec<_>, _>>()?;
Ok(render_charts(deck, &push, &open))
let text = render_charts(deck, &push, &open);
Ok(if ohne_ante(args) {
ohne_ante_kopf(
text,
"chartgen -- charts > src/preflop/generated_charts.rs",
"chartgen -- charts --ohne-ante --nur-open > src/preflop/generated_charts_ohne_ante.rs",
)
} else {
text
})
}
fn seat(args: &[String]) -> Result<Seat, Fault> {
@@ -161,7 +192,7 @@ fn multi_spot(args: &[String]) -> Result<String, Fault> {
/// One-defender baselines and every multi-defender spot; the most expensive spots start first.
fn multi(args: &[String]) -> Result<String, Fault> {
let env = Environment::frozen();
let env = umwelt(args, Environment::frozen());
let iterations = option(args, "--iterations").unwrap_or(MULTI_ITERATIONS);
let samples = option(args, "--check").unwrap_or(MULTI_CHECK_SAMPLES);
let started = Instant::now();
@@ -192,8 +223,20 @@ fn multi(args: &[String]) -> Result<String, Fault> {
let mut solved = solved;
solved.sort_by_key(|(i, _)| *i);
let spots = solved.into_iter().map(|(_, r)| r).collect::<Result<Vec<_>, _>>()?;
let reference: Vec<(Seat, u8, Vec<u16>)> = OPEN.iter().map(|s| (s.seat, s.depth_bb, s.open.to_vec())).collect();
Ok(render_multi(&env, &spots, &baselines, &reference))
// The two-blind reference of the same environment (the ante-free one, once it exists).
let open_ref: &[rechner::cfr::frozen_spot::OpenSpot] =
if ohne_ante(args) { &rechner::preflop::generated_charts_ohne_ante::OPEN } else { &OPEN };
let reference: Vec<(Seat, u8, Vec<u16>)> = open_ref.iter().map(|s| (s.seat, s.depth_bb, s.open.to_vec())).collect();
let text = render_multi(&env, &spots, &baselines, &reference);
Ok(if ohne_ante(args) {
ohne_ante_kopf(
text,
"chartgen -- multi > src/preflop/generated_charts_multi.rs",
"chartgen -- multi --ohne-ante > src/preflop/generated_charts_multi_ohne_ante.rs",
)
} else {
text
})
}
/// Tiefe Stacks (Schalter `PREFLOP_VOLL`): dieselben Multi-Spiele bei `DEEP_DEPTHS` (150 / 200 bb), in
@@ -202,7 +245,7 @@ fn multi(args: &[String]) -> Result<String, Fault> {
/// `cargo run --release --bin chartgen -- multi-deep --threads 2 > src/preflop/generated_charts_multi_deep.rs`
fn multi_deep(args: &[String]) -> Result<String, Fault> {
use rechner::cfr::render_multi::DEEP_DEPTHS;
let env = Environment::frozen();
let env = umwelt(args, Environment::frozen());
let iterations = option(args, "--iterations").unwrap_or(MULTI_ITERATIONS);
let samples = option(args, "--check").unwrap_or(MULTI_CHECK_SAMPLES);
let started = Instant::now();
@@ -238,7 +281,16 @@ fn multi_deep(args: &[String]) -> Result<String, Fault> {
let mut solved = solved;
solved.sort_by_key(|(i, _)| *i);
let spots = solved.into_iter().map(|(_, r)| r).collect::<Result<Vec<_>, _>>()?;
Ok(rechner::cfr::render_multi::render_multi_deep(&env, &spots, &baselines))
let text = rechner::cfr::render_multi::render_multi_deep(&env, &spots, &baselines);
Ok(if ohne_ante(args) {
ohne_ante_kopf(
text,
"chartgen -- multi-deep > src/preflop/generated_charts_multi_deep.rs",
"chartgen -- multi-deep --ohne-ante > src/preflop/generated_charts_multi_deep_ohne_ante.rs",
)
} else {
text
})
}
/// Die Teilspiele (`cfr::teilspiel_plan`): jede Zelle eigenes Zwei-Spieler-Spiel mit festen Eingangs-Ranges.
@@ -348,7 +400,19 @@ fn main() {
std::process::exit(2);
}
};
// `--out <file>`: write the source there (via a temporary file, so a stopped run leaves none),
// for queue runs whose stdout is a log.
let out: Option<String> = option(&args, "--out");
match result {
Ok(source) if out.is_some() => {
let out = out.unwrap_or_default();
let tmp = format!("{out}.tmp");
if let Err(e) = std::fs::write(&tmp, &source).and_then(|_| std::fs::rename(&tmp, &out)) {
eprintln!("chartgen: {out}: {e}");
std::process::exit(1);
}
eprintln!("chartgen: {out} written");
}
Ok(source) => print!("{source}"),
Err(fault) => {
eprintln!("chartgen: {fault}");
+35
View File
@@ -0,0 +1,35 @@
//! Schalter `PREFLOP_OHNE_ANTE`: die Open-Tabellen ohne Antes statt mit den 0,96 bb der gemessenen
//! Spieltisch-Antes (6 x 0,16 bb).
//!
//! Die eingefrorenen Tabellen (`generated_charts::OPEN`, `generated_charts_multi::MULTI`, die tiefen
//! Multi-Tabellen) rechnen jeden Pot mit 0,96 bb toten Antes. Am Live-Tisch (Micro-Cash 0.01/0.02)
//! gibt es keine: 14.11. 2703 von 2703 Haenden mit Ante 0. Mit Antes ist jeder Pot billiger zu
//! betreten, die Ranges sind zu weit (Teilspiel-Probe: BB gegen BTN-Open 2,5 bb verteidigt mit Antes
//! ~57 %, ohne ~40 %).
//!
//! An (`PREFLOP_OHNE_ANTE=1`): `generated_lookup` liest `generated_charts_ohne_ante::OPEN`,
//! `multi_lookup` die Multi-Tabellen aus `generated_charts_multi_ohne_ante` (und die tiefen aus
//! `generated_charts_multi_deep_ohne_ante`). Push / Fold bleibt mit Antes (das Turnier spielt mit Antes).
//! Aus (Vorgabe): alles wie vorher, bit-identisch. Einmal gelesen; `set_ohne_ante` fuer Tests und Arme.
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::OnceLock;
/// 0 = nicht gesetzt (Umgebung lesen), 1 = aus, 2 = an.
static SCHALTER: AtomicU8 = AtomicU8::new(0);
pub fn set_ohne_ante(an: bool) {
SCHALTER.store(if an { 2 } else { 1 }, Ordering::Relaxed);
}
/// `PREFLOP_OHNE_ANTE=1` (oder `set_ohne_ante(true)`). Vorgabe aus.
pub fn ohne_ante() -> bool {
match SCHALTER.load(Ordering::Relaxed) {
1 => false,
2 => true,
_ => {
static ENV: OnceLock<bool> = OnceLock::new();
*ENV.get_or_init(|| std::env::var("PREFLOP_OHNE_ANTE").as_deref() == Ok("1"))
}
}
}
@@ -0,0 +1,7 @@
//! Platzhalter, bis `chartgen multi-deep --ohne-ante` gelaufen ist (dann ersetzt).
use crate::cfr::frozen_multi::{BaselineSpot, MultiSpot};
pub const DEEP_DEPTHS: [u8; 2] = [150, 200];
pub static BASELINE_DEEP: [BaselineSpot; 0] = [];
pub static MULTI_DEEP: [MultiSpot; 0] = [];
@@ -0,0 +1,7 @@
//! Platzhalter, bis `chartgen multi --ohne-ante` gelaufen ist (dann ersetzt).
use crate::cfr::frozen_multi::{BaselineSpot, MultiSpot};
pub const OPEN_DEPTHS: [u8; 3] = [20, 40, 100];
pub static BASELINE: [BaselineSpot; 0] = [];
pub static MULTI: [MultiSpot; 0] = [];
File diff suppressed because it is too large Load Diff
+2
View File
@@ -168,6 +168,8 @@ fn push_chart(variant: Variant) -> Option<&'static [PushFoldSpot]> {
fn open_chart(variant: Variant) -> Option<&'static [OpenSpot]> {
match variant {
// `PREFLOP_OHNE_ANTE`: the same games without the table's antes (live micro cash has none).
Variant::Nlhe if super::ante::ohne_ante() => non_empty(&super::generated_charts_ohne_ante::OPEN),
Variant::Nlhe => non_empty(&OPEN),
Variant::ShortDeck => non_empty(&short::OPEN),
_ => None,
+4
View File
@@ -15,6 +15,9 @@ pub mod full_chart;
pub mod generated_charts;
pub mod generated_charts_multi;
pub mod generated_charts_multi_deep;
pub mod generated_charts_multi_deep_ohne_ante;
pub mod generated_charts_multi_ohne_ante;
pub mod generated_charts_ohne_ante;
pub mod generated_teilspiel;
pub mod generated_charts_short;
pub mod generated_lookup;
@@ -42,6 +45,7 @@ pub mod short_deck_percentile;
pub mod short_deck_ranking;
pub mod teilspiel_lookup;
pub mod voll;
pub mod ante;
pub mod situation;
pub mod situation_of;
pub mod width_factor;
+11 -2
View File
@@ -25,9 +25,18 @@ pub fn multi_depth_range() -> (f64, f64) {
}
fn spot(seat: Seat, defenders: usize, depth: u8) -> Option<&'static MultiSpot> {
MULTI
// `PREFLOP_OHNE_ANTE`: the same games without the table's antes. A file that is not solved yet
// (empty) leaves the table with antes in place, so the switch can be measured file by file.
let (flach, tief): (&'static [MultiSpot], &'static [MultiSpot]) = if super::ante::ohne_ante() {
let flach: &'static [MultiSpot] = &super::generated_charts_multi_ohne_ante::MULTI;
let tief: &'static [MultiSpot] = &super::generated_charts_multi_deep_ohne_ante::MULTI_DEEP;
(if flach.is_empty() { &MULTI } else { flach }, if tief.is_empty() { &MULTI_DEEP } else { tief })
} else {
(&MULTI, &MULTI_DEEP)
};
flach
.iter()
.chain(MULTI_DEEP.iter())
.chain(tief.iter())
.find(|s| s.seat == seat && s.defenders as usize == defenders && s.depth_bb == depth)
}
+83
View File
@@ -0,0 +1,83 @@
//! Spec: `PREFLOP_OHNE_ANTE` reads the open tables solved WITHOUT the table antes.
//!
//! The frozen open / multi tables carry six antes of 0.16 bb (0.96 bb dead money). Live micro cash
//! (0.01/0.02) has none: 14.11. 2703 of 2703 hands with ante 0. `chartgen charts --ohne-ante
//! --nur-open` solves the same 15 open games without them (`generated_charts_ohne_ante`).
//!
//! The switch is process-global: everything that toggles it runs in ONE test, in order.
use rechner::cfr::hand_class::{class_parse, CLASS_COUNT};
use rechner::cfr::seat::Seat;
use rechner::preflop::ante::set_ohne_ante;
use rechner::preflop::generated_charts::{OPEN, OPEN_DEPTHS};
use rechner::preflop::generated_charts_ohne_ante::OPEN as OPEN_OHNE_ANTE;
use rechner::preflop::generated_lookup::{open_frequency, push_frequency, vs_open};
use rechner::variant::Variant;
/// Combo-weighted share of hands the row plays (permille rows).
fn width(row: &[u16; CLASS_COUNT]) -> f64 {
let combos = |c: usize| {
let name = rechner::cfr::hand_class::class_name(c as _).unwrap_or_default();
if name.len() == 2 { 6.0 } else if name.ends_with('s') { 4.0 } else { 12.0 }
};
(0..CLASS_COUNT).map(|c| combos(c) * row[c] as f64 / 1000.0).sum::<f64>() / 1326.0
}
fn defend_width(row: &[[u16; 2]; CLASS_COUNT]) -> f64 {
let mut both = [0u16; CLASS_COUNT];
for c in 0..CLASS_COUNT {
both[c] = row[c][0] + row[c][1];
}
width(&both)
}
#[test]
fn the_switch_reads_the_ante_free_tables_and_nothing_else() {
// The file covers the same plan: every seat at every open depth, once.
assert_eq!(OPEN_OHNE_ANTE.len(), OPEN.len(), "ante-free tables solved (chartgen charts --ohne-ante --nur-open)");
for (a, b) in OPEN.iter().zip(OPEN_OHNE_ANTE.iter()) {
assert_eq!((a.seat, a.depth_bb), (b.seat, b.depth_bb));
}
let header = include_str!("../src/preflop/generated_charts_ohne_ante.rs");
assert!(header.contains("NO antes"), "the file says what it is");
let aa = class_parse("AA").expect("AA");
let k4o = class_parse("K4o").expect("K4o");
// Off: the lookup is the frozen table with antes, entry for entry.
set_ohne_ante(false);
for s in OPEN.iter() {
for c in [aa, k4o] {
let f = open_frequency(Variant::Nlhe, s.seat, s.depth_bb as f64, c).expect("open");
assert!((f.raise - s.open[c] as f64 / 1000.0).abs() < 1e-12);
}
}
let push_off = push_frequency(Variant::Nlhe, Seat::Button, 10.0, k4o).expect("push");
// On: the ante-free table, entry for entry; push / fold stays with antes (tournaments).
set_ohne_ante(true);
for s in OPEN_OHNE_ANTE.iter() {
for c in [aa, k4o] {
let f = open_frequency(Variant::Nlhe, s.seat, s.depth_bb as f64, c).expect("open");
assert!((f.raise - s.open[c] as f64 / 1000.0).abs() < 1e-12);
}
let v = vs_open(Variant::Nlhe, s.seat, s.depth_bb as f64, aa).expect("defend");
assert!(v.fold < 0.01, "{:?} {}: BB folds aces", s.seat, s.depth_bb);
}
assert_eq!(push_frequency(Variant::Nlhe, Seat::Button, 10.0, k4o).expect("push"), push_off);
set_ohne_ante(false);
// Without dead money every pot is dearer to enter: the opens and the big blind's defence
// against them are narrower than with antes, at every seat and depth.
for (a, b) in OPEN.iter().zip(OPEN_OHNE_ANTE.iter()) {
let tag = format!("{} {}bb", a.seat.label(), a.depth_bb);
assert!(width(&b.open) < width(&a.open), "{tag}: open {} vs {} with antes", width(&b.open), width(&a.open));
assert!(
defend_width(&b.defend) < defend_width(&a.defend) + 0.01,
"{tag}: BB defends {} vs {} with antes",
defend_width(&b.defend),
defend_width(&a.defend)
);
}
assert_eq!(OPEN_DEPTHS, [20, 40, 100]);
}