wip bot mirror

This commit is contained in:
Henri Bourcereau 2025-08-04 18:04:40 +02:00
parent fa9c02084a
commit f1461985ac

View file

@ -26,7 +26,7 @@ pub trait BotStrategy: std::fmt::Debug {
pub struct Bot {
pub player_id: PlayerId,
strategy: Box<dyn BotStrategy>,
// 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<GameEvent> {
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;
}