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:
+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);
|
||||
|
||||
Reference in New Issue
Block a user