diff --git a/bot/src/lib.rs b/bot/src/lib.rs index f8e3c23..9318fea 100644 --- a/bot/src/lib.rs +++ b/bot/src/lib.rs @@ -9,6 +9,7 @@ pub trait BotStrategy: std::fmt::Debug { fn calculate_points(&self) -> u8; fn calculate_adv_points(&self) -> u8; fn choose_move(&self) -> (CheckerMove, CheckerMove); + fn choose_go(&self) -> bool; fn set_player_id(&mut self, player_id: PlayerId); fn set_color(&mut self, color: Color); fn init_players(&mut self) { @@ -77,6 +78,18 @@ impl Bot { player_id: self.player_id, moves: self.strategy.choose_move(), }), + TurnStage::HoldOrGoChoice => { + if self.strategy.choose_go() { + Some(GameEvent::Go { + player_id: self.player_id, + }) + } else { + Some(GameEvent::Move { + player_id: self.player_id, + moves: self.strategy.choose_move(), + }) + } + } _ => None, }; } diff --git a/bot/src/strategy/client.rs b/bot/src/strategy/client.rs index e4ceae8..4f7b84f 100644 --- a/bot/src/strategy/client.rs +++ b/bot/src/strategy/client.rs @@ -49,6 +49,10 @@ impl BotStrategy for ClientStrategy { self.calculate_points() } + fn choose_go(&self) -> bool { + true + } + fn choose_move(&self) -> (CheckerMove, CheckerMove) { let (dice1, dice2) = match self.color { Color::White => (self.game.dice.values.0 as i8, self.game.dice.values.1 as i8), diff --git a/bot/src/strategy/default.rs b/bot/src/strategy/default.rs index 3677ab0..22482eb 100644 --- a/bot/src/strategy/default.rs +++ b/bot/src/strategy/default.rs @@ -50,6 +50,10 @@ impl BotStrategy for DefaultStrategy { self.calculate_points() } + fn choose_go(&self) -> bool { + true + } + fn choose_move(&self) -> (CheckerMove, CheckerMove) { let rules = MoveRules::new(&self.color, &self.game.board, self.game.dice); let possible_moves = rules.get_possible_moves_sequences(true); diff --git a/store/src/game.rs b/store/src/game.rs index 8d77f6f..cde7001 100644 --- a/store/src/game.rs +++ b/store/src/game.rs @@ -315,6 +315,7 @@ impl GameState { if self.turn_stage != TurnStage::Move && self.turn_stage != TurnStage::HoldOrGoChoice { + error!("bad stage {:?}", self.turn_stage); return false; } let color = &self.players[player_id].color; @@ -326,6 +327,7 @@ impl GameState { *moves }; if !rules.moves_follow_rules(&moves) { + error!("rules not followed "); return false; } } diff --git a/store/src/game_rules_moves.rs b/store/src/game_rules_moves.rs index 249dd10..adc047e 100644 --- a/store/src/game_rules_moves.rs +++ b/store/src/game_rules_moves.rs @@ -72,6 +72,7 @@ impl MoveRules { /// ---- moves_possibles : First of three checks for moves fn moves_possible(&self, moves: &(CheckerMove, CheckerMove)) -> bool { + println!("possible ???"); let color = &Color::White; if let Ok(chained_move) = moves.0.chain(moves.1) { // Check intermediary move and chained_move : "Tout d'une" @@ -84,6 +85,7 @@ impl MoveRules { || !self.board.move_possible(color, &moves.1) { // Move is not physically possible + println!("no phys! {} {:?}", self.board, moves); return false; } true