From f1461985acf3920b3dd7d8c9b334d866f9e6d3cc Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Mon, 4 Aug 2025 18:04:40 +0200 Subject: [PATCH] wip bot mirror --- bot/src/lib.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/bot/src/lib.rs b/bot/src/lib.rs index 65424fc..abb49bc 100644 --- a/bot/src/lib.rs +++ b/bot/src/lib.rs @@ -26,7 +26,7 @@ pub trait BotStrategy: std::fmt::Debug { pub struct Bot { pub player_id: PlayerId, strategy: Box, - // color: Color, + color: Color, // schools_enabled: bool, } @@ -52,19 +52,35 @@ impl Bot { Color::White => 1, Color::Black => 2, }; - strategy.set_player_id(player_id); - strategy.set_color(color); + // strategy.set_player_id(player_id); + // strategy.set_color(color); Self { player_id, strategy, - // color, + color, // schools_enabled: false, } } pub fn handle_event(&mut self, event: &GameEvent) -> Option { let game = self.strategy.get_mut_game(); - game.consume(event); + let mirror_event = if let GameEvent::Move { + player_id, + moves: (move1, move2), + } = event + { + &GameEvent::Move { + player_id: *player_id, + moves: (move1.mirror(), move2.mirror()), + } + } else { + event + }; + game.consume(if self.color == Color::White { + event + } else { + mirror_event + }); if game.stage == Stage::Ended { return None; }