This commit is contained in:
Henri Bourcereau 2025-08-06 21:18:24 +02:00
parent be027c8ec4
commit 0dea88033e
2 changed files with 14 additions and 11 deletions

View file

@ -71,7 +71,7 @@ impl Bot {
event
};
let init_player_points = game.who_plays().map(|p| p.points);
let init_player_points = game.who_plays().map(|p| (p.points, p.holes));
let turn_stage = game.turn_stage;
game.consume(internal_event);
if game.stage == Stage::Ended {
@ -87,11 +87,10 @@ impl Bot {
game.active_player_id
};
if active_player_id == self.player_id {
let player_points = game.who_plays().map(|p| p.points);
let player_points = game.who_plays().map(|p| (p.points, p.holes));
if self.color == Color::Black {
println!(
" input evt : {:?}, {:?}, {:?}",
internal_event, init_player_points, turn_stage
" input (internal) evt : {internal_event:?}, {init_player_points:?}, {turn_stage:?}"
);
}
let internal_event = match game.turn_stage {
@ -121,10 +120,7 @@ impl Bot {
_ => None,
};
return if self.color == Color::Black {
println!(
" bot evt : {:?} - {:?}",
internal_event, player_points
);
println!(" bot (internal) evt : {internal_event:?} - {player_points:?}");
internal_event.map(|evt| evt.get_mirror())
} else {
internal_event

View file

@ -91,7 +91,8 @@ impl fmt::Display for GameState {
s.push_str(&format!("Dice: {:?}\n", self.dice));
// s.push_str(&format!("Who plays: {}\n", self.who_plays().map(|player| &player.name ).unwrap_or("")));
s.push_str(&format!("Board: {:?}\n", self.board));
write!(f, "{}", s)
// s.push_str(&format!("History: {:?}\n", self.history));
write!(f, "{s}")
}
}
@ -372,7 +373,7 @@ impl GameState {
}
Go { player_id } => {
if !self.players.contains_key(player_id) {
error!("Player {} unknown", player_id);
error!("Player {player_id} unknown");
return false;
}
// Check player is currently the one making their move
@ -383,13 +384,19 @@ impl GameState {
// Check the player can leave (ie the game is in the KeepOrLeaveChoice stage)
if self.turn_stage != TurnStage::HoldOrGoChoice {
error!("bad stage {:?}", self.turn_stage);
error!(
"black player points : {:?}",
self.get_black_player()
.map(|player| (player.points, player.holes))
);
// error!("history {:?}", self.history);
return false;
}
}
Move { player_id, moves } => {
// Check player exists
if !self.players.contains_key(player_id) {
error!("Player {} unknown", player_id);
error!("Player {player_id} unknown");
return false;
}
// Check player is currently the one making their move