stapel_preis: Test gegen die echte Tafel (Umgebungsvariable STAPEL_TAFEL_ECHT) und die vier Haende
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -646,4 +646,66 @@ mod spec {
|
||||
assert_eq!(urteil_a("FOLD", 0.60, 400.0, Some(0.2), 0.36, 1.0, 0.30).map(|x| x.0), Some("CALL"));
|
||||
assert_eq!(urteil_a("CALL", 0.10, 0.0, Some(0.5), 0.36, 1.0, 0.9), None, "n = 0: kein Vertrauen");
|
||||
}
|
||||
|
||||
// ---- echte Tafel (Umgebungsvariable STAPEL_TAFEL_ECHT = Pfad; fehlt sie oder die Datei, wird uebersprungen)
|
||||
fn karte(s: &str) -> u8 {
|
||||
let b = s.as_bytes();
|
||||
let r = "23456789TJQKA".find(b[0] as char).unwrap();
|
||||
let f = "cdhs".find(b[1] as char).unwrap();
|
||||
(r * 4 + f) as u8
|
||||
}
|
||||
fn brett_von(s: &str) -> Vec<u8> {
|
||||
s.split_whitespace().map(karte).collect()
|
||||
}
|
||||
fn rang_von(hand: &str, brett: &str) -> f32 {
|
||||
let hh = brett_von(hand);
|
||||
crate::nachrechnen::rang_anteile(&[(hh[0].min(hh[1]), hh[0].max(hh[1]))], &brett_von(brett))[0]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn echte_tafel_lesen_und_vier_haende() {
|
||||
let Some(text) = std::env::var("STAPEL_TAFEL_ECHT").ok().and_then(|p| std::fs::read_to_string(p).ok()) else { return };
|
||||
let (ns, na) = (text.lines().filter(|z| z.starts_with("S ")).count(), text.lines().filter(|z| z.starts_with("A ")).count());
|
||||
let t = Tafel::lies(&text).unwrap();
|
||||
println!("Datei S {ns} A {na}; gelesen S {} A {} (Schluessel eindeutig)", t.s.len(), t.a.len());
|
||||
assert_eq!((t.s.len(), t.a.len()), (ns, na), "alle Zeilen lesbar");
|
||||
let alt = |a: &str, p: Option<f32>, r: &str| {
|
||||
let mut v = json!({"action": a, "size": null, "reason": r});
|
||||
if let Some(p) = p { v["stapel_eq"] = json!(p); }
|
||||
v
|
||||
};
|
||||
let mut q1 = hand1();
|
||||
q1["villains"][0]["profile"] = json!({});
|
||||
let r1 = rang_von("Ac 7c", "5d 6c Ah 7d 5h");
|
||||
let o = schicht_mit(&q1, json!({"action": "RAISE", "size": 93.0, "reason": "AllIn(9300) 100%"}), &|| r1, &t, 1.0);
|
||||
println!("Fall1 rang {r1:.3}: {} | {}", o["action"], o["reason"]);
|
||||
let r2 = rang_von("Js Ts", "Tc 2s 5h 5d");
|
||||
for (name, eq) in [("ohne Suche", None), ("Suche .50", Some(0.5)), ("Suche .40", Some(0.4))] {
|
||||
let o = schicht_mit(&hand2(0.22), alt("CALL", eq, "Fold 3%, Call 95%"), &|| r2, &t, 1.0);
|
||||
let l = lage_gegen_einsatz(&hand2(0.22)).unwrap();
|
||||
let z = suche(&t.s, l.schluessel);
|
||||
println!("Fall2 {name} rang {r2:.3} Zelle n {:?} gem {:?}: {} | {}", z.map(|z| z.n_gezeigt), z.and_then(|z| gewinnchance(r2, &z.h)), o["action"], o["reason"]);
|
||||
}
|
||||
let q3 = json!({"street": "RIVER", "pot": 35.5, "toCall": 0.0, "heroStack": 21.5, "maxRaiseTo": 21.5, "minRaiseTo": 1.0, "heroSeat": 1, "bigBlind": 1.0,
|
||||
"legalActions": ["CHECK", "RAISE"], "villains": [{"seat": 2, "stack": 60.0, "folded": false, "profile": {"vpip": 0.35, "hands": 300}}],
|
||||
"history": [h("PREFLOP", 1, "RAISE", 3.0), h("PREFLOP", 2, "CALL", 3.0), h("FLOP", 2, "CHECK", 0.0), h("FLOP", 1, "BET", 3.0), h("FLOP", 2, "CALL", 3.0),
|
||||
h("TURN", 2, "CHECK", 0.0), h("TURN", 1, "BET", 6.0), h("TURN", 2, "CALL", 6.0), h("RIVER", 2, "CHECK", 0.0)]});
|
||||
let r3 = rang_von("Qs Jd", "Ts Ac 7d 7c 9d");
|
||||
let l3 = lage_eigener_einsatz(&q3, 21.5).unwrap();
|
||||
let za = suche(&t.a, l3.schluessel);
|
||||
let eqc = za.and_then(|z| gewinnchance(r3, &z.h));
|
||||
let o = schicht_mit(&q3, json!({"action": "RAISE", "size": 21.5, "reason": "AllIn(2150) 97%"}), &|| r3, &t, 1.0);
|
||||
println!("Fall3 rang {r3:.3} Zelle {:?} fold {:?} eq Caller {eqc:?}: {} | {}", za.map(|z| z.n_gezeigt), za.map(|z| z.quote), o["action"], o["reason"]);
|
||||
let q4 = json!({"street": "RIVER", "pot": 122.5, "toCall": 62.5, "heroStack": 62.5, "heroSeat": 1, "bigBlind": 1.0, "legalActions": ["FOLD", "CALL"],
|
||||
"villains": [{"seat": 2, "stack": 0.0, "folded": false, "profile": {}}],
|
||||
"history": [h("PREFLOP", 2, "RAISE", 3.0), h("PREFLOP", 1, "CALL", 3.0), h("FLOP", 1, "CHECK", 0.0), h("FLOP", 2, "BET", 2.0), h("FLOP", 1, "RAISE", 6.0), h("FLOP", 2, "CALL", 6.0),
|
||||
h("TURN", 1, "CHECK", 0.0), h("TURN", 2, "BET", 10.0), h("TURN", 1, "CALL", 10.0), h("RIVER", 1, "CHECK", 0.0), h("RIVER", 2, "ALL_IN", 62.5)]});
|
||||
let r4 = rang_von("Ad Js", "Kc As 8c Ac Qc");
|
||||
let l4 = lage_gegen_einsatz(&q4).unwrap();
|
||||
let z4 = suche(&t.s, l4.schluessel);
|
||||
for (p, eq) in [(21u32, 0.2f32), (40, 0.2)] {
|
||||
let o = schicht_mit(&q4, alt("FOLD", Some(eq), &format!("Fold {}%, Call {p}%", 100 - p)), &|| r4, &t, 1.0);
|
||||
println!("Fall4 Call {p}% rang {r4:.3} {:?} n {:?} gem {:?}: {} | {}", l4.schluessel, z4.map(|z| z.n_gezeigt), z4.and_then(|z| gewinnchance(r4, &z.h)), o["action"], o["reason"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user