mod all_in;
mod calling;
mod folding;
mod random;
mod replay;
use super::{action::AgentAction, game_state::GameState};
pub trait Agent {
fn act(&mut self, id: u128, game_state: &GameState) -> AgentAction;
}
pub trait AgentGenerator {
fn generate(&self, game_state: &GameState) -> Box<dyn Agent>;
}
pub trait CloneAgent: Agent {
fn clone_box(&self) -> Box<dyn Agent>;
}
impl<T> CloneAgent for T
where
T: 'static + Agent + Clone,
{
fn clone_box(&self) -> Box<dyn Agent> {
Box::new(self.clone())
}
}
pub struct CloneAgentGenerator<T> {
agent: T,
}
impl<T> CloneAgentGenerator<T>
where
T: CloneAgent,
{
pub fn new(agent: T) -> Self {
CloneAgentGenerator { agent }
}
}
impl<T> AgentGenerator for CloneAgentGenerator<T>
where
T: CloneAgent,
{
fn generate(&self, _game_state: &GameState) -> Box<dyn Agent> {
self.agent.clone_box()
}
}
pub use all_in::{AllInAgent, AllInAgentGenerator};
pub use calling::{CallingAgent, CallingAgentGenerator};
pub use folding::{FoldingAgent, FoldingAgentGenerator};
pub use random::{RandomAgent, RandomAgentGenerator, RandomPotControlAgent};
pub use replay::{SliceReplayAgent, VecReplayAgent};