fix: training : exit board moves

This commit is contained in:
Henri Bourcereau 2026-02-25 15:56:54 +01:00
parent d53b65c947
commit 688d6174e3
3 changed files with 11 additions and 15 deletions

View file

@ -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<TricTracRule>,
) -> 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)

View file

@ -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 {

View file

@ -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;