Files
mmintelandClaude Opus 5.5 c8257b4248 Rake in der Live-Entscheidung hinter RAKE_LIVE (Stufe 1: Postflop), Mikro-Rake gemessen
Mikro-Tisch NL 0.01/0.02 aus 857 Haenden gemessen: 5 % auf den Cent (half-even), Deckel 10 bb,
kein no-flop-no-drop (RakeRule::MICRO_BB). rake::live: thread-lokaler Scope, nur Cash-Spots unter
RAKE_LIVE=1; ohne Scope ist net() die Identitaet -> aus = bit-gleich zu 62e51bb (1767 Postflop-
und 2776 Preflop-Spots byte-gleich).

Gerakt: odds::ev, break_even/MDF, Bluff-Zweige und Bluff-Schranke, River-Baum v1, river_game,
turn_river_game, open_jam, Audit (Jam/All-in). Simulator: SIM_RAKE=mikro (TableCost::MICRO).
chartgen charts --rake mikro (ChartRake::Micro) fuer Stufe 2 (Preflop-Tabellen, noch nicht verdrahtet).

Nachspiel: 20/1767 Aktionen kippen, Audit +21.94 bb fuer das Rake-Spiel (ein Turn-Spot +21.72),
River -1.73. Bericht und Schaltvorschlag: messung_rake/BERICHT.md. Specs rake_rule 22, rake_live 7 gruen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 00:58:53 +01:00

195 lines
6.8 KiB
Rust

