mirror of
https://github.com/Noratrieb/minmax.git
synced 2026-01-14 23:35:04 +01:00
wrap
This commit is contained in:
parent
5bfabd3cec
commit
6b5347b196
5 changed files with 89 additions and 20 deletions
|
|
@ -27,6 +27,10 @@ impl Connect4 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_pos(&mut self, position: usize, value: Position) {
|
||||
self.positions[position] = value;
|
||||
}
|
||||
|
||||
pub fn result(&self) -> State {
|
||||
match self.check_board() {
|
||||
State::Winner(winner) => State::Winner(winner),
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ impl Score {
|
|||
Self(int)
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn randomize(self) -> Self {
|
||||
let score = self.0 as f32;
|
||||
let rand = rand::thread_rng();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ impl<G: Game> PerfectPlayer<G> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn best_move(&self) -> G::Move {
|
||||
self.best_move.expect("no move made yet")
|
||||
}
|
||||
|
||||
fn minmax(&mut self, board: &mut G, player: Player, depth: usize) -> Score {
|
||||
if let Some(max_depth) = self.max_depth && depth >= max_depth {
|
||||
return board.rate(player);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue