From 223777346a4d8e963af5897b027289a6a7def6c7 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Sat, 21 Feb 2026 18:26:11 +0100 Subject: [PATCH] debug --- store/src/game.rs | 6 ++++-- store/src/game_rules_moves.rs | 12 +++++++++++- store/src/pyengine.rs | 9 ++++----- store/src/training_common.rs | 2 ++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/store/src/game.rs b/store/src/game.rs index edf068b..5191214 100644 --- a/store/src/game.rs +++ b/store/src/game.rs @@ -144,7 +144,7 @@ impl GameState { } pub fn mirror(&self) -> GameState { - // let mirrored_active_player = if self.active_player_id == 1 { 2 } else { 1 }; + let mirrored_active_player = if self.active_player_id == 1 { 2 } else { 1 }; let mut mirrored_players = HashMap::new(); if let Some(p2) = self.players.get(&2) { mirrored_players.insert(1, p2.mirror()); @@ -164,7 +164,8 @@ impl GameState { stage: self.stage, turn_stage: self.turn_stage, board: self.board.mirror(), - active_player_id: self.active_player_id, + active_player_id: mirrored_active_player, + //active_player_id: self.active_player_id, players: mirrored_players, history: mirrored_history, dice: self.dice, @@ -571,6 +572,7 @@ impl GameState { *moves }; if !rules.moves_follow_rules(&moves) { + println!(">>> rules not followed "); error!("rules not followed "); return false; } diff --git a/store/src/game_rules_moves.rs b/store/src/game_rules_moves.rs index 31c43fa..21fce73 100644 --- a/store/src/game_rules_moves.rs +++ b/store/src/game_rules_moves.rs @@ -63,6 +63,7 @@ impl MoveRules { fn get_board_from_color(color: &Color, board: &Board) -> Board { if *color == Color::Black { + println!("get_board_from_color -> mirror of {}", board); board.mirror() } else { board.clone() @@ -74,6 +75,7 @@ impl MoveRules { moves: &(CheckerMove, CheckerMove), // ignored_rules: Vec, ) -> bool { + println!("in moves_follow_rules"); // Check moves possibles on the board // Check moves conforms to the dice // Check move is allowed by the rules (to desactivate when playing with schools) @@ -81,7 +83,8 @@ impl MoveRules { let is_allowed = self.moves_allowed(moves); // let is_allowed = self.moves_allowed(moves, ignored_rules); if is_allowed.is_err() { - info!("Move not allowed : {:?}", is_allowed.unwrap_err()); + println!("Move not allowed : {:?}", is_allowed.unwrap_err()); + // info!("Move not allowed : {:?}", is_allowed.unwrap_err()); false } else { true @@ -99,6 +102,7 @@ impl MoveRules { if let Ok((field_count, Some(field_color))) = self.board.get_field_checkers(move0_from) { if color != field_color || field_count < 2 { + println!("Move not physically possible 1"); info!("Move not physically possible"); return false; } @@ -110,6 +114,7 @@ impl MoveRules { if !self.board.passage_possible(color, &moves.0) || !self.board.move_possible(color, &chained_move) { + println!("Tout d'une : Move not physically possible"); info!("Tout d'une : Move not physically possible"); return false; } @@ -117,6 +122,11 @@ impl MoveRules { || !self.board.move_possible(color, &moves.1) { // Move is not physically possible + println!("Move not physically possible 2"); + println!( + "board: {}, color: {:?} move: {:?}", + self.board, color, moves + ); info!("Move not physically possible"); return false; } diff --git a/store/src/pyengine.rs b/store/src/pyengine.rs index 4dbd966..e5779df 100644 --- a/store/src/pyengine.rs +++ b/store/src/pyengine.rs @@ -58,8 +58,8 @@ impl TricTrac { get_valid_action_indices(&self.game_state) } else { let mirror = self.game_state.mirror(); - println!("get validd actions for mirror"); - println!("{}", mirror); + println!("get valid actions for mirror"); + println!("/////{}", mirror); get_valid_action_indices(&mirror) } } else { @@ -92,14 +92,13 @@ impl TricTrac { if let Some(event) = TrictracAction::from_action_index(action_idx).and_then(|a| a.to_event(&self.game_state)) { - println!(">get event {:?}", event); - + println!("apply action on {:?} ", event); let event = if self.game_state.active_player_id == 2 { event.get_mirror(true) } else { event }; - println!("validating event {:?}", event); + println!("validating event {:?} on state {}", event, self.game_state); if self.game_state.validate(&event) { println!("valid event"); self.game_state.consume(&event); diff --git a/store/src/training_common.rs b/store/src/training_common.rs index 86f03ae..2abda34 100644 --- a/store/src/training_common.rs +++ b/store/src/training_common.rs @@ -196,6 +196,7 @@ pub fn get_valid_actions(game_state: &GameState) -> Vec { let player_color = game_state.player_color_by_id(&active_player_id); if let Some(color) = player_color { + println!("in get_valid_actions, color = {:?}", color); match game_state.turn_stage { TurnStage::RollDice => { valid_actions.push(TrictracAction::Roll); @@ -229,6 +230,7 @@ pub fn get_valid_actions(game_state: &GameState) -> Vec { } for (move1, move2) in possible_moves { + println!("adding moves {:?} {:?}", move1, move2); valid_actions.push(checker_moves_to_trictrac_action( &move1, &move2, &color, game_state, ));