Change a/b to fail-soft

This commit is contained in:
stefiosif
2025-01-25 09:16:51 +02:00
parent 29d69b5ab1
commit d8cc3b74a2
2 changed files with 17 additions and 14 deletions

View File

@@ -36,7 +36,6 @@ pub fn negamax(
let color = game.current_player();
let mut best_move = None;
let mut best_score = MIN_SCORE;
let mate_score = -MATE_SCORE + plies as i32;
let mut legal_moves = 0;
let all_moves = game.board.pseudo_moves_all();
@@ -57,23 +56,21 @@ pub fn negamax(
if score > best_score {
best_score = score;
best_move = Some(mv);
}
if score >= beta {
best_score = beta;
best_move = Some(mv);
break;
}
if score > alpha {
alpha = score;
best_move = Some(mv);
}
if score >= beta {
break;
}
}
if legal_moves == 0 {
if game.board.king_under_check(color) {
return Ok(mate_score);
return Ok(-MATE_SCORE + plies as i32);
}
return Ok(0);
}