1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// use std::{thread, time::Duration};
// use chess::{ChessMove, Board, MoveGen, Square};
// use crate::board::Evaluation;
// use super::Player;
// #[derive(Debug, Clone, Copy, PartialEq, Default)]
// pub struct SearchBot;
// impl Player for SearchBot {
// fn get_move(board: Board, num_moves: usize, bot_wait_ms: u64) -> Result<ChessMove, ()> {
// if bot_wait_ms > 0 { thread::sleep(Duration::from_millis(bot_wait_ms)) };
// let move_gen = MoveGen::new_legal(&board);
// // King's Pawn opener
// match num_moves {
// 0 => return Ok(ChessMove::new(Square::E2, Square::E4, None)),
// 1 => return Ok(ChessMove::new(Square::E7, Square::E5, None)),
// _ => ()
// };
// // check every line
// let mut best_move = (ChessMove::default(), 1E-10);
// for j in move_gen {
// let temp_board = board.make_move_new(j);
// let score = search(temp_board, 5);
// if score > best_move.1 {
// best_move = (j, score);
// // println!("{:?}", best_move);
// }
// }
// println!("{:?}", best_move);
// Ok(best_move.0)
// }
// }
// fn search(board: Board, depth_remaining: usize) -> f32 {
// if depth_remaining == 0 {
// return board.evaluate();
// }
// let mut best_score = -1E10;
// for j in MoveGen::new_legal(&board) {
// let score = search(board.make_move_new(j), depth_remaining - 1);
// if score > best_score {
// best_score = score;
// }
// }
// best_score
// }