Bladeren bron

slight eval changes

Nicolas Winkler 3 jaren geleden
bovenliggende
commit
cc05428ca1
2 gewijzigde bestanden met toevoegingen van 12 en 10 verwijderingen
  1. 4 1
      src/evaluate.rs
  2. 8 9
      src/search.rs

+ 4 - 1
src/evaluate.rs

@@ -101,8 +101,11 @@ fn knight_value(game: &Game, side: Side) -> PosValue {
 
     let num_opp_pawns = game.get_piece(PAWN, !side).count_ones() as PosValue;
     let num_knights = game.get_piece(KNIGHT, side).count_ones() as PosValue;
+
+    let center = (ROW_4 | ROW_5) & (FILE_D | FILE_E);
+    let center_knights = (game.get_piece(KNIGHT, side) & center).count_ones() as PosValue;
     
-    k_attacks as PosValue + ((num_knights * 75 * num_opp_pawns) / 8) as PosValue
+    center_knights * 20 + k_attacks as PosValue + ((num_knights * 75 * num_opp_pawns) / 8) as PosValue
 }
 
 fn material_value(game: &Game, side: Side) -> PosValue {

+ 8 - 9
src/search.rs

@@ -59,7 +59,7 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alp
 
     // use a slight offset for the alpha value in the root node in order to
     // determine possibly multiple good moves
-    const ALPHA_OFFSET: PosValue = 50 as PosValue;
+    const ALPHA_OFFSET: PosValue = 0 as PosValue;
 
     let mut valued_moves: Vec<(Move, PosValue)> = Vec::with_capacity(moves.len());
     let mut cancelled = false;
@@ -81,24 +81,23 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alp
             break;
         }
 
-        /*if val >= mate_in_p1(1) {
+        if val >= mate_in_p1(1) {
             // mate in 1 --- can't get better than that
             info!("yay mate!");
             return SearchResult::Finished(mov, increase_mate_in(val));
-        }*/
+        }
 
         //info!("searched {} -> {}", mov.to_string(), val);
 
         if val > alpha {
             alpha = val - ALPHA_OFFSET;
+            valued_moves.push((mov, -val));
         }
-
-        valued_moves.push((mov, -val));
     }
 
 
 
-    info!("movvalues: {:?}", valued_moves.iter().map(|mv| mv.0.to_string() + " - " + &mv.1.to_string()).collect::<Vec<String>>());
+    //info!("movvalues: {:?}", valued_moves.iter().map(|mv| mv.0.to_string() + " - " + &mv.1.to_string()).collect::<Vec<String>>());
 
     valued_moves.sort_by_key(|mv| mv.1);
 
@@ -134,19 +133,19 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
                 //EntryType::Value => { if e.value >= alpha { return (e.value, false); } else { return (alpha, false); } },
                 //EntryType::LowerBound => { if e.value > alpha { return (e.value, false) } },
                 EntryType::LowerBound => {
-                    if e.value < alpha { return (alpha, false); }
+                    if e.value >= beta { return (beta, false); }
                     //if e.value >= beta { return (beta, false); }
                 },
                 //EntryType::UpperBound => { if e.value >= beta { return (beta, false); } },
                 EntryType::UpperBound => {
-                    if e.value >= beta { return (beta, false); }
+                    if e.value < alpha { return (alpha, false); }
                 },
             }
         }
     }
 
     if depth == 0 {
-        return quiescence_search(game, sc, hash, alpha, beta, 13);
+        return quiescence_search(game, sc, hash, alpha, beta, 9);
     }
 
     sc.nodes += 1;