From 447ec8cc58c625e1ab7f4e08904271b4c4b36eba Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Sat, 4 Jan 2025 19:32:51 +0100 Subject: [PATCH] fix: 2 bots handling --- bot/src/lib.rs | 6 ++++-- client_cli/src/game_runner.rs | 2 +- devenv.nix | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bot/src/lib.rs b/bot/src/lib.rs index e6766b3..bb28411 100644 --- a/bot/src/lib.rs +++ b/bot/src/lib.rs @@ -58,8 +58,10 @@ impl Bot { pub fn handle_event(&mut self, event: &GameEvent) -> Option { let game = self.strategy.get_mut_game(); game.consume(event); - // println!("bot game {:?}", self.game); - // println!("bot player_id {:?}", self.player_id); + // println!( + // "bot player_id {:?} (active player_id {:?})", + // self.player_id, game.active_player_id + // ); if game.active_player_id == self.player_id { return match game.turn_stage { TurnStage::MarkAdvPoints => Some(GameEvent::Mark { diff --git a/client_cli/src/game_runner.rs b/client_cli/src/game_runner.rs index 5a1f249..8639916 100644 --- a/client_cli/src/game_runner.rs +++ b/client_cli/src/game_runner.rs @@ -69,12 +69,12 @@ impl GameRunner { let bot_events: Vec = self .bots .iter_mut() - .filter(|bot| Some(bot.player_id) != event.player_id()) .filter_map(|bot| bot.handle_event(event)) .collect(); let mut next_event = None; for bot_event in bot_events { + println!("bot event {:?}", bot_event); let bot_result_event = self.handle_event(&bot_event); if let Some(bot_id) = bot_event.player_id() { next_event = if self.bot_needs_dice_roll(bot_id) { diff --git a/devenv.nix b/devenv.nix index 127c215..75f70f9 100644 --- a/devenv.nix +++ b/devenv.nix @@ -4,13 +4,14 @@ # https://devenv.sh/basics/ # env.GREET = "devenv"; - packages = [ + packages = [ # for bevy pkgs.alsaLib pkgs.udev # bevy fast compile - pkgs.clang pkgs.lld + pkgs.clang + pkgs.lld # copiƩ de https://github.com/mmai/Hyperspeedcube/blob/develop/devenv.nix # TODO : retirer ce qui est inutile @@ -27,7 +28,8 @@ pkgs.xorg.libXi pkgs.xorg.libX11 - pkgs.vulkan-headers pkgs.vulkan-loader + pkgs.vulkan-headers + pkgs.vulkan-loader # ------------ fin copie ]; @@ -44,7 +46,7 @@ # scripts.hello.exec = "echo hello from $GREET"; # https://devenv.sh/pre-commit-hooks/ - pre-commit.hooks.shellcheck.enable = true; + # pre-commit.hooks.shellcheck.enable = true; # https://devenv.sh/processes/ # processes.ping.exec = "ping example.com";