Files
pokerfreak/src/engine/from_plan.rs
T
mmintel e7123b2524 Commitment-Riegel: ueber-grosse Raise gedeckelt, Fold-Riegel auf echte All-in-Calls verengt
Vorfall 6.11.: 99 fast All-in (3x-Reraise aufs Sizing) und danach Fold.
- from_plan: eine charted Raise, die aufs (nahe) All-in gesized wird, nimmt
  dieselbe Preis-Schwelle wie ein Jam (raise_commitment) - sonst Call/Fold.
- price_guarded: Fold-Riegel feuert nur bei to_call >= 90%% Reststack (echter
  All-in-Call), kennt jetzt die Spielform (kein Call im Jam-oder-Fold).
  Korrigiert den zu breiten Riegel aus 3569efc7, den zwei preflop_advise-Specs
  aufdeckten (KJo callte eine 3-Bet; AOF erzeugte einen Call).

preflop_commit_guard 16 gruen, preflop_advise 20 gruen, engine_from_plan 12 gruen.
2026-11-06 17:29:01 +01:00

68 lines
2.9 KiB
Rust

use super::passive::{cheapest_continue, give_up};
use crate::game::{ActionKind, Choice, Decision, Spot};
use crate::preflop::commit_guard::{raise_commitment, RaiseVerdict};
use crate::preflop::plan::{ChartAction, PreflopPlan};
use crate::sizing::{all_in::all_in, preflop::raise_size};
/// Below this chart certainty, a plan that would put chips in is not trusted.
pub const MIN_CERTAINTY: f64 = 0.15;
fn aggressive(spot: &Spot, size: Option<f64>) -> Option<Choice> {
spot.is_legal(ActionKind::Raise)
.then_some(size)
.flatten()
.map(|to| Choice::Raise { to })
.or_else(|| cheapest_continue(spot))
.or_else(|| give_up(spot))
}
fn wanted(spot: &Spot, action: ChartAction) -> Option<Choice> {
match action {
ChartAction::Jam => aggressive(spot, all_in(spot)),
ChartAction::Raise => aggressive(spot, raise_size(spot)),
ChartAction::Call => cheapest_continue(spot).or_else(|| give_up(spot)),
ChartAction::Fold => give_up(spot),
}
}
/// Maps a chart action through sizing and legality.
/// Jam is all-in, Raise the standard preflop size (both fall back to calling when a
/// raise is impossible), Call calls or checks when free, Fold folds or checks when
/// free. A certainty under [`MIN_CERTAINTY`] turns chip-committing plans into ABSTAIN.
/// A charted `Raise` that sizing capped to (near) all-in is a commitment: it must clear the same
/// price cut-off as a jam, or it steps down to a call (price paid) / fold (commit_guard). A `Raise`
/// well below all-in, and every non-Raise plan, pass through unchanged (the Jam already passed the
/// jam ceiling in `preflop::advise`).
fn commit_begrenzt(spot: &Spot, plan: &PreflopPlan, choice: Option<Choice>) -> Option<Choice> {
match choice {
Some(Choice::Raise { to }) if plan.action == ChartAction::Raise => {
let jam = all_in(spot).unwrap_or(to);
match raise_commitment(plan.percentile, to, jam, spot.to_call, spot.pot) {
RaiseVerdict::Keep => Some(Choice::Raise { to }),
RaiseVerdict::Downgrade => cheapest_continue(spot).or_else(|| give_up(spot)),
RaiseVerdict::Fold => give_up(spot),
}
}
other => other,
}
}
pub fn from_plan(spot: &Spot, plan: &PreflopPlan) -> Decision {
match commit_begrenzt(spot, plan, wanted(spot, plan.action)) {
None => Decision::abstain(format!("{}: no legal way to follow the chart", plan.reason)),
Some(choice @ (Choice::Call | Choice::Raise { .. })) if plan.certainty < MIN_CERTAINTY => {
Decision::abstain(format!(
"{}: certainty {:.2} too low to {}",
plan.reason,
plan.certainty,
choice.name().to_lowercase()
))
}
Some(choice) => Decision::new(
choice,
plan.certainty,
format!("{} -> {}", plan.reason, choice.name().to_lowercase()),
),
}
}