wip bot mirror
This commit is contained in:
parent
fa9c02084a
commit
f1461985ac
|
|
@ -26,7 +26,7 @@ pub trait BotStrategy: std::fmt::Debug {
|
||||||
pub struct Bot {
|
pub struct Bot {
|
||||||
pub player_id: PlayerId,
|
pub player_id: PlayerId,
|
||||||
strategy: Box<dyn BotStrategy>,
|
strategy: Box<dyn BotStrategy>,
|
||||||
// color: Color,
|
color: Color,
|
||||||
// schools_enabled: bool,
|
// schools_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,19 +52,35 @@ impl Bot {
|
||||||
Color::White => 1,
|
Color::White => 1,
|
||||||
Color::Black => 2,
|
Color::Black => 2,
|
||||||
};
|
};
|
||||||
strategy.set_player_id(player_id);
|
// strategy.set_player_id(player_id);
|
||||||
strategy.set_color(color);
|
// strategy.set_color(color);
|
||||||
Self {
|
Self {
|
||||||
player_id,
|
player_id,
|
||||||
strategy,
|
strategy,
|
||||||
// color,
|
color,
|
||||||
// schools_enabled: false,
|
// schools_enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
|
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
|
||||||
let game = self.strategy.get_mut_game();
|
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 {
|
if game.stage == Stage::Ended {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue