Nicolas Winkler před 3 roky
rodič
revize
ab48293218
1 změnil soubory, kde provedl 21 přidání a 16 odebrání
  1. 21 16
      src/search.rs

+ 21 - 16
src/search.rs

@@ -5,7 +5,7 @@ use evaluate::*;
 use log::info;
 use rand::prelude::*;
 use std::collections::HashMap;
-use hash::{CacheEntry, Cache};
+use hash::*;
 
 enum MoveUndo {
     Default {
@@ -78,10 +78,17 @@ pub fn search(game: &Game, sc: &mut SearchControl, hash: &mut Cache, depth: i32)
             match he.entry_type {
                 EntryType::Value => {
                     if he.depth >= depth {
+                        info!("table hit!");
                         valued_moves.push((mov, he.value));
                         continue;
                     }
-                }
+                },
+                EntryType::UpperBound => {
+                    /*if he.depth >= depth {
+                        if 
+                    }*/
+                },
+                _ => {}
             }
         }
 
@@ -253,20 +260,18 @@ pub fn apply_move(game: &Game, mov: Move) -> Game {
                 new_game.castling_rights[if game.turn == BLACK { 3 } else { 1 }] = false;
             }
 
-            if pt == ROOK {
-                // invalidate castling rights
-                if mov.from == square_from_indices(7, 7) {
-                    new_game.castling_rights[0] = false;
-                }
-                else if mov.from == square_from_indices(0, 7) {
-                    new_game.castling_rights[1] = false;
-                }
-                else if mov.from == square_from_indices(7, 7) {
-                    new_game.castling_rights[2] = false;
-                }
-                else if mov.from == square_from_indices(7, 7) {
-                    new_game.castling_rights[3] = false;
-                }
+            // invalidate castling rights
+            if mov.from == square_from_indices(7, 0) || mov.to == square_from_indices(7, 0) {
+                new_game.castling_rights[0] = false;
+            }
+            if mov.from == square_from_indices(0, 0) || mov.to == square_from_indices(0, 0) {
+                new_game.castling_rights[1] = false;
+            }
+            if mov.from == square_from_indices(7, 7) || mov.to == square_from_indices(7, 7) {
+                new_game.castling_rights[2] = false;
+            }
+            if mov.from == square_from_indices(0, 7) || mov.to == square_from_indices(0, 7) {
+                new_game.castling_rights[3] = false;
             }
 
             if from_square(mov.to) | others != 0 {