jamprobe-pool: table answer to our jam as root prior of the caller ranges (equilibrium approximation) instead of the best response; best response stays as information; spec of the five Tor-8 CFR-6max cases
Tor 8 (CFR-6max) showed the probe striking five jams against a best-response caller, the worst-case assumption. The pool chain now starts from the blueprint's own call answer at each opponent's node after our jam. Jam stays only with lower 95 % bound > 0 (unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
aaa71e15b9
commit
e8f4ae5dd2
@@ -7,6 +7,12 @@ Code: `entscheiden/motor/src/vorflop_jamprobe_pool.rs` (Modell, Posterior, Ziehu
|
||||
## Was es tut
|
||||
1. **Jam-Probe** (`MOTOR_VORFLOP_JAMPROBE=1`): heute streicht sie einen gezogenen All-in, wenn der Tafelwert (Bestantwort gegen unsere Jam-Range, Gegnerhaende aus der Tafelrange) < 0 ist. Mit Modell rechnet sie
|
||||
zusaetzlich den Wert gegen Posterior-Rufquoten und -Call-Ranges je Gegner (Position, Rolle, Stufe, Stack-Band, Typ, Zahl der Caller vor ihm; mehrweg ueber die Reihenfolge der Antworten).
|
||||
Wurzel-Prior je Gegner ist die **Tafel-Antwort auf unseren Jam** (Gleichgewichts-Naeherung: Rufanteil und Call-Haende seiner Range am Knoten nach
|
||||
unserem Jam, wenn die Gegner vor ihm folden; `tafel_antwort` in `dienst.rs`), nicht die Bestantwort (Hauptsession 05.12. nach Tor 8: die Bestantwort
|
||||
ist die schlimmste Annahme). Die Bestantwort bleibt nur als Auskunft im Zuggrund. Kette: Tafel -> Pool -> Stufe -> Rolle -> Position -> Stack-Band -> Typ.
|
||||
Spielerstufe fehlt: Profil und Gedaechtnis zaehlen je Spieler keine Antworten auf All-ins (nur Haende, VPIP, eigene All-ins); dafuer braeuchte der
|
||||
Laeufer einen neuen Zaehler. Fehlt ein Tafelknoten, ist die Probe nicht rechenbar (heutiges Urteil).
|
||||
Spec der fuenf Tor-8-Faelle (CFR-6max): `lesen/vorflop/jamprobe_pool_tor8.py` mit `jamprobe_pool_tor8.jsonl`.
|
||||
Strenge Lesart (Owner: "wenn unsicher niemals all in"): ein Jam bleibt nur, wenn die untere 95-%-Grenze seines Poolwerts (gegen Fold, Untergrenze des besten Nicht-Jam-Zugs) ueber 0 liegt, sonst faellt er; ein gestrichener kommt nur mit unterer Grenze > 0 zurueck. Nicht rechenbar: heutiges Urteil.
|
||||
2. **Sidecar an fold/call-Knoten vor einem All-in** (`MOTOR_VORFLOP_SELBST`): mehr Fold nur mit oberer Grenze von V(call) < 0, mehr Call nur mit unterer Grenze > 0, gerechnet gegen die Posterior-Shove-Range
|
||||
des Gegners zum echten Preis (heads-up); sonst gilt pi der Tafel (auch wo nicht rechenbar).
|
||||
@@ -26,4 +32,5 @@ Uebergross: `vorflop-selbst-uebergross` wie bisher, mit und ohne `MOTOR_JAMPROBE
|
||||
Pfade: `<B>` Baum des Zweigs `claude/jamprobe-pool` (Kopf siehe Commit), `<D>` = `D:\Projects\pokerfreak-daten\grundstrategie-mitzaehler`, `<O>` = `D:\Projects\pokerfreak-daten\innovation\jamprobe_pool\`.
|
||||
SHA256: `jamprobe-pool-v2.txt` d016e1cd80dfc7c833fb6c602b48cd43905697b9ea0e3ecd917463f19dbf9a3f, `ein-vorflop.jsonl` 5e8ff3a12416b9e3eca2324eb05c8717007d81f2917683e99b55c7ccd89b2a9d.
|
||||
Delta-Prior fuer Schritt 6/7 (`MOTOR_VORFLOP_UEBERGROSS_DELTA`, aus vergleich2): `0.069134,1.817251,0.080857,0.210826`.
|
||||
Schritt 0 (Tor-8-Spec, vor allem anderen): `python lesen\vorflop\jamprobe_pool_tor8.py <O>pokerbench-jamprobe-pool.exe <D> <einsatzstaerke-v3.txt> <O>jamprobe-pool-v2.txt aus=<O>tor8-faelle.tsv`.
|
||||
Mutationsprobe: nicht gelaufen (cargo-mutants `--file`/`--re` auf 74 Mutanten, etwa 2 Minuten je Mutant im Release-Bau, ueber 30 Minuten; abgebrochen nach 8 gefangenen, 0 uebersehenen, kein gueltiger Lauf).
|
||||
|
||||
@@ -1231,10 +1231,12 @@ impl Motor {
|
||||
let mut streicht = w < 0.0;
|
||||
let mut pool_text = String::new();
|
||||
if crate::vorflop_jamprobe_pool::an() {
|
||||
match self.jam_pool_grenzen(q, sitze, &tisch, &seats, &ranges, &ruft, hand, bb, &rake, saat) {
|
||||
let tafel = self.tafel_antwort(l, menue, jams, gegner, &ranges);
|
||||
let tafel_ruf = tafel.as_ref().map_or(0.0, |t| t.iter().map(|x| x.0).fold(0.0, f64::max));
|
||||
match tafel.and_then(|t| self.jam_pool_grenzen(q, sitze, &tisch, &seats, &t, hand, bb, &rake, saat)) {
|
||||
Ok(g) => {
|
||||
let neu = crate::vorflop_jamprobe_pool::jam_streichen(streicht, &g);
|
||||
pool_text = format!(", Pool {:+.1} bb [{:+.1}; {:+.1}] ({})", g.mittel / bb, g.unten / bb, g.oben / bb, if neu == streicht { "kein Beleg gegen das heutige Urteil" } else if neu { "Jam nicht belegt" } else { "Jam belegt" });
|
||||
pool_text = format!(", Pool {:+.1} bb [{:+.1}; {:+.1}] (Prior Tafel-Antwort, ruft bis {:.0}%; {})", g.mittel / bb, g.unten / bb, g.oben / bb, tafel_ruf * 100.0, if neu == streicht { "kein Beleg gegen das heutige Urteil" } else if neu { "Jam nicht belegt" } else { "Jam belegt" });
|
||||
streicht = neu;
|
||||
}
|
||||
Err(e) => pool_text = format!(", Pool nicht gerechnet: {e}"),
|
||||
@@ -1243,14 +1245,56 @@ impl Motor {
|
||||
Some((w, format!(" [Vorflop-Jam-Probe: Rechnung {:+.1} bb (Bestantwort, ruft mit bis {:.0}% der Range){b_text}, Wert {:+.1} bb{pool_text}", ev_a / bb, quote_ruf * 100.0, w / bb), streicht))
|
||||
}
|
||||
|
||||
/// MOTOR_JAMPROBE_POOL: Grenzen des Jam-Werts gegen die Posterior-Call-Quoten und -Ranges der Gegner (in Geld).
|
||||
/// Tafel-Antwort der Gegner auf unseren Jam (Gleichgewichts-Naeherung, Wurzel-Prior des Poolmodells): je Gegner `gegner[j]` der Rufanteil seiner Range
|
||||
/// und die Verteilung seiner Call-Haende ueber die 169 Klassen, gelesen an seinem Knoten nach unserem Jam, wenn alle Gegner vor ihm folden
|
||||
/// (die Zahl der Caller vor ihm traegt das Poolmodell selbst). Fehlt ein Knoten oder eine Range, ist die Probe nicht rechenbar.
|
||||
fn tafel_antwort(&self, l: &Lage, menue: &Menue, jams: &[usize], gegner: &[usize], ranges: &[Vec<f32>]) -> Result<Vec<(f64, [f64; crate::vorflop_jamprobe_pool::KLASSEN])>, String> {
|
||||
use crate::vorflop_jamprobe_pool::KLASSEN;
|
||||
let &jam = jams.iter().max_by_key(|&&j| menue.z[j].ziel).ok_or("kein Jam im Menue")?;
|
||||
let mut z = l.z;
|
||||
z.zieh(menue.z[jam].code, menue.z[jam].ziel);
|
||||
let paare = alle_paare();
|
||||
let mut je: Vec<Option<(f64, [f64; KLASSEN])>> = vec![None; gegner.len()];
|
||||
while !z.ende && je.iter().any(|x| x.is_none()) {
|
||||
let p = z.dran as usize;
|
||||
let m = z.menue(&self.s);
|
||||
let Some(j) = gegner.iter().position(|&g| g == p) else { return Err(format!("Tafel: Spieler {p} nicht unter den Gegnern")) };
|
||||
let call = m.liste().iter().position(|x| x.code == CALL).ok_or("Tafel: kein Call am Gegnerknoten")?;
|
||||
let key = z.schluessel(&m);
|
||||
let mut gewicht = [0f64; KLASSEN];
|
||||
for (h, &(a, b)) in paare.iter().enumerate() {
|
||||
gewicht[vorflop(a, b)] += ranges[j][h] as f64;
|
||||
}
|
||||
let (mut ja, mut alle) = (0f64, 0f64);
|
||||
let mut prior = [0f64; KLASSEN];
|
||||
for kl in 0..KLASSEN {
|
||||
if gewicht[kl] <= 0.0 {
|
||||
continue;
|
||||
}
|
||||
let v = self.st.hole(key, kl, m.n).ok_or_else(|| format!("Tafel: Knoten {key:016x} Klasse {kl} nie gelernt"))?;
|
||||
let c = v[call] as f64;
|
||||
alle += gewicht[kl];
|
||||
ja += gewicht[kl] * c;
|
||||
prior[kl] = gewicht[kl] * c;
|
||||
}
|
||||
if alle <= 0.0 || ja <= 0.0 {
|
||||
return Err(format!("Tafel: Spieler {p} ruft nie"));
|
||||
}
|
||||
je[j] = Some((ja / alle, prior));
|
||||
let fold = m.liste().iter().position(|x| x.code == FOLD).ok_or("Tafel: kein Fold am Gegnerknoten")?;
|
||||
z.zieh(FOLD, m.z[fold].ziel);
|
||||
}
|
||||
je.into_iter().map(|x| x.ok_or_else(|| "Tafel: Gegner ohne Knoten".to_string())).collect()
|
||||
}
|
||||
|
||||
/// MOTOR_JAMPROBE_POOL: Grenzen des Jam-Werts gegen die Posterior-Call-Quoten und -Ranges der Gegner (in Geld). Wurzel-Prior je Gegner: die Tafel-Antwort
|
||||
/// (`tafel_antwort`, Gleichgewichts-Naeherung), nicht die Bestantwort; darueber Pool, Stufe, Rolle, Position, Stack-Band und Typ.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn jam_pool_grenzen(&self, q: &Value, sitze: &[i64], tisch: &crate::vorflop_jamprobe::Tisch, seats: &[i64], ranges: &[Vec<f32>], ruft: &[Vec<bool>], hand: (u8, u8), bb: f64, rake: &crate::vorflop_jamprobe::RakeModell, saat: u64) -> Result<crate::vorflop_jamprobe_pool::Grenzen, String> {
|
||||
fn jam_pool_grenzen(&self, q: &Value, sitze: &[i64], tisch: &crate::vorflop_jamprobe::Tisch, seats: &[i64], tafel: &[(f64, [f64; crate::vorflop_jamprobe_pool::KLASSEN])], hand: (u8, u8), bb: f64, rake: &crate::vorflop_jamprobe::RakeModell, saat: u64) -> Result<crate::vorflop_jamprobe_pool::Grenzen, String> {
|
||||
use crate::vorflop_jamprobe_pool as pool;
|
||||
let m = pool::modell().ok_or("Modell nicht geladen")?;
|
||||
let held = q["heroSeat"].as_i64().ok_or("heroSeat")?;
|
||||
let (infos, raises) = pool::sitz_infos(q, sitze).ok_or("Sitzinfos")?;
|
||||
let paare = alle_paare();
|
||||
let stufe = (raises + 1).min(4) as u8;
|
||||
let mut t2 = tisch.clone();
|
||||
t2.gegner.clear();
|
||||
@@ -1259,22 +1303,9 @@ impl Motor {
|
||||
let Some(j) = seats.iter().position(|x| *x == s.sitz) else { return Err("Gegner nicht in der Rechnung".into()) };
|
||||
let g = tisch.gegner[j];
|
||||
let eff = tisch.ziel.min(g.drin + g.rest) / bb;
|
||||
let (mut ja, mut alle) = (0f64, 0f64);
|
||||
let mut prior = [0f64; pool::KLASSEN];
|
||||
for (h, &(a, b)) in paare.iter().enumerate() {
|
||||
let k = vorflop(a, b);
|
||||
let w = ranges[j][h] as f64;
|
||||
alle += w;
|
||||
if ruft[j][k] {
|
||||
ja += w;
|
||||
prior[k] += w;
|
||||
}
|
||||
}
|
||||
if alle <= 0.0 || ja <= 0.0 {
|
||||
prior = [1.0; pool::KLASSEN];
|
||||
}
|
||||
let (p_tisch, prior_call) = tafel[j];
|
||||
t2.gegner.push(g);
|
||||
anrufer.push(pool::Anrufer { merk: pool::Merkmale { stufe, rolle: s.rolle, pos: s.pos, band: crate::vorflop_tafel::band_von(eff), typ: s.typ }, p_tisch: ja / alle.max(1e-30), prior_call: prior });
|
||||
anrufer.push(pool::Anrufer { merk: pool::Merkmale { stufe, rolle: s.rolle, pos: s.pos, band: crate::vorflop_tafel::band_von(eff), typ: s.typ }, p_tisch, prior_call });
|
||||
}
|
||||
if anrufer.len() != tisch.gegner.len() {
|
||||
return Err("Gegnerzahl".into());
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{"fall":"tor8-blatt90-platz3","hand":["Qh","Kh"],"basis":["RAISE",2.0],"kandidat":["CALL",null],"q":{"variant":"NLHE","bigBlind":0.02,"seats":6,"heroSeat":4,"buttonSeat":6,"heroCards":[{"rank":"QUEEN","suit":"HEARTS"},{"rank":"KING","suit":"HEARTS"}],"board":{},"street":"PREFLOP","pot":1.46,"toCall":0.58,"heroStack":1.96,"legalActions":["FOLD","CALL","RAISE"],"allowedSizes":null,"villains":[{"seat":1,"stack":1.82,"folded":false},{"seat":2,"stack":1.38,"folded":false},{"seat":3,"stack":1.38,"folded":false},{"seat":5,"stack":2.0,"folded":true},{"seat":6,"stack":2.0,"folded":true}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":0.01},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":0.02},{"street":"PREFLOP","seat":3,"action":"RAISE","amount":0.04},{"street":"PREFLOP","seat":4,"action":"CALL","amount":0.04},{"street":"PREFLOP","seat":5,"action":"FOLD"},{"street":"PREFLOP","seat":6,"action":"FOLD"},{"street":"PREFLOP","seat":1,"action":"RAISE","amount":0.18},{"street":"PREFLOP","seat":2,"action":"RAISE","amount":0.62},{"street":"PREFLOP","seat":3,"action":"CALL","amount":0.62}],"seed":1267138157,"minRaiseTo":1.06,"maxRaiseTo":2.0}}
|
||||
{"fall":"tor8-blatt422-platz2","hand":["6s","6d"],"basis":["RAISE",2.0],"kandidat":["CALL",null],"q":{"variant":"NLHE","bigBlind":0.02,"seats":6,"heroSeat":3,"buttonSeat":6,"heroCards":[{"rank":"SIX","suit":"SPADES"},{"rank":"SIX","suit":"DIAMONDS"}],"board":{},"street":"PREFLOP","pot":1.54,"toCall":0.9,"heroStack":1.95,"legalActions":["FOLD","CALL","RAISE"],"allowedSizes":null,"villains":[{"seat":1,"stack":1.82,"folded":false},{"seat":2,"stack":1.05,"folded":false},{"seat":4,"stack":1.82,"folded":false},{"seat":5,"stack":2.0,"folded":true},{"seat":6,"stack":1.82,"folded":false}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":0.01},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":0.02},{"street":"PREFLOP","seat":3,"action":"RAISE","amount":0.05},{"street":"PREFLOP","seat":4,"action":"RAISE","amount":0.18},{"street":"PREFLOP","seat":5,"action":"FOLD"},{"street":"PREFLOP","seat":6,"action":"CALL","amount":0.18},{"street":"PREFLOP","seat":1,"action":"CALL","amount":0.18},{"street":"PREFLOP","seat":2,"action":"RAISE","amount":0.95}],"seed":1293316588,"minRaiseTo":1.72,"maxRaiseTo":2.0}}
|
||||
{"fall":"tor8-blatt588-platz4","hand":["Td","Kd"],"basis":["RAISE",2.0],"kandidat":["CALL",null],"q":{"variant":"NLHE","bigBlind":0.02,"seats":6,"heroSeat":5,"buttonSeat":6,"heroCards":[{"rank":"TEN","suit":"DIAMONDS"},{"rank":"KING","suit":"DIAMONDS"}],"board":{},"street":"PREFLOP","pot":0.816,"toCall":0.408,"heroStack":1.903,"legalActions":["FOLD","CALL","RAISE"],"allowedSizes":null,"villains":[{"seat":1,"stack":1.903,"folded":false},{"seat":2,"stack":1.495,"folded":false},{"seat":3,"stack":2.0,"folded":true},{"seat":4,"stack":1.98,"folded":true},{"seat":6,"stack":1.903,"folded":false}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":0.01},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":0.02},{"street":"PREFLOP","seat":3,"action":"FOLD"},{"street":"PREFLOP","seat":4,"action":"CALL","amount":0.02},{"street":"PREFLOP","seat":5,"action":"RAISE","amount":0.097},{"street":"PREFLOP","seat":6,"action":"CALL","amount":0.097},{"street":"PREFLOP","seat":1,"action":"CALL","amount":0.097},{"street":"PREFLOP","seat":2,"action":"RAISE","amount":0.505},{"street":"PREFLOP","seat":4,"action":"FOLD"}],"seed":1306582697,"minRaiseTo":0.913,"maxRaiseTo":2.0}}
|
||||
{"fall":"tor8-blatt619-platz1","hand":["5s","5h"],"basis":["RAISE",2.0],"kandidat":["FOLD",null],"q":{"variant":"NLHE","bigBlind":0.02,"seats":6,"heroSeat":2,"buttonSeat":6,"heroCards":[{"rank":"FIVE","suit":"SPADES"},{"rank":"FIVE","suit":"HEARTS"}],"board":{},"street":"PREFLOP","pot":0.56,"toCall":0.37,"heroStack":1.98,"legalActions":["FOLD","CALL","RAISE"],"allowedSizes":null,"villains":[{"seat":1,"stack":1.61,"folded":false},{"seat":3,"stack":1.98,"folded":false},{"seat":4,"stack":1.98,"folded":false},{"seat":5,"stack":2.0,"folded":true},{"seat":6,"stack":1.89,"folded":false}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":0.01},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":0.02},{"street":"PREFLOP","seat":3,"action":"CALL","amount":0.02},{"street":"PREFLOP","seat":4,"action":"CALL","amount":0.02},{"street":"PREFLOP","seat":5,"action":"FOLD"},{"street":"PREFLOP","seat":6,"action":"RAISE","amount":0.11},{"street":"PREFLOP","seat":1,"action":"RAISE","amount":0.39}],"seed":1308804369,"minRaiseTo":0.67,"maxRaiseTo":2.0}}
|
||||
{"fall":"tor8-blatt619-platz5","hand":["Qc","Kd"],"basis":["RAISE",2.0],"kandidat":["FOLD",null],"q":{"variant":"NLHE","bigBlind":0.02,"seats":6,"heroSeat":6,"buttonSeat":6,"heroCards":[{"rank":"QUEEN","suit":"CLUBS"},{"rank":"KING","suit":"DIAMONDS"}],"board":{},"street":"PREFLOP","pot":0.23,"toCall":0.09,"heroStack":2.0,"legalActions":["FOLD","CALL","RAISE"],"allowedSizes":null,"villains":[{"seat":1,"stack":1.99,"folded":false},{"seat":2,"stack":1.98,"folded":false},{"seat":3,"stack":1.98,"folded":false},{"seat":4,"stack":1.91,"folded":false},{"seat":5,"stack":1.91,"folded":false}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":0.01},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":0.02},{"street":"PREFLOP","seat":3,"action":"CALL","amount":0.02},{"street":"PREFLOP","seat":4,"action":"RAISE","amount":0.09},{"street":"PREFLOP","seat":5,"action":"CALL","amount":0.09}],"seed":1308626591,"minRaiseTo":0.16,"maxRaiseTo":2.0}}
|
||||
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Spec: the five Tor-8 jam-probe cases (CFR-6max, probe 86911151, messung/fremd/TOR8.md on claude/abnahme-bench c5336aba6).
|
||||
|
||||
In all five the base jams and the jam probe strikes the jam because it values it against a best-response caller. With MOTOR_JAMPROBE_POOL the
|
||||
probe values the jam against hierarchical caller ranges: table answer to our jam (equilibrium approximation) as root prior, then pool, stage,
|
||||
role, position, stack band and type; several callers in action order. The jam stays only if the lower 95 % bound of its value is above 0;
|
||||
the best-response value stays in the reason as information.
|
||||
|
||||
The expectation per case comes from the computation (the motor's posterior bounds), never from the outcome of the hand:
|
||||
A (no model): the probe strikes the jam (best-response value < 0), as in Tor 8.
|
||||
B (model): the probe reports Pool [mean; lower; upper] with the table-answer prior; verdict "Jam belegt" iff lower > 0,
|
||||
the action is never all-in when lower <= 0.
|
||||
|
||||
python3 lesen/vorflop/jamprobe_pool_tor8.py <motor.exe> <daten> <einsatzstaerke-v3.txt> <jamprobe-pool-v2.txt> [aus=<tsv>]
|
||||
|
||||
Requests: jamprobe_pool_tor8.jsonl (rebuilt from the table log by replaying tisch6.py; CFR bots, no real players). Exit 1 if a case
|
||||
violates the spec.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
HIER = os.path.dirname(os.path.abspath(__file__))
|
||||
FAELLE = os.path.join(HIER, "jamprobe_pool_tor8.jsonl")
|
||||
POOL = re.compile(r"Pool ([+-][\d.]+) bb \[([+-][\d.]+); ([+-][\d.]+)\] \(Prior Tafel-Antwort, ruft bis (\d+)%; ([^)]*)\)")
|
||||
BR = re.compile(r"Rechnung ([+-][\d.]+) bb \(Bestantwort, ruft mit bis (\d+)%")
|
||||
|
||||
|
||||
def umgebung(tafel, modell):
|
||||
e = dict(os.environ, R0="1", MOTOR_RAKE_REGEL="1", MOTOR_VORFLOP_ALLIN="1", MOTOR_VORFLOP_ALLIN_TAFEL=tafel,
|
||||
MOTOR_ALLIN_UEBERSETZUNG="1", MOTOR_VORFLOP_JAMPROBE="1")
|
||||
e.pop("MOTOR_JAMPROBE_POOL", None)
|
||||
if modell:
|
||||
e["MOTOR_JAMPROBE_POOL"] = modell
|
||||
return e
|
||||
|
||||
|
||||
def antworten(exe, daten, env, qs):
|
||||
argv = [exe, "dienst", "sechs100", daten, "2000-600-400", "200", os.path.join(daten, "sechs100-v2.bin"), "genau",
|
||||
"hu=%s,%s" % (os.path.join(daten, "hu100-v1.bin"), os.path.join(daten, "hu200-v2.bin"))]
|
||||
r = subprocess.run(argv, input="".join(json.dumps(q) + "\n" for q in qs), capture_output=True, text=True, env=env,
|
||||
creationflags=(0x08000000 | 0x4000) if os.name == "nt" else 0)
|
||||
z = [json.loads(x) for x in r.stdout.splitlines() if x.strip()]
|
||||
if len(z) != len(qs):
|
||||
raise SystemExit("%d answers to %d requests; stderr: %s" % (len(z), len(qs), r.stderr[-800:]))
|
||||
return z
|
||||
|
||||
|
||||
def ist_jam(w, q):
|
||||
return w.get("action") == "RAISE" and w.get("size") is not None and abs(float(w["size"]) - float(q["maxRaiseTo"])) < 1e-9
|
||||
|
||||
|
||||
def pruefe(fall, q, a, b):
|
||||
"""Returns (row, violations)."""
|
||||
fehler = []
|
||||
ra, rb = a.get("reason") or "", b.get("reason") or ""
|
||||
br = BR.search(ra)
|
||||
if not br or float(br.group(1)) >= 0 or ist_jam(a, q):
|
||||
fehler.append("A: probe does not strike the jam against the best response")
|
||||
p = POOL.search(rb)
|
||||
zeile = {"fall": fall, "br_bb": br and float(br.group(1)), "br_ruft": br and int(br.group(2)), "zug_a": a.get("action"), "zug_b": b.get("action"),
|
||||
"jam_b": ist_jam(b, q)}
|
||||
if not p:
|
||||
fehler.append("B: no pool bounds with table-answer prior in the reason: " + rb[-200:])
|
||||
return zeile, fehler
|
||||
m, u, o, ruf, urteil = float(p.group(1)), float(p.group(2)), float(p.group(3)), int(p.group(4)), p.group(5)
|
||||
zeile.update(pool_mittel=m, pool_unten=u, pool_oben=o, tafel_ruft=ruf, urteil=urteil, jam_bleibt=u > 0)
|
||||
if not (u <= m <= o):
|
||||
fehler.append("B: bounds out of order")
|
||||
# today's verdict (best response) strikes the jam, so with the strict reading: lower > 0 -> "Jam belegt", else it stays struck
|
||||
erwartet = "Jam belegt" if u > 0 else "kein Beleg gegen das heutige Urteil"
|
||||
if urteil != erwartet:
|
||||
fehler.append("B: verdict %r, expected %r from lower bound %+.1f" % (urteil, erwartet, u))
|
||||
if u <= 0 and ist_jam(b, q):
|
||||
fehler.append("B: all-in although the lower bound is <= 0")
|
||||
return zeile, fehler
|
||||
|
||||
|
||||
def main(argv):
|
||||
exe, daten, tafel, modell = argv[:4]
|
||||
opt = dict(x.split("=", 1) for x in argv[4:])
|
||||
faelle = [json.loads(z) for z in open(FAELLE, encoding="utf-8") if z.strip()]
|
||||
qs = [f["q"] for f in faelle]
|
||||
a = antworten(exe, daten, umgebung(tafel, None), qs)
|
||||
b = antworten(exe, daten, umgebung(tafel, modell), qs)
|
||||
zeilen, alle = [], []
|
||||
for f, q, x, y in zip(faelle, qs, a, b):
|
||||
z, fe = pruefe(f["fall"], q, x, y)
|
||||
z["hand"] = "".join(f["hand"])
|
||||
zeilen.append(z)
|
||||
alle += ["%s: %s" % (f["fall"], e) for e in fe]
|
||||
print(json.dumps(z, ensure_ascii=False))
|
||||
if opt.get("aus"):
|
||||
kopf = ["fall", "hand", "br_bb", "br_ruft", "tafel_ruft", "pool_mittel", "pool_unten", "pool_oben", "urteil", "jam_bleibt", "zug_a", "zug_b", "jam_b"]
|
||||
tmp = opt["aus"] + ".tmp"
|
||||
with open(tmp, "w", encoding="utf-8") as f:
|
||||
f.write("\t".join(kopf) + "\n")
|
||||
for z in zeilen:
|
||||
f.write("\t".join(str(z.get(k, "")) for k in kopf) + "\n")
|
||||
os.replace(tmp, opt["aus"])
|
||||
for e in alle:
|
||||
print("VERLETZT", e)
|
||||
print("%d cases, %d violations" % (len(faelle), len(alle)))
|
||||
return 1 if alle else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
Reference in New Issue
Block a user