rake-live: Entscheidungs-Rake glatt (5 %, ohne Cent-Stufe), Diagnose station

Die Cent-Stufe im Entscheidungsmodell setzte kuenstliche 0.5-bb-Spruenge zwischen Nachbargroessen
und trieb Value-Bets gegen die station auf die kleine Groesse (Leiter -0.16 +-0.16). DECISION_RULE =
MICRO_BB ohne step; der Simulator-Tisch behaelt die Cents. diag_rake + diag_diff.py zerlegen die
Wirkung je Hand. Aus bleibt bit-gleich zu 43e566f. Nachmessung rake-glatt-* eingereiht.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 11:39:22 +01:00
co-authored by Claude Opus 5.5
parent 28db90805f
commit e6c2ff4f5d
6 changed files with 172 additions and 23 deletions
+20
View File
@@ -114,3 +114,23 @@ Die Specs liefen einzeln, nicht über `tests/lauf.py`.
- `nachspiel_postflop.md`: der Einzelnachweis.
- `*_anfragen.jsonl`, `post_*.jsonl`, `pre_*.jsonl`: Eingaben und Antworten.
- `bin/pokerbench-rake-*.exe`: Mess-Binaries.
## 8. Urteil der ersten Messung und Nachbesserung (15.11. mittags)
Erste Messung mit Cent-Stufe im Entscheidungs-Rake (`URTEIL.md`):
- Leiter gesamt **+4.43 ±1.01 bb/100**: 12 Gegner gewinnen, 7 offen, **station −0.16 ±0.16 ist Verlierer**.
- LBR an−aus −64.3 ±69.6, also nicht schlechter.
- Nach der Regel bleibt der Schalter damit aus.
**Ursache, zerlegt mit `diag_rake station` mit und ohne Schalter, verglichen mit `diag_diff.py`:**
- Das Orakel-Lesen gegen die station reproduziert den Verlust: −0.19 bb/100.
- **Fast alles sind River- und Turn-Value-Bets, die auf die kleinere Größe wechseln**, z. B. Topf 13.89: 9.26 → 4.63, Topf 2: 2 → 1.33.
- Zwei Gründe:
1. Die **Cent-Stufe** im Entscheidungsmodell. Ein Pot-Bet in 2 bb zahlte gerundet 0.5 bb, zwei Drittel Pot zahlten 0. Das sind künstliche EV-Sprünge zwischen Nachbargrößen. Am Tisch ist die Rundung echt. Aber die Entscheidung kennt den Endtopf nicht, und über diese Unsicherheit mittelt sich die Rundung weg. Behoben mit `rake::live::DECISION_RULE`: 5 % glatt, Deckel 10 bb. Das halbiert die geänderten Hände (46 → 16).
2. Der Rest, −0.05 bb/100 ohne Größenmix: Das Modell setzt die Equity im gecallten Fall gegen die station pessimistisch an, etwa 0.53. Mit 5 % Rake lohnen die Zusatz-Chips eines großen Value-Bets dann kaum noch (2·0.53·0.95 ≈ 1). Das ist kein Rake-Fehler. Der Rake legt eine Modellschwäche frei, nämlich die Spanne, mit der die station callt.
- Ausgeschaltet ist der Kern weiter byte-gleich mit 43e566f.
**Nachmessung eingereiht:**
- `rake-glatt-an` gegen das fertige `rake-basis`, mit FRUEHSTOPP.
- `rake-glatt-lbr-an` gegen das fertige `rake-lbr-aus`.
- Auswertung: `python messung_rake/auswerten.py glatt`.
+12 -5
View File
@@ -1,6 +1,7 @@
"""Urteil RAKE_LIVE Stufe 1: Leiter gepaart am Mikro-Tisch + LBR gepaart, mit Schaltvorschlag.
python messung_rake/auswerten.py (Pfade fest: arme/rake-basis, arme/rake-an, lbr/rake-lbr-*.txt)
python messung_rake/auswerten.py glatt (an-Arm = arme/rake-glatt-an, lbr/rake-glatt-lbr-an.txt)
Leiter: `messung_engine/ab.py` (je Gegner Delta an - basis in bb/100, 95 %-KI, gepoolt, Urteil).
LBR: je Hand `i wert_bb` (was der beste lokale Konter gegen den Kern gewinnt); gepaart ueber `i`
@@ -39,14 +40,16 @@ def mittel_ki(xs):
def main():
sys.stdout.reconfigure(encoding="utf-8")
basis, an = os.path.join(HIER, "arme", "rake-basis"), os.path.join(HIER, "arme", "rake-an")
print("# RAKE_LIVE Stufe 1: Urteil\n")
arm = "rake-glatt-an" if sys.argv[1:] == ["glatt"] else "rake-an"
lbr_an = "rake-glatt-lbr-an.txt" if arm == "rake-glatt-an" else "rake-lbr-an.txt"
basis, an = os.path.join(HIER, "arme", "rake-basis"), os.path.join(HIER, "arme", arm)
print(f"# RAKE_LIVE Stufe 1: Urteil ({arm})\n")
print("## Leiter am Mikro-Tisch (SIM_RAKE=mikro), an - basis\n")
leiter = subprocess.run([sys.executable, AB, basis, an], capture_output=True, text=True, encoding="utf-8", env=dict(os.environ, PYTHONIOENCODING="utf-8"))
print("```\n" + leiter.stdout.strip() + ("\n" + leiter.stderr.strip() if leiter.stderr.strip() else "") + "\n```\n")
verlierer = "VERLIERER" in leiter.stdout
aus, ein = lbr(os.path.join(HIER, "lbr", "rake-lbr-aus.txt")), lbr(os.path.join(HIER, "lbr", "rake-lbr-an.txt"))
aus, ein = lbr(os.path.join(HIER, "lbr", "rake-lbr-aus.txt")), lbr(os.path.join(HIER, "lbr", lbr_an))
gemeinsam = sorted(set(aus) & set(ein))
ma, ka, na = mittel_ki(list(aus.values()))
me, ke, ne = mittel_ki(list(ein.values()))
@@ -60,8 +63,12 @@ def main():
print("## Urteil\n")
print(f"- Leiter: {'VERLIERER (mind. eine Zeile oder gesamt sicher unter 0)' if verlierer else 'kein Verlierer'}")
print(f"- LBR: {'SCHLECHTER (KI ganz ueber 0)' if lbr_schlechter else 'nicht schlechter'}")
if verlierer or lbr_schlechter:
print("- **Vorschlag: RAKE_LIVE bleibt aus.** Erst die Verlierer-Zeile(n) verstehen (Kandidat: River-Bluff-Schranke, dort zeigte das Audit den einzigen Verlust).")
zellen = lambda d: sorted(os.listdir(d)) if os.path.isdir(d) else []
vollstaendig = zellen(an) and zellen(an) == zellen(basis) and nd >= 2000 and "GESAMT" in leiter.stdout
if not vollstaendig:
print(f"- **UNVOLLSTAENDIG** (an-Zellen {len(zellen(an))}/{len(zellen(basis))}, LBR gepaart {nd}/2000): kein Urteil.")
elif verlierer or lbr_schlechter:
print("- **Vorschlag: RAKE_LIVE bleibt aus.** Erst die Verlierer-Zeile(n) mit `diag_rake` + `diag_diff.py` zerlegen (BERICHT.md 8).")
else:
print("- **Vorschlag: RAKE_LIVE=1 live setzen** (Zweig claude/rake-live, aus bitgleich). Stufe 2 (Preflop-Tabellen Mikro ohne Antes) folgt von preflop-voll.")
+51
View File
@@ -0,0 +1,51 @@
"""Diff zweier diag_rake-Ausgaben (aus, an): je Hand mit anderer Entscheidungsfolge die erste
abweichende Entscheidung, Netto-Delta (an - aus, bb) summiert nach Strasse und Richtung.
python messung_rake/diag_diff.py <aus.txt> <an.txt> [beispiele]
"""
import collections
import sys
def lies(p):
out = []
for z in open(p, encoding="utf-8"):
t = z.split()
out.append((float(t[2]), t[3:]))
return out
def art(c):
return c[0] if c[0] != "R" else "R"
def main():
a, b = lies(sys.argv[1]), lies(sys.argv[2])
n_bsp = int(sys.argv[3]) if len(sys.argv) > 3 else 12
summe = collections.defaultdict(lambda: [0, 0.0])
bsp = collections.defaultdict(list)
gesamt = 0.0
for i, ((na, da), (nb, db)) in enumerate(zip(a, b)):
gesamt += nb - na
if da == db:
continue
k = next(j for j in range(max(len(da), len(db))) if j >= len(da) or j >= len(db) or da[j] != db[j])
x = da[k].split(":") if k < len(da) else ["-"] * 5
y = db[k].split(":") if k < len(db) else ["-"] * 5
schl = (x[0], f"{art(x[3])}->{art(y[3])}" if x[0] != "-" and y[0] != "-" else "laenge")
summe[schl][0] += 1
summe[schl][1] += nb - na
bsp[schl].append(f"hand {i}: aus {' '.join(da[k:])} | an {' '.join(db[k:])} | delta {nb - na:+.2f}")
h = len(a)
print(f"Haende {h}, Delta gesamt {gesamt:+.2f} bb = {100 * gesamt / h:+.3f} bb/100\n")
print("| Strasse | aus->an | Haende | Delta bb | bb/100 |\n|---|---|---|---|---|")
for s, (n, d) in sorted(summe.items(), key=lambda kv: kv[1][1]):
print(f"| {s[0]} | {s[1]} | {n} | {d:+.2f} | {100 * d / h:+.3f} |")
for s, (n, d) in sorted(summe.items(), key=lambda kv: kv[1][1])[:3]:
print(f"\n### {s}")
for e in bsp[s][:n_bsp]:
print("- " + e)
if __name__ == "__main__":
main()
+60
View File
@@ -0,0 +1,60 @@
//! Where does `RAKE_LIVE` change hero's play against one opponent? Plays the same deals at the raked
//! micro table (`TableCost::MICRO`) on the traced path and prints one line per hand: deal, seat,
//! luck-corrected net (bb) and every hero decision (street, pot, to_call, choice, equity). Run it
//! once without and once with `RAKE_LIVE=1` and diff the two outputs (`messung_rake/diag_diff.py`).
//!
//! Run: `diag_rake <opponent: station|fish|reg|nit|maniac|gto> [deals]`, oracle read.
use rechner::game::Choice;
use rechner::rng::Rng;
use rechner::sim::opponent::Opponent;
use rechner::sim::reader::Style;
use rechner::sim::table::{deal, play_hand_traced, HandRead, HandSetup, TableCost};
const SEED: u64 = 0x5EED_4A4E;
fn mix(seed: u64, n: u64) -> u64 {
Rng::seeded(seed ^ n.wrapping_mul(0xD1B5_4A32_D192_ED03)).next_u64().0
}
fn main() {
let a: Vec<String> = std::env::args().collect();
let opponent = match a.get(1).map(String::as_str) {
Some("station") | None => Opponent::CallingStation,
Some("fish") => Opponent::Reader(Style::Fish),
Some("reg") => Opponent::Reader(Style::Reg),
Some("nit") => Opponent::Reader(Style::Nit),
Some("maniac") => Opponent::Reader(Style::Maniac),
Some("gto") => Opponent::Reader(Style::Gto),
Some(o) => panic!("unknown opponent {o}"),
};
let deals: u64 = a.get(2).and_then(|s| s.parse().ok()).unwrap_or(4000);
for d in 0..deals {
let (cards, _) = deal(2, Rng::seeded(mix(SEED, d)));
for hero_seat in 1..=2u8 {
let hand = HandSetup {
deal: &cards,
hero_seat,
opponent,
stack_bb: 100.0,
seed: mix(SEED ^ 0xA5A5, d << 8 | hero_seat as u64),
read: HandRead::Oracle,
};
let (res, trace) = play_hand_traced(&hand, TableCost::MICRO);
let decs: Vec<String> = trace
.iter()
.map(|x| {
let c = match x.choice {
Choice::Fold => "F".to_string(),
Choice::Check => "X".to_string(),
Choice::Call => "C".to_string(),
Choice::Raise { to } => format!("R{to:.2}"),
Choice::Abstain => "A".to_string(),
};
format!("{:?}:{:.2}:{:.2}:{}:{}", x.street, x.pot, x.to_call, c, x.equity.map_or("-".into(), |e| format!("{e:.3}")))
})
.collect();
println!("{d} {hero_seat} {:.4} {}", res.hero_net - res.luck, decs.join(" "));
}
}
}
+19 -11
View File
@@ -16,14 +16,24 @@
//! **Model.** The rake of a pot is the rule applied to the pot as it would end *now* (heads-up cap,
//! flop dealt or not makes no difference at this stake). Later streets are not modelled, exactly as
//! the EV formulas of `odds::ev` do not model them.
//!
//! **Smooth, not to the cent.** The table rounds to the cent (0.5 bb), but a decision does not know
//! the pot the hand will end with, and over that uncertainty the rounding averages out: the expected
//! rake is 5 % of the pot up to the cap (`DECISION_RULE`). Pricing the rounded step instead puts
//! artificial jumps of 0.5 bb between neighbouring sizes (a pot bet into 2 bb paid 0.5, two thirds
//! paid 0) and pushed value bets to the smaller size: measured against the station, −0.19 bb/100
//! (`messung_rake/URTEIL.md`). The simulator's table (`TableCost::MICRO`) keeps the exact cents.
use super::{HandEnd, RakeRule};
use std::cell::Cell;
use std::sync::OnceLock;
/// The rule the live tables take (big blinds).
/// The rule the live tables take (big blinds), to the cent.
pub const LIVE_RULE: RakeRule = RakeRule::MICRO_BB;
/// The rule a decision prices with: the live rule without the rounding step (its expectation).
pub const DECISION_RULE: RakeRule = RakeRule { step: 0.0, ..LIVE_RULE };
/// `RAKE_LIVE=1` switches the rake into the live decision. Read once per process.
pub fn enabled() -> bool {
static ON: OnceLock<bool> = OnceLock::new();
@@ -76,7 +86,7 @@ pub fn active() -> bool {
pub fn of_pot(pot: f64) -> f64 {
match BIG_BLIND.with(Cell::get) {
None => 0.0,
Some(bb) if pot.is_finite() && pot > 0.0 => LIVE_RULE.of_hand(pot / bb, 2, HandEnd::FlopDealt) * bb,
Some(bb) if pot.is_finite() && pot > 0.0 => DECISION_RULE.of_hand(pot / bb, 2, HandEnd::FlopDealt) * bb,
Some(_) => 0.0,
}
}
@@ -107,13 +117,11 @@ mod tests {
}
#[test]
fn the_micro_table_takes_five_percent_to_the_cent_capped_at_twenty_cents() {
fn a_decision_prices_five_percent_smooth_capped_at_twenty_cents() {
let _s = Scope::enter(0.02);
near(of_pot(0.10), 0.0); // 0.005 -> half to even -> 0
near(of_pot(0.11), 0.01);
near(of_pot(0.33), 0.02);
near(of_pot(1.56), 0.08);
near(of_pot(3.38), 0.17);
near(of_pot(0.10), 0.005);
near(of_pot(0.33), 0.0165);
near(of_pot(3.38), 0.169);
near(of_pot(4.03), 0.20);
near(of_pot(50.0), 0.20);
near(net(1.0), 0.95);
@@ -134,10 +142,10 @@ mod tests {
}
#[test]
fn in_big_blinds_the_cent_is_half_a_big_blind() {
fn in_big_blinds_neighbouring_sizes_pay_no_step() {
let _s = Scope::enter(1.0);
near(of_pot(5.0), 0.0);
near(of_pot(5.5), 0.5);
near(of_pot(4.67), 0.2335);
near(of_pot(6.0), 0.3);
near(of_pot(20.0), 1.0);
near(of_pot(400.0), 10.0);
}
+10 -7
View File
@@ -29,9 +29,10 @@ fn without_a_scope_every_price_is_the_raw_one_to_the_bit() {
#[test]
fn in_the_scope_a_call_needs_the_price_of_the_pot_after_rake() {
let _s = Scope::enter(0.02);
// Topf 0.20 + Call 0.10 = 0.30, Rake 0.02 (0.015 -> gerade 0.02): break-even 0.10 / 0.28.
near(break_even(0.20, 0.10), 0.10 / 0.28);
near(ev::call(0.5, 0.20, 0.10), 0.5 * 0.28 - 0.10);
// Topf 0.20 + Call 0.10 = 0.30, erwarteter Rake 5 % = 0.015 (glatt, nicht auf den Cent):
// break-even 0.10 / 0.285.
near(break_even(0.20, 0.10), 0.10 / 0.285);
near(ev::call(0.5, 0.20, 0.10), 0.5 * 0.285 - 0.10);
near(ev::check(0.5, 0.20), 0.5 * 0.19);
}
@@ -43,10 +44,12 @@ fn a_pot_won_by_a_fold_is_raked_too() {
}
#[test]
fn a_tiny_pot_pays_nothing_and_a_big_one_the_cap() {
fn the_decision_rake_is_smooth_up_to_the_cap() {
let _s = Scope::enter(1.0);
near(of_pot(4.0), 0.0);
near(net(4.0), 4.0);
// Keine Cent-Stufe zwischen Nachbargroessen (die Stufe trieb Value-Bets auf die kleine Groesse).
near(of_pot(4.67), 0.2335);
near(of_pot(6.0), 0.3);
near(net(4.0), 3.8);
near(of_pot(1000.0), 10.0);
}
@@ -96,7 +99,7 @@ fn in_the_scope_every_river_leaf_pays_the_rake_of_its_pot() {
_ => None,
})
.collect();
// check-check 30 -> 1.5 (half-even: 3 Halbe -> 1.5), Fold-Toepfe 30 -> 1.5, gecallt 70 -> 3.5.
// check-check 30 -> 1.5, Fold-Toepfe 30 -> 1.5, gecallt 70 -> 3.5.
assert_eq!(rakes.len(), 5);
assert!(rakes.iter().all(|r| [1.5, 3.5].contains(r)), "{rakes:?}");
let g = build(3, vec![1.0 / 9.0; 9], &Bets::standard(30.0, 100.0, 0), &[]);