Refactor based on clippy, move tt to search module and call iterative deepening from uci_go

This commit is contained in:
stefiosif
2024-11-03 01:19:12 +02:00
parent 802bdcdb37
commit 1b28de5064
11 changed files with 67 additions and 92 deletions

View File

@@ -4,10 +4,9 @@ use std::{
};
use crate::{
board::{game::Game, transposition_table::TranspositionTable},
evaluation::{MAX_SCORE, MIN_SCORE},
board::game::Game,
movegen::r#move::Move,
search,
search::{self, MAX_DEPTH, MOVE_TIME},
};
#[derive(PartialEq, Eq, Debug)]
@@ -117,8 +116,6 @@ pub fn uci_position(position: &mut SplitWhitespace) -> Result<Game, String> {
Ok(game)
}
const MAX_DEPTH: u8 = 3;
pub fn uci_go(go: &mut SplitWhitespace, game: &mut Game) -> Result<Move, String> {
let mut params = UciParameters::new();
while let Some(subcommand) = go.next() {
@@ -142,18 +139,11 @@ pub fn uci_go(go: &mut SplitWhitespace, game: &mut Game) -> Result<Move, String>
_ => (),
}
}
let mut tt = TranspositionTable::new(1000000);
Ok(search::negamax::negamax(
game,
MIN_SCORE,
MAX_SCORE,
params.depth.unwrap_or(MAX_DEPTH),
0,
&mut tt,
&mut 0,
Ok(
search::iterative_deepening::iterative_deepening(game, MAX_DEPTH, MOVE_TIME)
.expect("No move selected"),
)
.0
.expect("No move selected"))
}
pub fn uci_loop<R: BufRead, W: Write>(input: R, mut output: W) -> Result<(), String> {