Fix and simplify move ordering

This commit is contained in:
stefiosif
2025-01-25 16:39:04 +02:00
parent d8cc3b74a2
commit 62c524174e
4 changed files with 35 additions and 42 deletions

View File

@@ -6,7 +6,7 @@ use crate::{
};
use super::{
move_ordering,
move_ordering::score_move,
quiescence::quiescence,
time::{hard_limit, TimeInfo},
transposition_table::TTEntry,
@@ -33,14 +33,14 @@ pub fn negamax(
return Ok(q_score);
}
let color = game.current_player();
let mut best_move = None;
let mut best_score = MIN_SCORE;
let mut legal_moves = 0;
let all_moves = game.board.pseudo_moves_all();
let color = game.current_player();
let mut best_score = MIN_SCORE;
let mut best_move = None;
let mut moves = game.board.pseudo_moves_all();
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);
moves.sort_unstable_by_key(|mv| score_move(&game.mailbox, *mv, tt_move));
for mv in moves {
game.make_move(&mv);