Files
pokerfreak/engine/nlhe/tests/rake_rule.rs
T
mmintelandClaude Opus 5.5 bb4dd0ccc2 score: measurement rake (NL2 rule from 7b26c50) in the exact heads-up evaluator, --rake nl2|nl5|none in sharingan-teilspiel; hand-computed specs
The rake is a rule of the measurement (VecGame::rake), independent of the rake the strategy was solved under; the cap follows the players dealt in.
With a rake the game is not constant-sum: gain = BR value - profile value, both under the rake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 15:31:05 +01:00

53 lines
1.9 KiB
Rust

//! Spec of the NL2 rake rule used by the score (`nlhe::rake`), hand-computed in chips of a 100-chip big blind
//! (NL2: bb = 2 cents, so 1 cent = 50 chips).
use nlhe::rake::{matched_pot, RakeRule};
const CENT: i32 = 50;
fn nl2(players: usize) -> nlhe::Rake {
RakeRule::measured("nl2").unwrap().in_chips(players, 100).unwrap()
}
#[test]
fn five_percent_of_the_pot_rounded_to_the_cent() {
// 40 cents pot -> 2 cents
assert_eq!(nl2(6).of_pot(40 * CENT, true), 2 * CENT);
// 10 cents -> 0.5 cent -> half to even = 0
assert_eq!(nl2(6).of_pot(10 * CENT, true), 0);
// 30 cents -> 1.5 -> 2 ; 50 cents -> 2.5 -> 2 (half to even)
assert_eq!(nl2(6).of_pot(30 * CENT, true), 2 * CENT);
assert_eq!(nl2(6).of_pot(50 * CENT, true), 2 * CENT);
// 4 cents (a limped pot) -> 0.2 cent -> 0
assert_eq!(nl2(2).of_pot(4 * CENT, true), 0);
}
#[test]
fn cap_follows_the_players_dealt_in_not_the_players_left() {
// 600 cent pot: 5% = 30 cents, capped
for (dealt, cap) in [(2, 5), (3, 12), (4, 12), (5, 20), (6, 20)] {
assert_eq!(nl2(dealt).of_pot(600 * CENT, true), cap * CENT, "{dealt} dealt in");
}
// heads-up table: 80 cents -> 4 (under the cap), 120 cents -> 6 -> cap 5
assert_eq!(nl2(2).of_pot(80 * CENT, true), 4 * CENT);
assert_eq!(nl2(2).of_pot(120 * CENT, true), 5 * CENT);
}
#[test]
fn nl2_charges_preflop_pots_too_and_never_more_than_the_pot() {
// no "no flop, no drop" at NL2: a preflop-ended pot of 100 cents is raked
assert_eq!(nl2(6).of_pot(100 * CENT, false), 5 * CENT);
assert_eq!(nl2(6).of_pot(0, true), 0);
}
#[test]
fn matched_pot_leaves_out_the_uncalled_top() {
// A bet 300 total, B called 100 total, C folded after posting 50: matched = 100 + 100 + 50
assert_eq!(matched_pot(&[300, 100, 50]), 250);
assert_eq!(matched_pot(&[200, 200]), 400);
}
#[test]
fn rake_none_takes_nothing() {
assert_eq!(nlhe::Rake::NONE.of_pot(100_000, true), 0);
}