Files
pokerfreak/src/cfr/render_equity.rs
T
mmintelandClaude Opus 5.5 7f40fa49a0 CFR charts with both blinds as defenders, short deck tables
EP, MP, CO and BTN now play three-player games against small and big
blind (push/fold and open/call/3-bet trees, CFR+ for three players,
exploitability summed over all three best responses). Deal weights and
three-way shares are documented approximations. Short deck gets its own
equity table and charts from the same generator (--deck short).

Open width shrinks in EP/MP (e.g. EP 100bb 0.291 -> 0.249, MP 40bb
0.357 -> 0.293); frozen exploitability stays at 0-4 micro-bb (full) and
0-9 micro-bb (short). Lookup and advice cover SB vs open/jam, BB after
an SB call and the opener vs an SB 3-bet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:02:45 +01:00

48 lines
2.0 KiB
Rust

//! Rust source text of `generated_equity.rs` / `generated_equity_short.rs`.
use super::chart_deck::ChartDeck;
use super::equity_matrix::TRIANGLE_LEN;
/// Lines of numbers, `per_line` per line, indented.
pub fn wrapped(numbers: &[u16], per_line: usize) -> String {
numbers
.chunks(per_line.max(1))
.map(|chunk| {
let line: Vec<String> = chunk.iter().map(|n| n.to_string()).collect();
format!(" {},\n", line.join(", "))
})
.collect()
}
fn deck_lines(deck: ChartDeck) -> &'static str {
match deck {
ChartDeck::Full => "",
ChartDeck::Short => "//! Deck: 36 cards (six to ace), short deck hand order: flush over full house, A-6-7-8-9 is a\n\
//! straight. Classes with a rank below six are not in the deck and stay 0.\n\
//!\n",
}
}
pub fn render_equity(deck: ChartDeck, seed: u64, samples: u32, triangle: &[u16]) -> String {
format!(
"//! GENERATED by `cargo run --release --bin chartgen -- equity{arg} > {file}`.\n\
//! Do not edit.\n\
//!\n\
{deck}\
//! All-in preflop equity of hand class `i` against class `j` (`i <= j`, row-major over the\n\
//! 13 x 13 class grid of `hand_class`) in 1/10 000, from {samples} seeded Monte-Carlo\n\
//! board runouts per class pair with exact card removal, evaluated by `hand::showdown::judge`.\n\
//! The diagonal is 5000 by symmetry; the lower triangle is `10000 - upper`.\n\
//! Standard error per entry: at most {err:.2} % (sqrt(0.25 / samples)).\n\n\
pub const SEED: u64 = {seed};\n\
pub const SAMPLES: u32 = {samples};\n\n\
pub static TRIANGLE: [u16; {len}] = [\n{body}];\n",
arg = deck.deck_argument(),
file = deck.equity_file(),
deck = deck_lines(deck),
err = (0.25 / samples.max(1) as f64).sqrt() * 100.0,
len = TRIANGLE_LEN,
body = wrapped(triangle, 24),
)
}