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);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn quiescence(game: &mut Game, mut alpha: i32, beta: i32, time_info: &TimeIn
|
||||
let stand_pat = pesto().eval(game);
|
||||
|
||||
if stand_pat >= beta {
|
||||
return Ok(beta);
|
||||
return Ok(stand_pat);
|
||||
}
|
||||
|
||||
if stand_pat > alpha {
|
||||
@@ -26,6 +26,7 @@ pub fn quiescence(game: &mut Game, mut alpha: i32, beta: i32, time_info: &TimeIn
|
||||
let all_moves = game.board.pseudo_moves_all_captures();
|
||||
let tt_move = game.tt.lookup(game.hash).and_then(|entry| entry.mv);
|
||||
let moves = move_ordering::sort_moves(all_moves, &game.mailbox, tt_move);
|
||||
let mut best_score = stand_pat;
|
||||
|
||||
for mv in moves {
|
||||
game.make_move(&mv);
|
||||
@@ -38,14 +39,19 @@ pub fn quiescence(game: &mut Game, mut alpha: i32, beta: i32, time_info: &TimeIn
|
||||
let score = -quiescence(game, -beta, -alpha, time_info)?;
|
||||
game.unmake_move();
|
||||
|
||||
if score >= beta {
|
||||
return Ok(beta);
|
||||
|
||||
if score > best_score {
|
||||
best_score = score;
|
||||
}
|
||||
|
||||
if score > alpha {
|
||||
alpha = score
|
||||
alpha = score;
|
||||
}
|
||||
|
||||
if score >= beta {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(alpha)
|
||||
Ok(best_score)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user