Sicherung 01.12.: ungesicherte Dateien aus Worktree C:\Users\marcm\pokerfreak-zwilling\iter-baum3 (Zweig (detached), HEAD a893f9eb)
1 Dateien. Nicht enthalten: 0 Dateien (Bau, Binaer, > 25 MB, archiv/lauf, Spuren echter Haende), 0 Loeschungen nicht nachgezogen. Der Worktree selbst ist unveraendert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+103
-25
@@ -507,11 +507,13 @@ fn vorflop_wahl(p: [f64; 5], u: f64, darf_raise: bool, gegen: bool) -> char {
|
||||
}
|
||||
}
|
||||
|
||||
/// Gemessene Vorflop-Range (`messung/zwilling/vorflop_range.py bauen`): je (Position, eigener Pfad, Lage, Art)
|
||||
/// die Likelihood L_art(c) ueber die 169 Klassen; P(art | c) = P_zwilling(art) * L_art(c), Fold = Rest.
|
||||
/// Gemessene Vorflop-Range (`messung/zwilling/vorflop_range.py bauen`, v2): je (Position, eigener Pfad, Lage, Art)
|
||||
/// die Population P(art) und die Likelihood L_art(c) ueber die 169 Klassen, dazu (Art `*`) die Ankunfts-Range am
|
||||
/// Knoten. Population P(art | c) = P(art) * L_art(c), Fold = Rest; je Typ wird sie minimal-KL gekippt
|
||||
/// (exponentielle Neigung je Art, IPF ueber die Ankunfts-Range), bis die Anteile des Typ-Bandes stimmen.
|
||||
pub struct VorflopTab {
|
||||
klassen: HashMap<String, usize>,
|
||||
zeilen: HashMap<(String, String, String, char), Vec<f64>>,
|
||||
zeilen: HashMap<(String, String, String, char), (f64, Vec<f64>)>,
|
||||
}
|
||||
|
||||
fn vorflop_tabelle() -> Option<&'static VorflopTab> {
|
||||
@@ -531,8 +533,10 @@ fn vorflop_tabelle() -> Option<&'static VorflopTab> {
|
||||
}
|
||||
let t: Vec<&str> = z.split('\t').collect();
|
||||
let pf = if t[1] == "-" { String::new() } else { t[1].to_string() };
|
||||
let pa: f64 = t[5].parse().expect("ZWILLING_VORFLOP P");
|
||||
let l: Vec<f64> = t[6].split_whitespace().map(|x| x.parse().expect("ZWILLING_VORFLOP L")).collect();
|
||||
zeilen.insert((t[0].to_string(), pf, t[2].to_string(), t[3].chars().next().unwrap()), l);
|
||||
assert_eq!(l.len(), 169, "ZWILLING_VORFLOP: 169 Werte je Zeile");
|
||||
zeilen.insert((t[0].to_string(), pf, t[2].to_string(), t[3].chars().next().unwrap()), (pa, l));
|
||||
}
|
||||
assert_eq!(klassen.len(), 169, "ZWILLING_VORFLOP: Kopfzeile # klassen fehlt");
|
||||
Some(VorflopTab { klassen, zeilen })
|
||||
@@ -550,37 +554,111 @@ fn klasse169(hole: &[Card; 2]) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
/// Anteile [f, x, c, r, a] der Hand am Knoten aus der gemessenen Range; None ohne Zeilen fuer eine Art mit
|
||||
/// nennenswertem Anteil (dann bleibt das Band).
|
||||
fn vorflop_klassen_p(t: &VorflopTab, pos: &str, pfad: &str, lage: &str, p: [f64; 5], hole: &[Card; 2]) -> Option<[f64; 5]> {
|
||||
let c = *t.klassen.get(&klasse169(hole))?;
|
||||
thread_local! {
|
||||
/// Kippung je (Knoten, Typ-Anteile): Anteile [f, c, r, a] fuer alle 169 Klassen.
|
||||
static VF_KIPP: std::cell::RefCell<HashMap<(String, String, String, [u64; 5]), Option<Vec<[f64; 4]>>>> =
|
||||
std::cell::RefCell::new(HashMap::new());
|
||||
}
|
||||
|
||||
/// Population am Knoten minimal-KL auf die Typ-Anteile `p` gekippt; None ohne Zeile fuer eine Art mit nennenswertem
|
||||
/// Anteil oder ohne Ankunfts-Range (dann bleibt das Band).
|
||||
fn vorflop_kippen(t: &VorflopTab, pos: &str, pfad: &str, lage: &str, p: [f64; 5]) -> Option<Vec<[f64; 4]>> {
|
||||
let [_, x, cc, r, a] = p;
|
||||
let mut q = [0.0f64; 5];
|
||||
let mut irgendeine = false;
|
||||
for (i, art, pa) in [(2usize, 'c', x + cc), (3, 'r', r), (4, 'a', a)] {
|
||||
if pa <= EPS {
|
||||
let k = |art: char| (pos.to_string(), pfad.to_string(), lage.to_string(), art);
|
||||
let reach = &t.zeilen.get(&k('*'))?.1;
|
||||
// Ziel der Kippung: an den Wurzel-Knoten (erste Entscheidung, kein Raise oder ein Raise ohne eigenes Zutun) die
|
||||
// Typ-Anteile des Bandes; tiefer (Limp-Reraise, gegen 3-Bet/4-Bet, kalt gegen 3-Bet) die gemessenen Anteile des
|
||||
// Knotens, dort passt das Band nicht (v2-Pruefstein: Limp-Reraise-Jam 0,22 gegen 0,01).
|
||||
let band = pfad.is_empty() && matches!(lage, "U0" | "U1" | "U2" | "V0" | "V1");
|
||||
let ziel = if band {
|
||||
[0.0, x + cc, r, a]
|
||||
} else {
|
||||
let pa = |art: char| t.zeilen.get(&k(art)).map_or(0.0, |z| z.0);
|
||||
[0.0, pa('c'), pa('r'), pa('a')]
|
||||
};
|
||||
// Arten mit Zeile werden gekippt; ohne Zeile und kleinem Anteil bleibt der Band-Anteil fest.
|
||||
let mut fest = [0.0f64; 4];
|
||||
let mut zeile: [Option<&(f64, Vec<f64>)>; 4] = [None; 4];
|
||||
for (i, art) in [(1usize, 'c'), (2, 'r'), (3, 'a')] {
|
||||
if ziel[i] <= EPS {
|
||||
continue;
|
||||
}
|
||||
match t.zeilen.get(&(pos.to_string(), pfad.to_string(), lage.to_string(), art)) {
|
||||
Some(l) => {
|
||||
q[i] = pa * l[c];
|
||||
irgendeine = true;
|
||||
}
|
||||
None if pa < 0.02 => q[i] = pa,
|
||||
match t.zeilen.get(&k(art)) {
|
||||
Some(z) => zeile[i] = Some(z),
|
||||
None if ziel[i] < 0.02 => fest[i] = ziel[i],
|
||||
None => return None,
|
||||
}
|
||||
}
|
||||
if !irgendeine {
|
||||
if zeile.iter().all(|z| z.is_none()) {
|
||||
return None;
|
||||
}
|
||||
let s = q[2] + q[3] + q[4];
|
||||
if s > 1.0 {
|
||||
for v in q.iter_mut().skip(2) {
|
||||
*v /= s;
|
||||
let frei = 1.0 - fest.iter().sum::<f64>();
|
||||
let mut tz = [0.0f64; 4];
|
||||
for i in 1..4 {
|
||||
if zeile[i].is_some() {
|
||||
tz[i] = ziel[i];
|
||||
}
|
||||
}
|
||||
q[0] = (1.0 - q[2] - q[3] - q[4]).max(0.0);
|
||||
Some(q)
|
||||
tz[0] = (frei - tz[1] - tz[2] - tz[3]).max(0.0);
|
||||
// Population je Klasse (Fold = Rest, nie ganz 0, damit die Kippung ihn erreichen kann)
|
||||
let mut pop = vec![[0.0f64; 4]; 169];
|
||||
for (c, q) in pop.iter_mut().enumerate() {
|
||||
let mut s = 0.0;
|
||||
for i in 1..4 {
|
||||
if let Some((pa, l)) = zeile[i] {
|
||||
q[i] = pa * l[c];
|
||||
s += q[i];
|
||||
}
|
||||
}
|
||||
if s > 1.0 {
|
||||
for v in q.iter_mut().skip(1) {
|
||||
*v /= s;
|
||||
}
|
||||
s = 1.0;
|
||||
}
|
||||
q[0] = (1.0 - s).max(1e-4);
|
||||
}
|
||||
let mut e = [1.0f64; 4];
|
||||
let mut out = vec![[0.0f64; 4]; 169];
|
||||
for _ in 0..200 {
|
||||
let mut m = [0.0f64; 4];
|
||||
for c in 0..169 {
|
||||
let s: f64 = (0..4).map(|i| if tz[i] > 0.0 { pop[c][i] * e[i] } else { 0.0 }).sum::<f64>().max(1e-300);
|
||||
for i in 0..4 {
|
||||
out[c][i] = if tz[i] > 0.0 { frei * pop[c][i] * e[i] / s } else { 0.0 };
|
||||
m[i] += reach[c] * out[c][i];
|
||||
}
|
||||
}
|
||||
let mut fehler = 0.0f64;
|
||||
for i in 0..4 {
|
||||
if tz[i] > 0.0 {
|
||||
fehler = fehler.max((m[i] - tz[i]).abs());
|
||||
e[i] *= tz[i] / m[i].max(1e-300);
|
||||
}
|
||||
}
|
||||
if fehler < 1e-7 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for q in out.iter_mut() {
|
||||
for i in 1..4 {
|
||||
q[i] += fest[i];
|
||||
}
|
||||
}
|
||||
Some(out)
|
||||
}
|
||||
|
||||
/// Anteile [f, x, c, r, a] der Hand am Knoten aus der gekippten gemessenen Range (x = 0, Check steckt in c);
|
||||
/// None, wenn das Band bleibt.
|
||||
fn vorflop_klassen_p(t: &VorflopTab, pos: &str, pfad: &str, lage: &str, p: [f64; 5], hole: &[Card; 2]) -> Option<[f64; 5]> {
|
||||
let c = *t.klassen.get(&klasse169(hole))?;
|
||||
let schl = (pos.to_string(), pfad.to_string(), lage.to_string(), p.map(f64::to_bits));
|
||||
VF_KIPP.with(|m| {
|
||||
let mut m = m.borrow_mut();
|
||||
let q = m.entry(schl).or_insert_with(|| vorflop_kippen(t, pos, pfad, lage, p)).as_ref()?;
|
||||
let [f, cc, r, a] = q[c];
|
||||
Some([f, 0.0, cc, r, a])
|
||||
})
|
||||
}
|
||||
|
||||
fn vorflop(z: &Zwilling, typ: &str, view: View, ctx: &Ctx, rng: Rng) -> (Act, Rng) {
|
||||
|
||||
Reference in New Issue
Block a user