Forráskód Böngészése

adding no hash move ordering

Nicolas Winkler 3 éve
szülő
commit
a924f9742a
2 módosított fájl, 10 hozzáadás és 2 törlés
  1. 9 1
      src/movegen.rs
  2. 1 1
      src/search.rs

+ 9 - 1
src/movegen.rs

@@ -201,7 +201,6 @@ pub fn generate_attacking_moves(game: &Game, side: Side) -> Vec<Move> {
 
 
 pub fn sort_moves(game: &mut Game, hash: &mut Cache, move_list: &mut Vec<Move>) {
-
     move_list.sort_by_cached_key(|mov| {
         let undo = game.apply(*mov);
         if let Some(e) = hash.lookup(game) {
@@ -227,6 +226,15 @@ pub fn sort_moves(game: &mut Game, hash: &mut Cache, move_list: &mut Vec<Move>)
     });
 }
 
+pub fn sort_moves_no_hash(game: &mut Game, move_list: &mut Vec<Move>) {
+    move_list.sort_by_cached_key(|mov| {
+        let undo = game.apply(*mov);
+        let eval = crate::evaluate::evaluate(game);
+        game.undo_move(undo);
+        return eval;
+    });
+}
+
 
 fn generate_pawn_pushes(game: &Game, side: Side, move_list: &mut Vec<Move>) {
     let pawns = game.pawns(side);

+ 1 - 1
src/search.rs

@@ -258,7 +258,7 @@ fn quiescence_search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache,
 
     let mut moves = generate_attacking_moves(game, game.turn);
 
-    sort_moves(game, hash, &mut moves);
+    sort_moves_no_hash(game, &mut moves);
 
     for mov in moves {
         let undo = game.apply(mov);