Merge remote-tracking branch 'origin/main'

This commit is contained in:
2026-10-28 15:03:04 +01:00
3 changed files with 41 additions and 6 deletions
+8 -2
View File
@@ -60,6 +60,7 @@ fn postflop(spot: &Spot, thresholds: &Thresholds) -> Decision {
match estimate(&query, Rng::seeded(spot.seed)) {
Ok((equity, _)) => {
choose_postflop_with(spot, &equity, &called_equity(spot), thresholds, &hand_read)
.with_equity(equity.share)
}
Err(fault) => Decision::abstain(format!("equity unavailable: {fault}")),
}
@@ -75,7 +76,12 @@ fn think(spot: &Spot) -> Decision {
}
/// Full decision for a validated spot (preflop chart or postflop read/equity/EV),
/// always passed through `guard::enforce::enforce`.
/// always passed through `guard::enforce::enforce`. Die Handkategorie wird nur
/// zur Nachprüfung angehängt.
pub fn decide(spot: &Spot) -> Decision {
enforce(spot, think(spot))
let decision = enforce(spot, think(spot));
match crate::hand::showdown::best(spot.rules().hole_usage, &spot.hero_cards, &spot.board) {
Ok(strength) => decision.with_category(strength.category),
Err(_) => decision,
}
}
+22 -1
View File
@@ -1,18 +1,39 @@
use super::{Choice, Confidence};
use crate::hand::category::Category;
#[derive(Clone, Debug, PartialEq)]
pub struct Decision {
pub choice: Choice,
pub confidence: Confidence,
pub reason: String,
/// Nur zur Nachprüfung: geschätzte Equity. Ändert keine Entscheidung.
pub equity: Option<f64>,
/// Nur zur Nachprüfung: eigene Handkategorie.
pub category: Option<Category>,
}
impl Decision {
pub fn new(choice: Choice, confidence: f64, reason: impl Into<String>) -> Decision {
Decision { choice, confidence: Confidence::new(confidence), reason: reason.into() }
Decision {
choice,
confidence: Confidence::new(confidence),
reason: reason.into(),
equity: None,
category: None,
}
}
pub fn abstain(reason: impl Into<String>) -> Decision {
Decision::new(Choice::Abstain, 0.0, reason)
}
pub fn with_equity(mut self, equity: f64) -> Decision {
self.equity = Some(equity);
self
}
pub fn with_category(mut self, category: Category) -> Decision {
self.category = Some(category);
self
}
}
+11 -3
View File
@@ -5,15 +5,23 @@ fn three_decimals(value: f64) -> f64 {
(value * 1000.0).round() / 1000.0
}
/// `{"action", "size", "confidence", "reason"}` in that key order.
/// `{"action", "size", "confidence", "reason"}` in that key order, plus the optional
/// diagnostic keys `equity` and `category` when they are known.
pub fn encode_value(decision: &Decision) -> Value {
let size = decision.choice.size().filter(|s| s.is_finite()).map_or(Value::Null, Value::Number);
Value::Object(vec![
let mut felder = vec![
("action".to_string(), Value::String(decision.choice.name().to_string())),
("size".to_string(), size),
("confidence".to_string(), Value::Number(three_decimals(decision.confidence.value()))),
("reason".to_string(), Value::String(decision.reason.clone())),
])
];
if let Some(equity) = decision.equity {
felder.push(("equity".to_string(), Value::Number(three_decimals(equity))));
}
if let Some(category) = decision.category {
felder.push(("category".to_string(), Value::String(format!("{category:?}"))));
}
Value::Object(felder)
}
/// One response line (no trailing newline).