wip
This commit is contained in:
parent
be027c8ec4
commit
0dea88033e
|
|
@ -71,7 +71,7 @@ impl Bot {
|
||||||
event
|
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;
|
let turn_stage = game.turn_stage;
|
||||||
game.consume(internal_event);
|
game.consume(internal_event);
|
||||||
if game.stage == Stage::Ended {
|
if game.stage == Stage::Ended {
|
||||||
|
|
@ -87,11 +87,10 @@ impl Bot {
|
||||||
game.active_player_id
|
game.active_player_id
|
||||||
};
|
};
|
||||||
if active_player_id == self.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 {
|
if self.color == Color::Black {
|
||||||
println!(
|
println!(
|
||||||
" input evt : {:?}, {:?}, {:?}",
|
" input (internal) evt : {internal_event:?}, {init_player_points:?}, {turn_stage:?}"
|
||||||
internal_event, init_player_points, turn_stage
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let internal_event = match game.turn_stage {
|
let internal_event = match game.turn_stage {
|
||||||
|
|
@ -121,10 +120,7 @@ impl Bot {
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
return if self.color == Color::Black {
|
return if self.color == Color::Black {
|
||||||
println!(
|
println!(" bot (internal) evt : {internal_event:?} - {player_points:?}");
|
||||||
" bot evt : {:?} - {:?}",
|
|
||||||
internal_event, player_points
|
|
||||||
);
|
|
||||||
internal_event.map(|evt| evt.get_mirror())
|
internal_event.map(|evt| evt.get_mirror())
|
||||||
} else {
|
} else {
|
||||||
internal_event
|
internal_event
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,8 @@ impl fmt::Display for GameState {
|
||||||
s.push_str(&format!("Dice: {:?}\n", self.dice));
|
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!("Who plays: {}\n", self.who_plays().map(|player| &player.name ).unwrap_or("")));
|
||||||
s.push_str(&format!("Board: {:?}\n", self.board));
|
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 } => {
|
Go { player_id } => {
|
||||||
if !self.players.contains_key(player_id) {
|
if !self.players.contains_key(player_id) {
|
||||||
error!("Player {} unknown", player_id);
|
error!("Player {player_id} unknown");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check player is currently the one making their move
|
// 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)
|
// Check the player can leave (ie the game is in the KeepOrLeaveChoice stage)
|
||||||
if self.turn_stage != TurnStage::HoldOrGoChoice {
|
if self.turn_stage != TurnStage::HoldOrGoChoice {
|
||||||
error!("bad stage {:?}", self.turn_stage);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Move { player_id, moves } => {
|
Move { player_id, moves } => {
|
||||||
// Check player exists
|
// Check player exists
|
||||||
if !self.players.contains_key(player_id) {
|
if !self.players.contains_key(player_id) {
|
||||||
error!("Player {} unknown", player_id);
|
error!("Player {player_id} unknown");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check player is currently the one making their move
|
// Check player is currently the one making their move
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue