Convert minimax to negamax and implement alpha-beta pruning

This commit is contained in:
stefiosif
2024-09-03 20:35:08 +03:00
parent ba0cbf4d7d
commit e817229d12
5 changed files with 130 additions and 114 deletions

View File

@@ -3,7 +3,12 @@ use std::{
str::SplitWhitespace,
};
use crate::{board::game::Game, movegen::r#move::Move, search};
use crate::{
board::game::Game,
evaluation::evaluation::{MAX_EVAL, MIN_EVAL},
movegen::r#move::Move,
search,
};
#[derive(PartialEq, Eq, Debug)]
pub enum Command {
@@ -132,11 +137,15 @@ pub fn uci_go(go: &mut SplitWhitespace, game: &mut Game) -> Result<Move, String>
_ => (),
}
}
Ok(
search::minimax::minimax(game, params.depth.unwrap_or(MAX_DEPTH))
.0
.expect("No move selected"),
Ok(search::negamax::negamax(
game,
MIN_EVAL,
MAX_EVAL,
params.depth.unwrap_or(MAX_DEPTH),
0,
)
.0
.expect("No move selected"))
}
pub fn uci_loop<R: BufRead, W: Write>(input: R, mut output: W) -> Result<(), String> {