Sim: Leiterzeile pool-<stufe> aus geeichter Pool-Persona (POOL_PERSONA)
Persona::from_pool_json ersetzt die genannten Felder der Micro-Basis, unbekannte Felder sind ein Fehler. Eigene Zieh- und Austeil-Seeds; alle bisherigen Zeilen unveraendert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,10 @@ const MICRO_SEED: u64 = 0x31C0_5EED;
|
||||
/// Holdout pool (plan M1): opponents nobody develops against. Separate draw and deal seeds, so the
|
||||
/// individuals and the cards are new; `ho-regeln` draws a fresh rule bot per cell. Only the gates E4
|
||||
/// and E5 run it (`holdout` rows); it is never part of `all`.
|
||||
/// Rows `pool-<stage>` (plan D2 Eichschleife): the persona of the calibrated real pool, from the file in
|
||||
/// `POOL_PERSONA` (`lesen/pool.py persona`). Own draw and deal seeds.
|
||||
const POOL_DRAW_SEED: u64 = 0x9001_D2A9_0000;
|
||||
const POOL_SEED: u64 = 0x9001_5EED;
|
||||
const HOLDOUT_DRAW_SEED: u64 = 0x4011_D0D0_0000;
|
||||
const HOLDOUT_SEED: u64 = 0x4011_D0D0_5EED;
|
||||
|
||||
@@ -146,6 +150,13 @@ fn cell(name: &str, k: u64, welt_deals: u32, klassik_deals: u32) -> (Opponent, u
|
||||
let opp = Opponent::Welt(Persona::draw(i, Rng::seeded(DRAW_SEED + 1000 * i as u64 + k)).0);
|
||||
return (opp, welt_deals, WELT_SEED ^ (k + 1).wrapping_mul(0x9E37_79B9));
|
||||
}
|
||||
if name.starts_with("pool-") {
|
||||
let pfad = std::env::var("POOL_PERSONA").unwrap_or_else(|_| panic!("Zeile {name} braucht POOL_PERSONA"));
|
||||
let text = std::fs::read_to_string(&pfad).unwrap_or_else(|e| panic!("POOL_PERSONA {pfad}: {e}"));
|
||||
let m = Persona::from_pool_json(&text).unwrap_or_else(|e| panic!("{e}"));
|
||||
let opp = Opponent::Welt(Persona::draw_pool(m, Rng::seeded(POOL_DRAW_SEED + k)).0);
|
||||
return (opp, welt_deals, POOL_SEED ^ (k + 1).wrapping_mul(0x9E37_79B9));
|
||||
}
|
||||
if name == "micro-passiv" {
|
||||
// Own draw and deal seeds: a new individual and new cards per k, the world rows unchanged.
|
||||
let opp = Opponent::Welt(Persona::draw_micro(Rng::seeded(MICRO_DRAW_SEED + k)).0);
|
||||
|
||||
@@ -276,6 +276,59 @@ impl Persona {
|
||||
Persona::draw_around(Persona::micro_passiv(), false, rng)
|
||||
}
|
||||
|
||||
/// The persona of a calibrated real pool (plan D2 Eichschleife, `lesen/pool.py persona`): the micro
|
||||
/// pool as base, every field the JSON names replaced (`call_margin raise_at bet_at open_at bluff size
|
||||
/// lo hi noise cbet_call three_bet_continue check_raise`, `oracle` as [vpip, pfr, foldToBet,
|
||||
/// aggression], `label`). Unknown keys are an error, so a typo never silently plays the base.
|
||||
pub fn from_pool_json(text: &str) -> Result<Persona, String> {
|
||||
use crate::json::value::Value;
|
||||
let v = crate::json::parse::parse(text).map_err(|e| format!("{e:?}"))?;
|
||||
let Value::Object(felder) = v else { return Err("pool persona: object expected".into()) };
|
||||
let mut p = Persona::micro_passiv();
|
||||
for (k, x) in felder {
|
||||
let zahl = || match x {
|
||||
Value::Number(n) if n.is_finite() => Ok(n),
|
||||
_ => Err(format!("pool persona: {k} must be a number")),
|
||||
};
|
||||
match k.as_str() {
|
||||
"call_margin" => p.rules.call_margin = zahl()?,
|
||||
"raise_at" => p.rules.raise_at = zahl()?,
|
||||
"bet_at" => p.rules.bet_at = zahl()?,
|
||||
"open_at" => p.rules.open_at = zahl()?,
|
||||
"bluff" => p.rules.bluff = zahl()?,
|
||||
"size" => p.rules.size = zahl()?,
|
||||
"lo" => p.lo = zahl()?,
|
||||
"hi" => p.hi = zahl()?,
|
||||
"noise" => p.noise = zahl()?,
|
||||
"cbet_call" => p.cbet_call = zahl()?,
|
||||
"three_bet_continue" => p.three_bet_continue = zahl()?,
|
||||
"check_raise" => p.check_raise = zahl()?,
|
||||
"oracle" => match &x {
|
||||
Value::Array(a) if a.len() == 4 => {
|
||||
for (i, e) in a.iter().enumerate() {
|
||||
let Value::Number(n) = e else { return Err("pool persona: oracle numbers".into()) };
|
||||
p.oracle[i] = *n;
|
||||
}
|
||||
}
|
||||
_ => return Err("pool persona: oracle = [vpip, pfr, foldToBet, aggression]".into()),
|
||||
},
|
||||
"label" => match &x {
|
||||
Value::String(s) => p.label = Box::leak(s.clone().into_boxed_str()),
|
||||
_ => return Err("pool persona: label must be a string".into()),
|
||||
},
|
||||
// informational fields of lesen/pool.py (version, targets) are allowed
|
||||
_ if k.starts_with('_') => {}
|
||||
other => return Err(format!("pool persona: unknown field {other}")),
|
||||
}
|
||||
}
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
/// One individual of a calibrated pool persona (`from_pool_json`), perturbed like a world archetype.
|
||||
pub fn draw_pool(m: Persona, rng: Rng) -> (Persona, Rng) {
|
||||
Persona::draw_around(m, false, rng)
|
||||
}
|
||||
|
||||
fn draw_around(m: Persona, control: bool, rng: Rng) -> (Persona, Rng) {
|
||||
let r = m.rules;
|
||||
let (call_margin, rng) = jitter(r.call_margin, 0.04, 0.0, 0.45, rng);
|
||||
@@ -735,4 +788,18 @@ mod tests {
|
||||
}
|
||||
assert!(seen.iter().all(|c| *c > 150), "{seen:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pool_persona_overrides_and_rejects_typos() {
|
||||
let p = Persona::from_pool_json(r#"{"call_margin":0.2,"cbet_call":0.1,"oracle":[0.3,0.2,0.55,0.3],"label":"pool-x","_version":"v1"}"#).unwrap();
|
||||
assert_eq!(p.rules.call_margin, 0.2);
|
||||
assert_eq!(p.cbet_call, 0.1);
|
||||
assert_eq!(p.oracle, [0.3, 0.2, 0.55, 0.3]);
|
||||
assert_eq!(p.label, "pool-x");
|
||||
assert_eq!(p.rules.bet_at, Persona::micro_passiv().rules.bet_at, "unnamed fields keep the micro base");
|
||||
assert!(Persona::from_pool_json(r#"{"call_margn":0.2}"#).is_err());
|
||||
let a = Persona::draw_pool(p, Rng::seeded(3)).0;
|
||||
let b = Persona::draw_pool(p, Rng::seeded(3)).0;
|
||||
assert_eq!(a.rules.call_margin, b.rules.call_margin, "deterministic per seed");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user