Change a/b to fail-soft
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user