summaryrefslogtreecommitdiff
path: root/ui/src/main.rs
diff options
context:
space:
mode:
authorMike White <botahamec@outlook.com>2021-09-18 22:49:34 -0400
committerMike White <botahamec@outlook.com>2021-09-18 22:49:34 -0400
commit86273330cd6e09b1fe4b9c6efbfb9c56033e28bd (patch)
tree9013aa83df8edf4da89837a0732e13903a7ea898 /ui/src/main.rs
parentf0f18161c6a20db901cfd285491b8677e4c41851 (diff)
Created a transposition table and fixed some bugs
Diffstat (limited to 'ui/src/main.rs')
-rw-r--r--ui/src/main.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/ui/src/main.rs b/ui/src/main.rs
index 2b4bd17..c25c0d7 100644
--- a/ui/src/main.rs
+++ b/ui/src/main.rs
@@ -19,6 +19,7 @@ struct GameState {
bit_board: CheckersBitBoard,
selected_square: Option<SquareCoordinate>,
possible_moves: HashSet<Move>,
+ evaluation: f32,
}
impl GameState {
@@ -33,6 +34,7 @@ impl GameState {
bit_board: CheckersBitBoard::starting_position(),
selected_square: None,
possible_moves: HashSet::new(),
+ evaluation: 0.5,
})
}
}
@@ -75,8 +77,18 @@ impl State for GameState {
// safety: this was determined to be in the list of possible moves
self.bit_board = unsafe { selected_move.apply_to(self.bit_board) };
+ // ai makes a move
+ while self.bit_board.turn() == PieceColor::Light
+ && !PossibleMoves::moves(self.bit_board).is_empty()
+ {
+ let best_move = ai::best_move(12, self.bit_board);
+ self.bit_board = unsafe { best_move.apply_to(self.bit_board) };
+ }
+
self.selected_square = None;
self.possible_moves.clear();
+ self.evaluation = ai::eval_multithreaded(12, 0.0, 1.0, self.bit_board);
+ println!("{}", self.evaluation);
} else {
self.selected_square = Some(square);