use crate::texas::agents::{TexasAgentAction, TexasAgentState};
use super::TexasAgent;
#[derive(Debug)]
pub struct SimpleCliTexasAgent { }
impl SimpleCliTexasAgent {
pub fn new() -> Self {
Self {}
}
}
impl TexasAgent for SimpleCliTexasAgent {
fn decide(&self, state: &TexasAgentState) -> TexasAgentAction {
println!("| Texas Agent CLI : decide()");
println!("| context:");
for (id, agent) in state.shared.agents.iter().enumerate() {
let active = agent.active;
let is_you_str = if id == state.id as usize { " (YOU)" } else { "" };
let is_allin_str = if state.shared.agents[id as usize].bank == 0.into() { " [ALLIN]" } else { "" };
if active {
println!("| P{:} has {:}{:}{:}", id, state.shared.agents[id as usize].bank, is_allin_str, is_you_str);
} else {
println!("| P{:} is FOLDED{:}{:}", id, is_allin_str, is_you_str);
}
}
println!("| pot: {:}", state.shared.pot);
println!("| shared: {:}", state.shared.shared);
println!("| hole: {:}", state.hidden.hole);
println!("| enter the amount to call (={:}), raise (>{:}), or check/fold (=0):", state.shared.bet, state.shared.bet);
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let out = input.trim().parse().unwrap();
println!("| decision: {:}", out);
TexasAgentAction::new(out)
}
}