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>
125 lines
5.7 KiB
Rust
125 lines
5.7 KiB
Rust
//! Lookup over the frozen multi-defender tables (`generated_charts_multi`): one decision node of
|
|
//! the game "first actor `seat` against `defenders` modelled players behind it", for every class.
|
|
//!
|
|
//! - Full deck only (NLHE); the short deck has no multi-defender table.
|
|
//! - Depth rule: the two grid depths around `depth_bb` are interpolated linearly, like
|
|
//! `generated_lookup`, but there is no clamping: outside the grid (`OPEN_DEPTHS`, 20 to 100 bb)
|
|
//! the answer is `None` and the caller keeps its old tables.
|
|
//! - Node names are those of `cfr::multi_tree` (`open`, `{D}_defend`, `vs_{D}_three_bet`,...).
|
|
//! Two-action nodes are fold / aggressive (`open`) or fold / call (`{D}_vs_jam`, overcalls),
|
|
//! three-action nodes fold / call / aggressive.
|
|
//!
|
|
//! The rows are decoded once per call; the result covers all `CLASS_COUNT` classes.
|
|
|
|
use super::generated_charts_multi::{MULTI, OPEN_DEPTHS};
|
|
use super::generated_charts_multi_deep::{DEEP_DEPTHS, MULTI_DEEP};
|
|
use super::generated_lookup::Frequencies;
|
|
use crate::cfr::frozen_multi::{permille_rows, MultiRow, MultiSpot};
|
|
use crate::cfr::seat::Seat;
|
|
|
|
/// Covered stack range in bb.
|
|
pub fn multi_depth_range() -> (f64, f64) {
|
|
let lo = OPEN_DEPTHS.iter().copied().min().unwrap_or(0) as f64;
|
|
let hi = OPEN_DEPTHS.iter().copied().max().unwrap_or(0) as f64;
|
|
(lo, hi)
|
|
}
|
|
|
|
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.
|
|
// `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 })
|
|
} else {
|
|
(&MULTI, &MULTI_DEEP)
|
|
};
|
|
flach
|
|
.iter()
|
|
.chain(tief.iter())
|
|
.find(|s| s.seat == seat && s.defenders as usize == defenders && s.depth_bb == depth)
|
|
}
|
|
|
|
/// With `PREFLOP_VOLL`: the grid with the deep tables that exist (150 / 200 bb), and deeper stacks
|
|
/// clamped to the deepest one. Without, `None` above 100 bb as always.
|
|
fn deep_node(seat: Seat, defenders: usize, depth_bb: f64, node: &str) -> Option<Vec<Frequencies>> {
|
|
let grid: Vec<u8> = OPEN_DEPTHS
|
|
.iter()
|
|
.copied()
|
|
.chain(DEEP_DEPTHS.iter().copied().filter(|d| spot(seat, defenders, *d).is_some()))
|
|
.collect();
|
|
let deepest = grid.iter().copied().max()? as f64;
|
|
let depth = depth_bb.min(deepest);
|
|
let below = grid.iter().copied().filter(|d| *d as f64 <= depth).max()?;
|
|
let above = grid.iter().copied().filter(|d| *d as f64 >= depth).min()?;
|
|
let low = node_row(spot(seat, defenders, below)?, node)?;
|
|
if below == above {
|
|
return Some(low);
|
|
}
|
|
let high = node_row(spot(seat, defenders, above)?, node)?;
|
|
let t = (depth - below as f64) / (above as f64 - below as f64);
|
|
let mix = |a: f64, b: f64| a * (1.0 - t) + b * t;
|
|
Some(
|
|
low.iter()
|
|
.zip(high.iter())
|
|
.map(|(a, b)| Frequencies { fold: mix(a.fold, b.fold), call: mix(a.call, b.call), raise: mix(a.raise, b.raise) })
|
|
.collect(),
|
|
)
|
|
}
|
|
|
|
/// Frequencies of `node` per class; `aggressive_two`: a two-action node's second action is the
|
|
/// aggressive one (open) rather than a call.
|
|
fn row(row: &MultiRow, aggressive_two: bool) -> Option<Vec<Frequencies>> {
|
|
let permille = permille_rows(row).ok()?;
|
|
permille
|
|
.iter()
|
|
.map(|p| {
|
|
let f = |i: usize| p.get(i).copied().unwrap_or(0) as f64 / 1000.0;
|
|
match p.len() {
|
|
2 if aggressive_two => Some(Frequencies { fold: f(0), call: 0.0, raise: f(1) }),
|
|
2 => Some(Frequencies { fold: f(0), call: f(1), raise: 0.0 }),
|
|
3 => Some(Frequencies { fold: f(0), call: f(1), raise: f(2) }),
|
|
_ => None,
|
|
}
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
fn node_row(spot: &MultiSpot, node: &str) -> Option<Vec<Frequencies>> {
|
|
let found = spot.rows.iter().find(|r| r.name == node)?;
|
|
row(found, node == "open")
|
|
}
|
|
|
|
/// `node` of the game `seat` against `defenders` at `depth_bb`, per class; `None` outside the
|
|
/// depth grid, for an unknown lineup or node.
|
|
pub fn multi_node(seat: Seat, defenders: usize, depth_bb: f64, node: &str) -> Option<Vec<Frequencies>> {
|
|
let (lo, hi) = multi_depth_range();
|
|
if !depth_bb.is_finite() || depth_bb < lo {
|
|
return None;
|
|
}
|
|
if depth_bb > hi {
|
|
return if super::voll::voll_an() { deep_node(seat, defenders, depth_bb, node) } else { None };
|
|
}
|
|
let below = OPEN_DEPTHS.iter().copied().filter(|d| *d as f64 <= depth_bb).max()?;
|
|
let above = OPEN_DEPTHS.iter().copied().filter(|d| *d as f64 >= depth_bb).min()?;
|
|
let low = node_row(spot(seat, defenders, below)?, node)?;
|
|
if below == above {
|
|
return Some(low);
|
|
}
|
|
let high = node_row(spot(seat, defenders, above)?, node)?;
|
|
let t = (depth_bb - below as f64) / (above as f64 - below as f64);
|
|
let mix = |a: f64, b: f64| a * (1.0 - t) + b * t;
|
|
Some(
|
|
low.iter()
|
|
.zip(high.iter())
|
|
.map(|(a, b)| Frequencies { fold: mix(a.fold, b.fold), call: mix(a.call, b.call), raise: mix(a.raise, b.raise) })
|
|
.collect(),
|
|
)
|
|
}
|