feat: bot random strategy
This commit is contained in:
parent
b02ce8d185
commit
bf820ecc4e
10 changed files with 106 additions and 27 deletions
|
|
@ -1,4 +1,7 @@
|
|||
use bot::{BotStrategy, DefaultStrategy, DqnStrategy, ErroneousStrategy, StableBaselines3Strategy};
|
||||
use bot::{
|
||||
BotStrategy, DefaultStrategy, DqnStrategy, ErroneousStrategy, RandomStrategy,
|
||||
StableBaselines3Strategy,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::game_runner::GameRunner;
|
||||
|
|
@ -32,13 +35,15 @@ impl App {
|
|||
"dummy" => {
|
||||
Some(Box::new(DefaultStrategy::default()) as Box<dyn BotStrategy>)
|
||||
}
|
||||
"random" => {
|
||||
Some(Box::new(RandomStrategy::default()) as Box<dyn BotStrategy>)
|
||||
}
|
||||
"erroneous" => {
|
||||
Some(Box::new(ErroneousStrategy::default()) as Box<dyn BotStrategy>)
|
||||
}
|
||||
"ai" => Some(Box::new(StableBaselines3Strategy::default())
|
||||
as Box<dyn BotStrategy>),
|
||||
"dqn" => Some(Box::new(DqnStrategy::default())
|
||||
as Box<dyn BotStrategy>),
|
||||
"dqn" => Some(Box::new(DqnStrategy::default()) as Box<dyn BotStrategy>),
|
||||
s if s.starts_with("ai:") => {
|
||||
let path = s.trim_start_matches("ai:");
|
||||
Some(Box::new(StableBaselines3Strategy::new(path))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use bot::{Bot, BotStrategy};
|
||||
use log::{error, info};
|
||||
use log::{debug, error};
|
||||
use store::{CheckerMove, DiceRoller, GameEvent, GameState, PlayerId, TurnStage};
|
||||
|
||||
// Application Game
|
||||
|
|
@ -63,19 +63,19 @@ impl GameRunner {
|
|||
return None;
|
||||
}
|
||||
let valid_event = if self.state.validate(event) {
|
||||
info!(
|
||||
debug!(
|
||||
"--------------- new valid event {event:?} (stage {:?}) -----------",
|
||||
self.state.turn_stage
|
||||
);
|
||||
self.state.consume(event);
|
||||
info!(
|
||||
debug!(
|
||||
" --> stage {:?} ; active player points {:?}",
|
||||
self.state.turn_stage,
|
||||
self.state.who_plays().map(|p| p.points)
|
||||
);
|
||||
event
|
||||
} else {
|
||||
info!("{}", self.state);
|
||||
debug!("{}", self.state);
|
||||
error!("event not valid : {event:?}");
|
||||
panic!("crash and burn");
|
||||
&GameEvent::PlayError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue