Files
pokerfreak/src/game/choice.rs
T

36 lines
917 B
Rust

use super::ActionKind;
/// What the engine answers. A raise always carries its total size; nothing else can.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Choice {
Fold,
Check,
Call,
Raise { to: f64 },
Abstain,
}
impl Choice {
/// The `legalActions` entry this choice needs; `None` for `Abstain`.
pub fn kind(self) -> Option<ActionKind> {
match self {
Choice::Fold => Some(ActionKind::Fold),
Choice::Check => Some(ActionKind::Check),
Choice::Call => Some(ActionKind::Call),
Choice::Raise { .. } => Some(ActionKind::Raise),
Choice::Abstain => None,
}
}
pub fn size(self) -> Option<f64> {
match self {
Choice::Raise { to } => Some(to),
_ => None,
}
}
pub fn name(self) -> &'static str {
self.kind().map_or("ABSTAIN", ActionKind::name)
}
}