sharingan-teilspiel: stichprobe format, --lagen/--art filter, vektor candidate from turn

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 20:47:46 +01:00
co-authored by Claude Opus 5.5
parent 57b9d858e2
commit 00adeafaae
@@ -12,7 +12,8 @@
//! `warm64` (`--set warm=64`), `vektor` (`--set vector=1,vecmin=flop`), `tabelle` (blueprint, no search).
//!
//! Flags of its own: `--requests F --out F [--cands a,b] [--iters-other 24000] [--iters-flop N]
//! [--br-iters N] [--eval-samples N] [--only i,j] [--no-gadget] [--max-lines N] [--threads N]`; everything else
//! [--br-iters N] [--eval-samples N] [--only i,j] [--no-gadget] [--max-lines N] [--threads N]
//! [--lagen stichprobe150_lagen.jsonl --art "FLOP 2"] (only situations whose `art` matches; matched by hole cards + board)`; everything else
//! is `sharingan-serve`'s configuration (`--blueprint`, `--buckets`, `--sizing`, `--set`, ...).
use serde_json::{json, Value};
@@ -23,14 +24,14 @@ use std::collections::{HashMap, HashSet};
use std::io::Write;
use std::time::Instant;
const OWN: &[&str] = &["requests", "out", "cands", "iters-other", "iters-flop", "br-iters", "eval-samples", "only", "no-gadget", "max-lines", "threads"];
const OWN: &[&str] = &["requests", "out", "cands", "iters-other", "iters-flop", "br-iters", "eval-samples", "only", "no-gadget", "max-lines", "threads", "lagen", "art"];
fn candidate_sets(name: &str) -> Option<&'static str> {
Some(match name {
"mittel" => "",
"final" => "final=1",
"warm64" => "warm=64",
"vektor" => "vector=1,vecmin=flop",
"vektor" => "vector=1,vecmin=turn",
"tabelle" => "",
_ => return None,
})
@@ -80,6 +81,22 @@ fn main() {
big_blind: 100,
threads: num("threads", 2) as usize,
};
let art_keys: Option<HashSet<String>> = match (own.get("lagen"), own.get("art")) {
(Some(f), Some(art)) => {
let rank = |r: &str| match r { "TWO" => "2", "THREE" => "3", "FOUR" => "4", "FIVE" => "5", "SIX" => "6", "SEVEN" => "7", "EIGHT" => "8", "NINE" => "9", "TEN" => "T", "JACK" => "J", "QUEEN" => "Q", "KING" => "K", _ => "A" };
let suit = |x: &str| match x { "DIAMONDS" => "d", "HEARTS" => "h", "CLUBS" => "c", _ => "s" };
let card = |c: &Value| format!("{}{}", rank(c["rank"].as_str().unwrap_or("")), suit(c["suit"].as_str().unwrap_or("")));
let text = std::fs::read_to_string(f).unwrap_or_else(|e| { eprintln!("{f}: {e}"); std::process::exit(1) });
Some(text.lines().filter_map(|l| serde_json::from_str::<Value>(l).ok()).filter(|v| v["art"].as_str() == Some(art.as_str())).map(|v| {
let q = &v["q"];
let mut hole: Vec<String> = q["heroCards"].as_array().map_or(vec![], |a| a.iter().map(&card).collect());
hole.sort();
let board: Vec<String> = ["FLOP", "TURN", "RIVER"].iter().flat_map(|k| q["board"][*k].as_array().cloned().unwrap_or_default()).map(|c| card(&c)).collect();
format!("{hole:?}|{board:?}")
}).collect())
}
_ => None,
};
let iters_other = num("iters-other", 24_000);
let iters_flop = own.get("iters-flop").and_then(|v| v.parse::<u64>().ok());
@@ -106,7 +123,8 @@ fn main() {
continue;
}
let Ok(v) = serde_json::from_str::<Value>(line) else { continue };
let f = &v["frage"];
// Farm spur lines wrap the question in "frage"; the stichprobe files hold it directly.
let f = if v["frage"].is_object() { &v["frage"] } else { &v };
if f["op"] != "suche" {
continue;
}
@@ -120,6 +138,14 @@ fn main() {
if !seen.insert(key.clone()) {
continue;
}
if let Some(keys) = &art_keys {
let mut hole = req.hole_cards.clone();
hole.sort();
if !keys.contains(&format!("{hole:?}|{:?}", req.board)) {
seen.remove(&key);
continue;
}
}
let flop = req.board.len() == 3;
let iters = if flop {
iters_flop.or(f["iters"].as_u64()).unwrap_or(200_000)