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
+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);
}