PREFLOP_MIKRO: Preflop-Tabellen fuer den Live-Mikro-Tisch (keine Antes + Mikro-Rake), nur im gerakten Cash-Spot

Wirkt nur mit RAKE_LIVE-Scope (rake::live::active), Absprache rake-live: Leiter RAKE_LIVE gegen
RAKE_LIVE+PREFLOP_MIKRO. Leere Dateien (chartgen --mikro laeuft in der Warteschlange) lassen die
alte Tabelle stehen. Aus: bit-identisch (tests/preflop_mikro.rs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 01:22:37 +01:00
co-authored by Claude Opus 5.5
parent a7b23fc3ff
commit b6ff1414bd
10 changed files with 148 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
//! Platzhalter, bis `chartgen charts --mikro` gelaufen ist (dann ersetzt).
use crate::cfr::frozen_spot::{OpenSpot, PushFoldSpot};
pub static PUSH_FOLD: [PushFoldSpot; 0] = [];
pub static OPEN: [OpenSpot; 0] = [];
@@ -0,0 +1,7 @@
//! Platzhalter, bis `chartgen multi-deep --mikro` gelaufen ist (dann ersetzt).
use crate::cfr::frozen_multi::{BaselineSpot, MultiSpot};
pub const DEEP_DEPTHS: [u8; 2] = [150, 200];
pub static BASELINE_DEEP: [BaselineSpot; 0] = [];
pub static MULTI_DEEP: [MultiSpot; 0] = [];
@@ -0,0 +1,7 @@
//! Platzhalter, bis `chartgen multi --mikro` gelaufen ist (dann ersetzt).
use crate::cfr::frozen_multi::{BaselineSpot, MultiSpot};
pub const OPEN_DEPTHS: [u8; 3] = [20, 40, 100];
pub static BASELINE: [BaselineSpot; 0] = [];
pub static MULTI: [MultiSpot; 0] = [];
+5 -1
View File
@@ -159,7 +159,8 @@ fn non_empty<T>(spots: &'static [T]) -> Option<&'static [T]> {
fn push_chart(variant: Variant) -> Option<&'static [PushFoldSpot]> {
match variant {
Variant::Nlhe => non_empty(&PUSH_FOLD),
// `PREFLOP_MIKRO` in a raked cash spot: the live micro table (no antes, micro rake).
Variant::Nlhe => non_empty(super::mikro::waehle(&PUSH_FOLD, &super::generated_charts_mikro::PUSH_FOLD)),
Variant::Aof => non_empty(AOF_PUSH_FOLD),
Variant::ShortDeck => non_empty(&short::PUSH_FOLD),
_ => None,
@@ -169,6 +170,9 @@ fn push_chart(variant: Variant) -> Option<&'static [PushFoldSpot]> {
fn open_chart(variant: Variant) -> Option<&'static [OpenSpot]> {
match variant {
// `PREFLOP_OHNE_ANTE`: the same games without the table's antes (live micro cash has none).
Variant::Nlhe if super::mikro::mikro() && !super::generated_charts_mikro::OPEN.is_empty() => {
non_empty(&super::generated_charts_mikro::OPEN)
}
Variant::Nlhe if super::ante::ohne_ante() => non_empty(&super::generated_charts_ohne_ante::OPEN),
Variant::Nlhe => non_empty(&OPEN),
Variant::ShortDeck => non_empty(&short::OPEN),
+6
View File
@@ -0,0 +1,6 @@
//! Platzhalter, bis `chartgen teilspiel --mikro` gelaufen ist (dann ersetzt; die Zellenart
//! `TeilZelle` bleibt die von `generated_teilspiel`).
pub use super::generated_teilspiel::TeilZelle;
pub static TEILSPIEL: [TeilZelle; 0] = [];
+45
View File
@@ -0,0 +1,45 @@
//! Schalter `PREFLOP_MIKRO`: Preflop-Tabellen fuer den Live-Mikro-Tisch (NL 0.01/0.02).
//!
//! Die eingefrorenen Tabellen rechnen 0,96 bb Antes und den Rake des 1000/2000-Tisches (Deckel 1 bb,
//! Fold-Pots frei). Live Mikro hat keine Antes (2703/2703 Haende) und nimmt 5 % auf den Cent, Deckel
//! 10 bb, auch preflop und auch in Fold-Pots (rake-live, 857 Haende). `chartgen --mikro` loest alle
//! Preflop-Spiele in genau dieser Umgebung: `generated_charts_mikro` (Push/Fold + Open),
//! `generated_charts_multi_mikro`, `generated_charts_multi_deep_mikro`, `generated_teilspiel_mikro`.
//!
//! An (`PREFLOP_MIKRO=1`) wirkt er NUR in einem gerakten Cash-Spot (`rake::live::active()`, also mit
//! `RAKE_LIVE=1`; ein Turnier zahlt keinen Rake und behaelt die Tabellen mit Antes). So misst die
//! gepaarte Leiter jeden Schritt einzeln: RAKE_LIVE gegen RAKE_LIVE + PREFLOP_MIKRO (Absprache
//! rake-live 15.11.). Eine Datei, die noch nicht geloest ist (leer), laesst die alte Tabelle stehen.
//! Aus (Vorgabe): bit-identisch. Einmal gelesen; `set_mikro` fuer Tests und Arme.
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::OnceLock;
/// 0 = nicht gesetzt (Umgebung lesen), 1 = aus, 2 = an.
static SCHALTER: AtomicU8 = AtomicU8::new(0);
pub fn set_mikro(an: bool) {
SCHALTER.store(if an { 2 } else { 1 }, Ordering::Relaxed);
}
/// `PREFLOP_MIKRO=1` (oder `set_mikro(true)`). Vorgabe aus.
pub fn mikro_an() -> bool {
match SCHALTER.load(Ordering::Relaxed) {
1 => false,
2 => true,
_ => {
static ENV: OnceLock<bool> = OnceLock::new();
*ENV.get_or_init(|| std::env::var("PREFLOP_MIKRO").as_deref() == Ok("1"))
}
}
}
/// Die Mikro-Tabellen gelten hier: Schalter an UND ein gerakter Cash-Spot.
pub fn mikro() -> bool {
mikro_an() && crate::rake::live::active()
}
/// `mikro()` und die Datei ist geloest, sonst die Tabelle mit Antes.
pub fn waehle<T>(alt: &'static [T], neu: &'static [T]) -> &'static [T] {
if mikro() && !neu.is_empty() { neu } else { alt }
}
+5
View File
@@ -19,6 +19,11 @@ pub mod generated_charts_multi_deep_ohne_ante;
pub mod generated_charts_multi_ohne_ante;
pub mod generated_charts_ohne_ante;
pub mod generated_teilspiel;
pub mod generated_teilspiel_mikro;
pub mod generated_charts_mikro;
pub mod generated_charts_multi_mikro;
pub mod generated_charts_multi_deep_mikro;
pub mod mikro;
pub mod generated_charts_short;
pub mod generated_lookup;
pub mod hand_percentile;
+7 -1
View File
@@ -27,7 +27,13 @@ pub fn multi_depth_range() -> (f64, f64) {
fn spot(seat: Seat, defenders: usize, depth: u8) -> Option<&'static MultiSpot> {
// `PREFLOP_OHNE_ANTE`: the same games without the table's antes. A file that is not solved yet
// (empty) leaves the table with antes in place, so the switch can be measured file by file.
let (flach, tief): (&'static [MultiSpot], &'static [MultiSpot]) = if super::ante::ohne_ante() {
// `PREFLOP_MIKRO` (raked cash spot): the live micro tables, file by file as they are solved.
let (flach, tief): (&'static [MultiSpot], &'static [MultiSpot]) = if super::mikro::mikro() {
(
super::mikro::waehle(&MULTI, &super::generated_charts_multi_mikro::MULTI),
super::mikro::waehle(&MULTI_DEEP, &super::generated_charts_multi_deep_mikro::MULTI_DEEP),
)
} else if super::ante::ohne_ante() {
let flach: &'static [MultiSpot] = &super::generated_charts_multi_ohne_ante::MULTI;
let tief: &'static [MultiSpot] = &super::generated_charts_multi_deep_ohne_ante::MULTI_DEEP;
(if flach.is_empty() { &MULTI } else { flach }, if tief.is_empty() { &MULTI_DEEP } else { tief })
+3 -1
View File
@@ -146,7 +146,9 @@ fn tiefen_paar(tiefe: f64) -> (u8, u8, f64) {
fn zelle(z: &Zelle, tiefe: u8, groesse: f64) -> Option<&'static TeilZelle> {
let g = (groesse * 10.0).round() as u16;
TEILSPIEL.iter().find(|c| {
// `PREFLOP_MIKRO` (raked cash spot): the cells solved with the live micro rake.
let zellen = super::mikro::waehle(&TEILSPIEL, &super::generated_teilspiel_mikro::TEILSPIEL);
zellen.iter().find(|c| {
c.art == z.art
&& c.villain == z.villain
&& c.hero == z.hero
+57
View File
@@ -0,0 +1,57 @@
//! Spec: `PREFLOP_MIKRO` reads the live micro tables (no antes, micro rake) ONLY inside a raked cash
//! spot (`rake::live` scope). Off, or without a scope (tournaments, `RAKE_LIVE` off): bit-identical.
//! A table not yet solved (empty file) leaves the old one in place.
//!
//! The switch is process-global: everything that toggles it runs in ONE test, in order.
use rechner::cfr::hand_class::class_parse;
use rechner::cfr::seat::Seat;
use rechner::preflop::generated_charts::OPEN;
use rechner::preflop::generated_charts_mikro::{OPEN as OPEN_MIKRO, PUSH_FOLD as PUSH_MIKRO};
use rechner::preflop::generated_lookup::{open_frequency, push_frequency};
use rechner::preflop::mikro::{mikro, set_mikro};
use rechner::rake::live::Scope;
use rechner::variant::Variant;
#[test]
fn the_micro_tables_apply_only_with_the_switch_and_a_raked_cash_spot() {
let k4o = class_parse("K4o").expect("K4o");
let read = || {
OPEN.iter()
.map(|s| open_frequency(Variant::Nlhe, s.seat, s.depth_bb as f64, k4o).expect("open").raise)
.chain([push_frequency(Variant::Nlhe, Seat::Button, 10.0, k4o).expect("push").raise])
.collect::<Vec<f64>>()
};
set_mikro(false);
let base = read();
// Switch on, no scope (tournament / RAKE_LIVE off): nothing changes.
set_mikro(true);
assert!(!mikro());
assert_eq!(read(), base);
// Switch off, scope on: nothing changes.
set_mikro(false);
{
let _s = Scope::enter(0.02);
assert!(!mikro());
assert_eq!(read(), base);
}
// Both: the micro tables where solved, the old ones where the file is still empty.
set_mikro(true);
{
let _s = Scope::enter(0.02);
assert!(mikro());
let on = read();
if OPEN_MIKRO.is_empty() && PUSH_MIKRO.is_empty() {
assert_eq!(on, base, "unsolved: the old tables stay");
} else if !OPEN_MIKRO.is_empty() {
for (i, s) in OPEN_MIKRO.iter().enumerate() {
assert!((on[i] - s.open[k4o] as f64 / 1000.0).abs() < 1e-12);
}
}
}
assert!(!mikro(), "scope dropped");
set_mikro(false);
}