Rake-Deckel nach Spielerzahl: RAKE_LIVE=sitze (Kern) und lesen/rake.regel_cent (Fremdpruefung Befund 3)
- Kern: RAKE_LIVE=sitze = wie 1 plus Deckel nach ausgeteilten Spielern (2: 5 Cent, 3-4: 12 Cent, 5+: 20 Cent). RAKE_LIVE=1 unveraendert: Identitaet 0/3000 (golive) und 0/1961 (eigen). Mit sitze nur Abweichungen bei 2-4 Spielern (27 Aktions-/Groessen-Kipps auf 4961 Anfragen, Liste in fremd-out/rake). - lesen/rake.py: deckel_cent/regel_cent; gegen den Raum 7550 eigene + 1953 hhDealer-Haende 0 Abweichungen (vorher 15 + 4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -85,3 +85,26 @@ def aus_tisch(topf_chips, zahlen, spieler=6, vorflop=False):
|
||||
def netto(topf_chips, zahlen, spieler=6, vorflop=False):
|
||||
"""Was von diesem Topf nach dem Rake des Tisches bleibt."""
|
||||
return round(float(topf_chips) - aus_tisch(topf_chips, zahlen, spieler, vorflop), 2)
|
||||
|
||||
|
||||
# --- Die Regel des Raums nach Spielerzahl (gemessen 23.11.2026, messung/fremd/4_regeln/ERGEBNIS.md) -----------
|
||||
# NL2 0.01/0.02, auch vor dem Flop: 5 % vom Topf, halber Cent zur geraden Zahl; Deckel nach den Spielern der Hand
|
||||
# (gegebene Haende = Sitzzeilen der Handhistorie): 5-6 Spieler 20 Cent, 3-4 Spieler 12 Cent, 2 Spieler 5 Cent.
|
||||
# 7.550 eigene und 1.953 hhDealer-Haende (ab 18.10.2026, ohne Ante) stimmen auf den Cent. Die Raumfelder
|
||||
# `rakeCap`/`rakeCapGT3` (0.12/0.05) decken sich nicht mit dieser Zuordnung - sie stehen in `aus_tisch`, die Regel hier gilt.
|
||||
DECKEL_CENT = {2: 5, 3: 12, 4: 12}
|
||||
DECKEL_CENT_VOLL = 20
|
||||
|
||||
|
||||
def deckel_cent(spieler):
|
||||
"""Deckel des Raums in Cent fuer eine Hand mit `spieler` Spielern (NL2)."""
|
||||
return DECKEL_CENT.get(int(spieler), DECKEL_CENT_VOLL)
|
||||
|
||||
|
||||
def regel_cent(topf_cent, spieler=6):
|
||||
"""Rake einer Hand in Cent nach der Regel des Raums: 5 % vom Topf (Antes zaehlen, Ungecalltes nicht),
|
||||
halber Cent zur geraden Zahl, Deckel nach Spielerzahl. `topf_cent` ganze Cent."""
|
||||
q, rest = divmod(int(topf_cent) * 5, 100)
|
||||
if rest * 2 > 100 or (rest * 2 == 100 and q % 2 == 1):
|
||||
q += 1
|
||||
return min(q, deckel_cent(spieler))
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@ impl Default for Opts {
|
||||
pub fn audit(spot: &Spot, taken: Taken, opts: Opts) -> Result<Audit, Skip> {
|
||||
// RAKE_LIVE: the audit prices the river game and the all-in prices net of the room's rake, as the
|
||||
// live decision does (`rake::live`). The turn+river game (`cfr::turn_river_game`) stays raw.
|
||||
let _rake = crate::rake::live::cash_scope(spot.big_blind);
|
||||
let _rake = crate::rake::live::cash_scope_seats(spot.big_blind, spot.seats);
|
||||
match spot.street {
|
||||
Street::River => audit_river(spot, taken, opts),
|
||||
Street::Turn => audit_turn(spot, taken, opts),
|
||||
|
||||
@@ -372,7 +372,7 @@ fn decide_one_inner(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
|
||||
// a tournament pays none, also a chip-linear one that plays the cash path below
|
||||
// (the scope is decided on the original situation). Off: no scope, nothing changes.
|
||||
let _rake = match lage {
|
||||
None => crate::rake::live::cash_scope(spot.big_blind),
|
||||
None => crate::rake::live::cash_scope_seats(spot.big_blind, spot.seats),
|
||||
Some(_) => crate::rake::live::enabled().then(crate::rake::live::Scope::none),
|
||||
};
|
||||
// Chip-lineares Geld (der Sieger nimmt alles, alle Verbliebenen gleich bezahlt, p1 > p2 = ... = pn):
|
||||
|
||||
+73
-4
@@ -8,6 +8,12 @@
|
||||
//! **Switch.** `RAKE_LIVE=1` (read once). Off by default: then no scope is ever entered, `net` returns
|
||||
//! its argument unchanged and every result is bit-identical to the engine without this module.
|
||||
//!
|
||||
//! **Seat cap (`RAKE_LIVE=sitze`).** The room's cap depends on the players dealt in (measured 23.11.,
|
||||
//! `messung/fremd/4_regeln/ERGEBNIS.md`, NL 0.01/0.02): 5-6 players 20 cents (10 bb), 3-4 players 12
|
||||
//! cents (6 bb), 2 players 5 cents (2.5 bb); 7550 own and 1953 hhDealer hands match to the cent.
|
||||
//! `RAKE_LIVE=sitze` is `RAKE_LIVE=1` plus that cap (the spot's `seats`, the players of the hand);
|
||||
//! with `RAKE_LIVE=1` and at five or more seats nothing differs from the flat 10 bb, bit for bit.
|
||||
//!
|
||||
//! **Scope.** The rake only exists at a cash table: `engine::decide::decide_with` enters a `Scope` for a
|
||||
//! spot without a tournament situation (tournaments pay no rake per pot). The scope is thread-local and
|
||||
//! restored on drop, so parallel simulations and nested decisions stay independent. Inside it the pot
|
||||
@@ -37,18 +43,37 @@ 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();
|
||||
*ON.get_or_init(|| std::env::var("RAKE_LIVE").as_deref() == Ok("1"))
|
||||
*ON.get_or_init(|| matches!(std::env::var("RAKE_LIVE").as_deref(), Ok("1") | Ok("sitze")))
|
||||
}
|
||||
|
||||
/// `RAKE_LIVE=sitze`: the cap follows the players of the hand (`cap_bb`). Read once per process.
|
||||
pub fn seat_cap_enabled() -> bool {
|
||||
static ON: OnceLock<bool> = OnceLock::new();
|
||||
*ON.get_or_init(|| std::env::var("RAKE_LIVE").as_deref() == Ok("sitze"))
|
||||
}
|
||||
|
||||
/// The room's cap in big blinds for a hand with `players` dealt in (NL 0.01/0.02: 20 / 12 / 5 cents).
|
||||
pub fn cap_bb(players: u8) -> f64 {
|
||||
match players {
|
||||
0 | 1 => LIVE_RULE.cap,
|
||||
2 => 2.5,
|
||||
3 | 4 => 6.0,
|
||||
_ => LIVE_RULE.cap,
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
/// Big blind of the cash spot being decided on this thread; `None` = no rake.
|
||||
static BIG_BLIND: Cell<Option<f64>> = const { Cell::new(None) };
|
||||
/// Players of the hand when the seat cap is on; `None` = the flat cap.
|
||||
static SEATS: Cell<Option<u8>> = const { Cell::new(None) };
|
||||
}
|
||||
|
||||
/// While alive, `net` and `of_pot` rake pots in chips of a table with this big blind.
|
||||
#[must_use]
|
||||
pub struct Scope {
|
||||
previous: Option<f64>,
|
||||
previous_seats: Option<u8>,
|
||||
}
|
||||
|
||||
impl Scope {
|
||||
@@ -56,18 +81,26 @@ impl Scope {
|
||||
/// rake.
|
||||
pub fn enter(big_blind: f64) -> Scope {
|
||||
let value = (big_blind.is_finite() && big_blind > 0.0).then_some(big_blind);
|
||||
Scope { previous: BIG_BLIND.with(|b| b.replace(value)) }
|
||||
Scope { previous: BIG_BLIND.with(|b| b.replace(value)), previous_seats: SEATS.with(|s| s.replace(None)) }
|
||||
}
|
||||
|
||||
/// Enter with the seat cap of a table with `players` dealt in (tests, `cash_scope`).
|
||||
pub fn enter_seats(big_blind: f64, players: u8) -> Scope {
|
||||
let scope = Scope::enter(big_blind);
|
||||
SEATS.with(|s| s.set(Some(players)));
|
||||
scope
|
||||
}
|
||||
|
||||
/// No rake inside, whatever the outer scope said (a tournament decision nested in a cash run).
|
||||
pub fn none() -> Scope {
|
||||
Scope { previous: BIG_BLIND.with(|b| b.replace(None)) }
|
||||
Scope { previous: BIG_BLIND.with(|b| b.replace(None)), previous_seats: SEATS.with(|s| s.replace(None)) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Scope {
|
||||
fn drop(&mut self) {
|
||||
BIG_BLIND.with(|b| b.set(self.previous));
|
||||
SEATS.with(|s| s.set(self.previous_seats));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +110,12 @@ pub fn cash_scope(big_blind: f64) -> Option<Scope> {
|
||||
enabled().then(|| Scope::enter(big_blind))
|
||||
}
|
||||
|
||||
/// `cash_scope` for a spot with `players` dealt in: under `RAKE_LIVE=sitze` the cap follows them, under
|
||||
/// `RAKE_LIVE=1` the scope is the one of `cash_scope` (flat cap).
|
||||
pub fn cash_scope_seats(big_blind: f64, players: u8) -> Option<Scope> {
|
||||
enabled().then(|| if seat_cap_enabled() { Scope::enter_seats(big_blind, players) } else { Scope::enter(big_blind) })
|
||||
}
|
||||
|
||||
/// Is a rake scope active on this thread?
|
||||
pub fn active() -> bool {
|
||||
BIG_BLIND.with(Cell::get).is_some()
|
||||
@@ -86,7 +125,16 @@ 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 => DECISION_RULE.of_hand(pot / bb, 2, HandEnd::FlopDealt) * bb,
|
||||
Some(bb) if pot.is_finite() && pot > 0.0 => {
|
||||
let rule = match SEATS.with(Cell::get) {
|
||||
Some(players) if cap_bb(players) != LIVE_RULE.cap => {
|
||||
let cap = cap_bb(players);
|
||||
RakeRule { cap, cap_more_than_three: cap, ..DECISION_RULE }
|
||||
}
|
||||
_ => DECISION_RULE,
|
||||
};
|
||||
rule.of_hand(pot / bb, 2, HandEnd::FlopDealt) * bb
|
||||
}
|
||||
Some(_) => 0.0,
|
||||
}
|
||||
}
|
||||
@@ -141,6 +189,27 @@ mod tests {
|
||||
assert!(!active());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_seat_cap_follows_the_players_of_the_hand() {
|
||||
{
|
||||
let _s = Scope::enter_seats(0.02, 6);
|
||||
near(of_pot(50.0), 0.20);
|
||||
near(of_pot(3.38), 0.169);
|
||||
}
|
||||
{
|
||||
let _s = Scope::enter_seats(0.02, 4);
|
||||
near(of_pot(50.0), 0.12);
|
||||
near(of_pot(1.0), 0.05);
|
||||
}
|
||||
{
|
||||
let _s = Scope::enter_seats(0.02, 2);
|
||||
near(of_pot(50.0), 0.05);
|
||||
}
|
||||
assert!(!active());
|
||||
let _s = Scope::enter(0.02);
|
||||
near(of_pot(50.0), 0.20);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_big_blinds_neighbouring_sizes_pay_no_step() {
|
||||
let _s = Scope::enter(1.0);
|
||||
|
||||
@@ -48,5 +48,22 @@ class LetztesBB(unittest.TestCase):
|
||||
self.assertIsNone(rake.letztes_bb(None))
|
||||
|
||||
|
||||
class RegelNachSpielern(unittest.TestCase):
|
||||
"""Die Regel des Raums (gemessen 23.11.2026): Deckel 5-6 Spieler 20, 3-4 Spieler 12, 2 Spieler 5 Cent."""
|
||||
|
||||
def test_deckel_nach_spielern(self):
|
||||
self.assertEqual([rake.deckel_cent(n) for n in (2, 3, 4, 5, 6)], [5, 12, 12, 20, 20])
|
||||
|
||||
def test_gross_gedeckelt_je_spielerzahl(self):
|
||||
self.assertEqual([rake.regel_cent(5000, n) for n in (2, 3, 4, 5, 6)], [5, 12, 12, 20, 20])
|
||||
|
||||
def test_kleiner_topf_gleich_fuer_alle(self):
|
||||
self.assertEqual(rake.regel_cent(33, 2), 2) # 1,65 -> 2 (halber Cent zur geraden Zahl: 1,65 liegt ueber der Mitte)
|
||||
self.assertEqual(rake.regel_cent(10, 6), 0) # 0,50 -> 0 (gerade)
|
||||
self.assertEqual(rake.regel_cent(30, 6), 2) # 1,50 -> 2 (gerade)
|
||||
self.assertEqual(rake.regel_cent(50, 3), 2) # 2,50 -> 2 (gerade)
|
||||
self.assertEqual(rake.regel_cent(70, 3), 4) # 3,50 -> 4 (gerade)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
|
||||
Reference in New Issue
Block a user