//! Spezifikation der Rake-Rechnung. Die Zahlen stammen aus Händen des Tisches 1000/2000
//! (`game.winnerInfo`, `potAmount` gegen `potAmountAfterRake`); die Hand steht am Fall.
use rechner::rake::{split_over_pots, uncalled, ChartRake, HandEnd, RakeRule, MEASURED_ANTE_BB};
/// Der gemessene Tisch in seiner eigenen Währung.
const TABLE: RakeRule = RakeRule { percent: 5.0, cap: 2000.0, cap_more_than_three: 2000.0, ..RakeRule::MEASURED_BB };
fn near(a: f64, b: f64) {
assert!((a - b).abs() < 1e-9, "{a} != {b}");
}
// -- Eine Hand ------------------------------------------------------------------------------
#[test]
fn a_pot_under_the_cap_pays_five_percent_antes_included() {
// Hand 166457200019, Topf 4640 samt Antes: 232 Rake.
near(TABLE.of_hand(4640.0, 2, HandEnd::FlopDealt), 232.0);
}
#[test]
fn the_cap_stops_the_rake() {
// Hand 166408600402: Topf 191680, 2000 Rake.
near(TABLE.of_hand(191_680.0, 2, HandEnd::FlopDealt), 2000.0);
}
#[test]
fn the_cap_starts_exactly_at_twenty_big_blinds() {
near(TABLE.of_hand(39_999.0, 2, HandEnd::FlopDealt), 1999.95);
near(TABLE.of_hand(40_000.0, 2, HandEnd::FlopDealt), 2000.0);
near(TABLE.of_hand(40_001.0, 2, HandEnd::FlopDealt), 2000.0);
}
#[test]
fn heads_up_pays_the_same_as_three_players() {
assert_eq!(TABLE.of_hand(10_000.0, 2, HandEnd::FlopDealt), TABLE.of_hand(10_000.0, 3, HandEnd::FlopDealt));
}
#[test]
fn a_hand_that_ends_before_the_flop_pays_nothing() {
assert_eq!(TABLE.of_hand(21_600.0, 2, HandEnd::NoFlop), 0.0);
assert_eq!(TABLE.of_hand(1_000_000.0, 6, HandEnd::NoFlop), 0.0);
}
#[test]
fn more_than_three_players_use_their_own_cap_and_three_do_not() {
let rule = RakeRule { percent: 5.0, cap: 100.0, cap_more_than_three: 40.0, ..RakeRule::MEASURED_BB };
near(rule.of_hand(10_000.0, 3, HandEnd::FlopDealt), 100.0);
near(rule.of_hand(10_000.0, 4, HandEnd::FlopDealt), 40.0);
near(rule.of_hand(500.0, 4, HandEnd::FlopDealt), 25.0);
}
#[test]
fn an_empty_or_broken_pot_pays_nothing() {
assert_eq!(TABLE.of_hand(0.0, 2, HandEnd::FlopDealt), 0.0);
assert_eq!(TABLE.of_hand(-5.0, 2, HandEnd::FlopDealt), 0.0);
assert_eq!(TABLE.of_hand(f64::NAN, 2, HandEnd::FlopDealt), 0.0);
}
#[test]
fn the_measured_table_in_big_blinds_is_the_table_above() {
let bb = 2000.0;
for pot in [4640.0, 39_999.0, 191_680.0] {
near(RakeRule::MEASURED_BB.of_hand(pot / bb, 2, HandEnd::FlopDealt) * bb, TABLE.of_hand(pot, 2, HandEnd::FlopDealt));
}
near(MEASURED_ANTE_BB, 320.0 / bb);
}
// -- Side Pots ------------------------------------------------------------------------------
#[test]
fn the_cap_holds_per_hand_and_is_shared_in_proportion_to_the_pots() {
// Hand 166408600403: Töpfe 609640 und 574480, abgezogen 1029,69 und 970,31.
let pots = [609_640.0, 574_480.0];
let total = TABLE.of_hand(pots.iter().sum(), 2, HandEnd::FlopDealt);
let parts = split_over_pots(total, &pots);
near(total, 2000.0);
assert!((parts[0] - 1029.69).abs() < 0.01, "{}", parts[0]);
assert!((parts[1] - 970.31).abs() < 0.01, "{}", parts[1]);
near(parts.iter().sum(), 2000.0);
}
#[test]
fn nothing_to_split_stays_empty_or_zero() {
assert!(split_over_pots(100.0, &[]).is_empty());
assert_eq!(split_over_pots(100.0, &[0.0, 0.0]), vec![0.0, 0.0]);
assert_eq!(split_over_pots(100.0, &[50.0]), vec![100.0]);
}
#[test]
fn only_the_part_nobody_called_comes_back() {
assert_eq!(uncalled(&[10.0, 4.0, 4.0]), Some((0, 6.0)));
assert_eq!(uncalled(&[1.0, 8.0, 3.0]), Some((1, 5.0)));
assert_eq!(uncalled(&[5.0, 5.0]).map(|u| u.1), Some(0.0));
assert_eq!(uncalled(&[5.0]), None);
}
// -- Rake in den Chart-Spielen --------------------------------------------------------------
#[test]
fn no_rake_is_no_rake() {
assert_eq!(ChartRake::None.postflop(5.5), 0.0);
assert_eq!(ChartRake::None.all_in(200.0), 0.0);
}
#[test]
fn an_all_in_pays_the_exact_rule_on_the_pot() {
near(ChartRake::Measured.all_in(200.0), 1.0);
near(ChartRake::Measured.all_in(5.96), 0.05 * 5.96);
}
#[test]
fn a_pot_with_chips_behind_pays_what_such_pots_paid_at_the_table() {
// Mittlerer Rake je Flop-Topf (Topf samt Antes, aus 728 Händen; Kopf von `rake`).
near(ChartRake::Measured.postflop(4.0), 0.489);
near(ChartRake::Measured.postflop(6.46), 0.720);
near(ChartRake::Measured.postflop(10.0), 0.850);
near(ChartRake::Measured.postflop(19.46), 0.906);
near(ChartRake::Measured.postflop(60.0), 0.950);
}
#[test]
fn a_flop_pot_on_a_bucket_bound_belongs_to_the_next_bucket() {
near(ChartRake::Measured.postflop(6.0), 0.720);
}
#[test]
fn the_postflop_rake_never_shrinks_with_the_pot_and_never_passes_the_cap() {
let mut last = 0.0;
for k in 0..400 {
let r = ChartRake::Measured.postflop(k as f64 * 0.5);
assert!(r >= last && r <= 1.0, "{k}: {r}");
last = r;
}
}
// -- Der Live-Tisch NL 0.01/0.02 (`RakeRule::MICRO_BB`) ---------------------------------------
// Gemessen 15.11. an 857 Händen der Mikro-Läufe vom 14.11. (`potAmount` gegen `potAmountAfterRake`).
/// Der Mikro-Tisch in Cent: 1 bb = 0.02.
fn micro(pot: f64, end: HandEnd) -> f64 {
RakeRule::MICRO_BB.of_hand(pot / 0.02, 2, end) * 0.02
}
#[test]
fn the_micro_table_takes_five_percent_rounded_to_the_cent() {
// Hand für Hand gemessen: 0.11 -> 0.01, 0.33 -> 0.02, 3.38 -> 0.17.
near(micro(0.11, HandEnd::FlopDealt), 0.01);
near(micro(0.33, HandEnd::FlopDealt), 0.02);
near(micro(3.38, HandEnd::FlopDealt), 0.17);
}
#[test]
fn half_a_cent_rounds_to_even() {
// 0.10 -> 0.005 -> 0 (15 Hände gemessen, alle ohne Rake); 0.30 -> 0.015 -> 0.02.
near(micro(0.10, HandEnd::FlopDealt), 0.0);
near(micro(0.30, HandEnd::FlopDealt), 0.02);
}
#[test]
fn the_micro_cap_is_ten_big_blinds() {
near(micro(4.03, HandEnd::FlopDealt), 0.20);
near(micro(7.99, HandEnd::FlopDealt), 0.20);
near(RakeRule::MICRO_BB.of_hand(1000.0, 6, HandEnd::FlopDealt), 10.0);
}
#[test]
fn at_the_micro_table_a_pot_without_flop_pays_too() {
// 50 von 428 Händen ohne Flop zahlten: jeder Topf ab 0.11.
near(micro(0.13, HandEnd::NoFlop), 0.01);
near(micro(0.41, HandEnd::NoFlop), 0.02);
near(micro(0.03, HandEnd::NoFlop), 0.0);
}
#[test]
fn the_measured_big_table_is_unchanged_by_the_micro_fields() {
assert_eq!(RakeRule::MEASURED_BB.step, 0.0);
assert!(RakeRule::MEASURED_BB.no_flop_no_drop);
assert_eq!(RakeRule::MEASURED_BB.of_hand(5.96, 2, HandEnd::FlopDealt), 0.05 * 5.96);
}
#[test]
fn the_micro_chart_rake_rises_with_the_pot_up_to_the_cap() {
near(ChartRake::Micro.all_in(200.0), 10.0);
near(ChartRake::Micro.all_in(5.5), 0.5);
near(ChartRake::Micro.postflop(6.5), 0.808);
near(ChartRake::Micro.postflop(20.0), 2.061);
let mut last = 0.0;
for k in 0..400 {
let r = ChartRake::Micro.postflop(k as f64 * 0.5);
assert!(r >= last && r <= 10.0, "{k}: {r}");
last = r;
}
}