Pure CFR+ core over a 169-class abstraction, push/fold and open/call/3-bet games, Nash/Kuhn/plausibility/lookup tests, chartgen binary, frozen equity and charts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.5 KiB
Rust
38 lines
1.5 KiB
Rust
//! The hands that "wake up" behind the first actor: the strongest `fraction` of all combos,
|
|
//! ranked by all-in equity against a random hand (`Environment::order`). The class on the
|
|
//! border is included fractionally, so the covered combos equal the requested share exactly.
|
|
|
|
use super::environment::Environment;
|
|
use super::hand_class::CLASS_COUNT;
|
|
|
|
/// Membership in `[0, 1]` per class.
|
|
pub fn top_membership(env: &Environment, fraction: f64) -> Vec<f64> {
|
|
let total: f64 = env.order.iter().map(|c| env.chance.combos(*c) as f64).sum();
|
|
let budget = fraction.clamp(0.0, 1.0) * total;
|
|
let (_, membership) = env.order.iter().fold((budget, vec![0.0; CLASS_COUNT]), |(left, mut m), c| {
|
|
let combos = env.chance.combos(*c) as f64;
|
|
let take = if combos > 0.0 { (left / combos).clamp(0.0, 1.0) } else { 0.0 };
|
|
m[*c] = take;
|
|
(left - take * combos, m)
|
|
});
|
|
membership
|
|
}
|
|
|
|
/// Equity of each class against that range (card removal exact). A class that blocks the whole
|
|
/// range keeps 0.5.
|
|
pub fn equity_against(env: &Environment, membership: &[f64]) -> Vec<f64> {
|
|
(0..CLASS_COUNT)
|
|
.map(|i| {
|
|
let (num, den) = (0..CLASS_COUNT).fold((0.0, 0.0), |(n, d), j| {
|
|
let w = env.chance.probability(i, j) * membership.get(j).copied().unwrap_or(0.0);
|
|
(n + w * env.equity.get(i, j), d + w)
|
|
});
|
|
if den > 0.0 {
|
|
num / den
|
|
} else {
|
|
0.5
|
|
}
|
|
})
|
|
.collect()
|
|
}
|