Allow short all-in below minRaiseTo; tests updated first

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 12:02:39 +01:00
co-authored by Claude Opus 5.5
parent 9371161d33
commit 12b1efbe1a
5 changed files with 27 additions and 8 deletions
+5 -2
View File
@@ -15,13 +15,16 @@ impl Bounds {
}
/// `[min_raise_to, min(max_raise_to, hero_stack)]`; pot-limit rules also cap at a
/// pot-sized raise (`pot + 2 * to_call`). `None` when no positive size fits.
/// pot-sized raise (`pot + 2 * to_call`). A stack below `min_raise_to` may still go
/// all-in for exactly the stack (short all-in). `None` when no positive size fits.
pub fn bounds(spot: &Spot) -> Option<Bounds> {
let lo = spot.min_raise_to.unwrap_or(0.0).max(0.0);
let min = spot.min_raise_to.unwrap_or(0.0).max(0.0);
let capped = spot.max_raise_to.unwrap_or(f64::INFINITY).min(spot.hero_stack);
let hi = match spot.rules().sizing {
SizingRule::PotLimit => capped.min(spot.pot + 2.0 * spot.to_call),
_ => capped,
};
let short_all_in = hi == spot.hero_stack && spot.hero_stack < min;
let lo = if short_all_in { hi } else { min };
(lo.is_finite() && hi > 0.0 && lo <= hi).then_some(Bounds { lo, hi })
}
+7 -1
View File
@@ -56,8 +56,14 @@ fn jam_without_raise_falls_back_to_a_call() {
}
#[test]
fn unsizeable_raise_falls_back_to_passive() {
fn short_stack_raise_becomes_the_short_all_in() {
let spot = Spot { hero_stack: 0.15, ..preflop() };
assert_eq!(choice(&spot, ChartAction::Raise, 1.0), Choice::Raise { to: 0.15 });
}
#[test]
fn unsizeable_raise_falls_back_to_passive() {
let spot = Spot { hero_stack: 0.15, max_raise_to: Some(0.12), ..preflop() };
assert_eq!(choice(&spot, ChartAction::Raise, 1.0), Choice::Call);
}
+1 -1
View File
@@ -139,7 +139,7 @@ fn assert_sound(spot: &Spot, decision: &Decision, label: &str) {
assert!(allowed.iter().any(|a| *a == to), "not from allowedSizes. {ctx}");
}
if let Some(min) = spot.min_raise_to {
assert!(to >= min, "below min. {ctx}");
assert!(to >= min || to == spot.hero_stack, "below min and not all-in. {ctx}");
}
if let Some(max) = spot.max_raise_to {
assert!(to <= max, "above max. {ctx}");
+7 -3
View File
@@ -42,9 +42,12 @@ fn sizes_are_clamped_into_the_hero_stack() {
}
#[test]
fn stack_below_min_raise_gives_no_candidates() {
fn stack_below_min_raise_offers_only_the_short_all_in() {
let spot = Spot { hero_stack: 0.3, ..flop() };
assert!(candidates(&spot).is_empty());
assert_eq!(candidates(&spot), vec![0.3]);
// A max cap below the stack is not a short all-in: nothing fits.
let capped = Spot { hero_stack: 0.3, max_raise_to: Some(0.2), ..flop() };
assert!(candidates(&capped).is_empty());
}
#[test]
@@ -102,7 +105,8 @@ fn all_in_is_stack_or_max() {
assert_eq!(all_in(&flop()), Some(2.4));
assert_eq!(all_in(&Spot { max_raise_to: Some(1.0), ..flop() }), Some(1.0));
assert_eq!(all_in(&Spot { hero_stack: 0.0, ..flop() }), None);
assert_eq!(all_in(&Spot { min_raise_to: Some(3.0), ..flop() }), None);
// Stack 2.4 below a 3.0 minimum: the short all-in for the whole stack.
assert_eq!(all_in(&Spot { min_raise_to: Some(3.0), ..flop() }), Some(2.4));
}
#[test]
+7 -1
View File
@@ -38,7 +38,13 @@ fn raise_size_picks_the_nearest_allowed_size_verbatim() {
}
#[test]
fn unaffordable_min_raise_gives_nothing() {
fn unaffordable_min_raise_becomes_the_short_all_in() {
let spot = Spot { hero_stack: 0.15, ..preflop() };
assert_eq!(raise_size(&spot), Some(0.15));
}
#[test]
fn capped_below_min_raise_gives_nothing() {
let spot = Spot { hero_stack: 0.15, max_raise_to: Some(0.12), ..preflop() };
assert_eq!(raise_size(&spot), None);
}