Add check extention
This commit is contained in:
@@ -16,7 +16,7 @@ pub fn negamax(
|
||||
game: &mut Game,
|
||||
mut alpha: i32,
|
||||
beta: i32,
|
||||
depth: u8,
|
||||
mut depth: u8,
|
||||
plies: u8,
|
||||
time: &TimeInfo,
|
||||
nodes: &mut u64,
|
||||
@@ -29,13 +29,19 @@ pub fn negamax(
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
let color = game.current_player();
|
||||
let in_check = game.board.king_under_check(color);
|
||||
|
||||
if in_check {
|
||||
depth += 1;
|
||||
}
|
||||
|
||||
if depth == 0 {
|
||||
let q_score = quiescence(game, alpha, beta, time, nodes).map_err(|e| anyhow!("{e}"))?;
|
||||
return Ok(q_score);
|
||||
}
|
||||
|
||||
let mut legal_moves = 0;
|
||||
let color = game.current_player();
|
||||
let mut best_score = MIN_SCORE;
|
||||
let mut best_move = None;
|
||||
let mut moves = game.board.pseudo_moves_all();
|
||||
@@ -101,7 +107,7 @@ pub fn negamax(
|
||||
}
|
||||
|
||||
if legal_moves == 0 {
|
||||
if game.board.king_under_check(color) {
|
||||
if in_check {
|
||||
return Ok(-MATE_SCORE + plies as i32);
|
||||
}
|
||||
return Ok(0);
|
||||
|
||||
Reference in New Issue
Block a user