From 688d6174e3ef81158ca6d0078748d9aff2fafd2e Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Wed, 25 Feb 2026 15:56:54 +0100 Subject: [PATCH] fix: training : exit board moves --- store/src/game_rules_moves.rs | 2 -- store/src/pyengine.rs | 16 +++------------- store/src/training_common.rs | 8 ++++++++ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/store/src/game_rules_moves.rs b/store/src/game_rules_moves.rs index 625baec..aefc94e 100644 --- a/store/src/game_rules_moves.rs +++ b/store/src/game_rules_moves.rs @@ -63,7 +63,6 @@ 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() @@ -75,7 +74,6 @@ 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) diff --git a/store/src/pyengine.rs b/store/src/pyengine.rs index 7fb00b2..7577954 100644 --- a/store/src/pyengine.rs +++ b/store/src/pyengine.rs @@ -1,20 +1,14 @@ //! # Expose trictrac game state and rules in a python module use pyo3::prelude::*; -use pyo3::types::PyDict; -use crate::board::CheckerMove; -use crate::dice::{Dice, DiceRoller}; +use crate::dice::Dice; use crate::game::{GameEvent, GameState, Stage, TurnStage}; -use crate::game_rules_moves::MoveRules; -use crate::game_rules_points::PointsRules; -use crate::player::{Color, PlayerId}; +use crate::player::PlayerId; use crate::training_common::{get_valid_action_indices, TrictracAction}; #[pyclass] struct TricTrac { game_state: GameState, - dice_roll_sequence: Vec<(u8, u8)>, - current_dice_index: usize, } #[pymethods] @@ -30,11 +24,7 @@ impl TricTrac { // Commencer la partie avec le joueur 1 game_state.consume(&GameEvent::BeginGame { goes_first: 1 }); - TricTrac { - game_state, - dice_roll_sequence: Vec::new(), - current_dice_index: 0, - } + TricTrac { game_state } } fn needs_roll(&self) -> bool { diff --git a/store/src/training_common.rs b/store/src/training_common.rs index 86f03ae..6427ea4 100644 --- a/store/src/training_common.rs +++ b/store/src/training_common.rs @@ -117,6 +117,10 @@ impl TrictracAction { .get_checker_field(color, *checker1 as u8) .unwrap_or(0); let mut to1 = from1 + dice1 as usize; + if 24 < to1 { + // exit board + to1 = 0; + } let checker_move1 = CheckerMove::new(from1, to1).unwrap_or_default(); let mut tmp_board = state.board.clone(); @@ -129,6 +133,10 @@ impl TrictracAction { .get_checker_field(color, *checker2 as u8) .unwrap_or(0); let mut to2 = from2 + dice2 as usize; + if 24 < to2 { + // exit board + to2 = 0; + } // Gestion prise de coin par puissance let opp_rest_field = 13;