Clippy cleanup under green tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,9 @@ use crate::preflop::advise::advise;
|
||||
use crate::preflop::hand_percentile::percentile;
|
||||
use crate::rng::Rng;
|
||||
|
||||
/// A villain's range as an owned predicate over hole cards.
|
||||
type HandFilter = Box<dyn Fn(&[Card]) -> bool>;
|
||||
|
||||
const TRIALS_TWO_CARD: u32 = 3000;
|
||||
const TRIALS_FIVE_CARD: u32 = 1500;
|
||||
|
||||
@@ -35,11 +38,10 @@ fn postflop(spot: &Spot, thresholds: &Thresholds) -> Decision {
|
||||
);
|
||||
}
|
||||
let variant = spot.variant;
|
||||
let filters: Vec<Box<dyn Fn(&[Card]) -> bool>> = fractions
|
||||
let filters: Vec<HandFilter> = fractions
|
||||
.into_iter()
|
||||
.map(|fraction| {
|
||||
Box::new(move |hand: &[Card]| percentile(variant, hand) <= fraction)
|
||||
as Box<dyn Fn(&[Card]) -> bool>
|
||||
Box::new(move |hand: &[Card]| percentile(variant, hand) <= fraction) as HandFilter
|
||||
})
|
||||
.collect();
|
||||
let ranges: Vec<VillainRange> =
|
||||
|
||||
@@ -31,9 +31,7 @@ pub fn scored(spot: &Spot, estimate: &Estimate, thresholds: &Thresholds) -> Vec<
|
||||
.then(|| Scored { choice: Choice::Call, ev: ev::call(share, spot.pot, spot.to_call) });
|
||||
let fold = (spot.is_legal(ActionKind::Fold) && !free)
|
||||
.then(|| Scored { choice: Choice::Fold, ev: ev::fold() });
|
||||
let raises = (spot.is_legal(ActionKind::Raise) && share >= thresholds.value_raise)
|
||||
.then(|| candidates(spot))
|
||||
.unwrap_or_default()
|
||||
let raises = if spot.is_legal(ActionKind::Raise) && share >= thresholds.value_raise { candidates(spot) } else { Default::default() }
|
||||
.into_iter()
|
||||
.map(|to| {
|
||||
let fe = fold_equity(spot.pot, to, thresholds.fold_equity_scale, live);
|
||||
|
||||
@@ -36,12 +36,11 @@ pub fn remaining_deck(query: &Query) -> Result<Vec<Card>, Fault> {
|
||||
}
|
||||
|
||||
fn known_hands(query: &Query, k: usize) -> Result<Vec<Card>, Fault> {
|
||||
let hands = query.villains.iter().filter_map(|v| match v {
|
||||
let mut hands = query.villains.iter().filter_map(|v| match v {
|
||||
VillainRange::Exact(cards) => Some(cards),
|
||||
_ => None,
|
||||
});
|
||||
hands.fold(Ok(Vec::new()), |acc, cards| {
|
||||
let mut all = acc?;
|
||||
hands.try_fold(Vec::new(), |mut all, cards| {
|
||||
if cards.len() != k {
|
||||
return Err(invalid("villain", format!("expected {k} cards, got {}", cards.len())));
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ pub fn classify(profile: &Profile) -> Style {
|
||||
);
|
||||
let loose = vpip.is_some_and(|v| v >= LOOSE_VPIP);
|
||||
let sticky = fold.is_some_and(|b| b <= STATION_FOLD_TO_BET)
|
||||
&& vpip.map_or(true, |v| v >= STATION_MIN_VPIP);
|
||||
&& vpip.is_none_or(|v| v >= STATION_MIN_VPIP);
|
||||
let tight = vpip.is_some_and(|v| v <= NIT_VPIP)
|
||||
|| (fold.is_some_and(|b| b >= NIT_FOLD_TO_BET)
|
||||
&& vpip.map_or(true, |v| v <= NIT_MAX_VPIP_WITH_FOLDS));
|
||||
&& vpip.is_none_or(|v| v <= NIT_MAX_VPIP_WITH_FOLDS));
|
||||
if vpip.is_none() && pfr.is_none() && fold.is_none() {
|
||||
Style::Unknown
|
||||
} else if loose && pfr.is_some_and(|f| f >= AGGRESSIVE_PFR) {
|
||||
|
||||
@@ -78,7 +78,7 @@ fn actions(spot: &Spot) -> Result<(), Fault> {
|
||||
if spot.is_legal(ActionKind::Check) && spot.to_call > 0.0 {
|
||||
return Err(Fault::Inconsistent("CHECK legal while toCall > 0".to_string()));
|
||||
}
|
||||
let sizeable = spot.allowed_sizes.as_ref().map_or(false, |s| !s.is_empty())
|
||||
let sizeable = spot.allowed_sizes.as_ref().is_some_and(|s| !s.is_empty())
|
||||
|| spot.min_raise_to.is_some()
|
||||
|| spot.max_raise_to.is_some()
|
||||
|| spot.hero_stack > 0.0;
|
||||
|
||||
@@ -12,8 +12,8 @@ pub fn valid_allowed(spot: &Spot) -> Option<Vec<f64>> {
|
||||
s.is_finite()
|
||||
&& *s > 0.0
|
||||
&& *s <= spot.hero_stack
|
||||
&& spot.min_raise_to.map_or(true, |min| *s >= min)
|
||||
&& spot.max_raise_to.map_or(true, |max| *s <= max)
|
||||
&& spot.min_raise_to.is_none_or(|min| *s >= min)
|
||||
&& spot.max_raise_to.is_none_or(|max| *s <= max)
|
||||
})
|
||||
.collect();
|
||||
usable.sort_by(f64::total_cmp);
|
||||
|
||||
@@ -136,7 +136,7 @@ fn assert_sound(spot: &Spot, decision: &Decision, label: &str) {
|
||||
assert!(to.is_finite() && to > 0.0, "{ctx}");
|
||||
assert!(to <= spot.hero_stack, "unaffordable. {ctx}");
|
||||
if let Some(allowed) = &spot.allowed_sizes {
|
||||
assert!(allowed.iter().any(|a| *a == to), "not from allowedSizes. {ctx}");
|
||||
assert!(allowed.contains(&to), "not from allowedSizes. {ctx}");
|
||||
}
|
||||
if let Some(min) = spot.min_raise_to {
|
||||
assert!(to >= min || to == spot.hero_stack, "below min and not all-in. {ctx}");
|
||||
|
||||
@@ -9,6 +9,7 @@ use support::{action, board_json, cards_json, confidence, short, size};
|
||||
/// careful engine must refuse to reason about it.
|
||||
const CONTRACT_EXAMPLE: &str = r#"{"variant":"NLHE","bigBlind":0.1,"seats":6,"heroSeat":5,"heroCards":[{"rank":"A","suit":"HEARTS"},{"rank":"5","suit":"HEARTS"}],"board":{"FLOP":[{"rank":"A","suit":"CLUBS"}],"TURN":null,"RIVER":null},"street":"FLOP","pot":1.25,"toCall":0.2,"heroStack":2.4,"minRaiseTo":0.5,"maxRaiseTo":20.0,"legalActions":["FOLD","CALL","RAISE"],"allowedSizes":[0.5,1.15,4.6],"villains":[{"seat":2,"stack":10.4,"folded":false}]}"#;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn request(
|
||||
variant: &str,
|
||||
hero: &str,
|
||||
|
||||
@@ -39,8 +39,8 @@ pub fn field<'a>(response: &'a str, key: &str) -> Option<&'a str> {
|
||||
let pattern = format!("\"{key}\":");
|
||||
let start = response.find(&pattern)? + pattern.len();
|
||||
let rest = &response[start..];
|
||||
let end = if rest.starts_with('"') {
|
||||
rest[1..].find('"').map(|i| i + 2)?
|
||||
let end = if let Some(quoted) = rest.strip_prefix('"') {
|
||||
quoted.find('"').map(|i| i + 2)?
|
||||
} else {
|
||||
rest.find([',', '}'])?
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user