From c1e99a5f35186596263cf39acef31273ca555b5f Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Sat, 16 Aug 2025 16:39:25 +0200 Subject: [PATCH] wip (tests fails) --- bot/src/dqn/burnrl_big/environment.rs | 6 +----- client_cli/src/app.rs | 1 + client_cli/src/game_runner.rs | 2 +- store/src/game.rs | 22 +++++++++++++++++++++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bot/src/dqn/burnrl_big/environment.rs b/bot/src/dqn/burnrl_big/environment.rs index ccb5322..bb139df 100644 --- a/bot/src/dqn/burnrl_big/environment.rs +++ b/bot/src/dqn/burnrl_big/environment.rs @@ -187,10 +187,6 @@ impl Environment for TrictracEnvironment { // Faire jouer l'adversaire (stratégie simple) if has_played { - print!( - "?({},{:?}) ", - self.game.active_player_id, self.game.turn_stage - ); if self.goodmoves_count > 10 { println!("{:?}", self.game.history); panic!("end debug"); @@ -222,7 +218,6 @@ impl Environment for TrictracEnvironment { // Mettre à jour l'état self.current_state = TrictracState::from_game_state(&self.game); self.episode_reward += reward; - if self.visualized && terminated { println!( "Episode terminé. Récompense totale: {:.2}, Étapes: {}", @@ -373,6 +368,7 @@ impl TrictracEnvironment { /// Fait jouer l'adversaire avec une stratégie simple fn play_opponent_if_needed(&mut self) -> f32 { + print!("z?"); let mut reward = 0.0; // Si c'est le tour de l'adversaire, jouer automatiquement diff --git a/client_cli/src/app.rs b/client_cli/src/app.rs index 519adf1..d400004 100644 --- a/client_cli/src/app.rs +++ b/client_cli/src/app.rs @@ -329,6 +329,7 @@ Player :: holes :: points seed: Some(1327), bot: Some("dummy".into()), }); + println!("avant : {}", app.display()); app.input("roll"); app.input("1 3"); app.input("1 4"); diff --git a/client_cli/src/game_runner.rs b/client_cli/src/game_runner.rs index 797dbc9..9566713 100644 --- a/client_cli/src/game_runner.rs +++ b/client_cli/src/game_runner.rs @@ -77,7 +77,7 @@ impl GameRunner { } else { debug!("{}", self.state); error!("event not valid : {event:?}"); - panic!("crash and burn"); + panic!("crash and burn {} \nevt not valid {event:?}", self.state); &GameEvent::PlayError }; diff --git a/store/src/game.rs b/store/src/game.rs index 2b7fa46..a0356a5 100644 --- a/store/src/game.rs +++ b/store/src/game.rs @@ -338,7 +338,7 @@ impl GameState { return false; } } - Roll { player_id } | RollResult { player_id, dice: _ } => { + Roll { player_id } => { // Check player exists if !self.players.contains_key(player_id) { return false; @@ -347,6 +347,26 @@ impl GameState { if self.active_player_id != *player_id { return false; } + // Check the turn stage + if self.turn_stage != TurnStage::RollWaiting { + error!("bad stage {:?}", self.turn_stage); + return false; + } + } + RollResult { player_id, dice: _ } => { + // Check player exists + if !self.players.contains_key(player_id) { + return false; + } + // Check player is currently the one making their move + if self.active_player_id != *player_id { + return false; + } + // Check the turn stage + if self.turn_stage != TurnStage::RollDice { + error!("bad stage {:?}", self.turn_stage); + return false; + } } Mark { player_id,