fix: 2 bots handling

This commit is contained in:
Henri Bourcereau 2025-01-04 19:32:51 +01:00
parent 2fe2f66c13
commit 447ec8cc58
3 changed files with 11 additions and 7 deletions

View file

@ -58,8 +58,10 @@ impl Bot {
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
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 {

View file

@ -69,12 +69,12 @@ impl GameRunner {
let bot_events: Vec<GameEvent> = 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) {

View file

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