فهرست منبع

adding tweaks and psqt struct

Nicolas Winkler 2 سال پیش
والد
کامیت
18054d27b4
5فایلهای تغییر یافته به همراه38 افزوده شده و 4 حذف شده
  1. 4 0
      src/evaluate.rs
  2. 1 2
      src/main.rs
  3. 1 1
      src/movegen.rs
  4. 24 0
      src/psqt.rs
  5. 8 1
      src/search.rs

+ 4 - 0
src/evaluate.rs

@@ -4,6 +4,8 @@ use movegen::*;
 
 use std::i32;
 
+use crate::psqt::PAWN_PST;
+
 ///
 /// type that is returned by the evaluate funcion
 /// 
@@ -199,6 +201,8 @@ pub fn evaluate(game: &Board) -> PosValue {
 
     let mat_val = (material_value_us) - (material_value_them) as PosValue;
 
+    //let pawn_pst = PAWN_PST.score_bitboard(game.pawns(game.turn)) - PAWN_PST.score_bitboard(game.pawns(!game.turn));
+
     let kv = knight_value(game, game.turn) - knight_value(game, !game.turn);
     let king_safety = king_safety(game, game.turn) - king_safety(game, !game.turn);
     let king_there = king_there(game, game.turn) - king_there(game, !game.turn);

+ 1 - 2
src/main.rs

@@ -1,5 +1,3 @@
-#![feature(const_for)]
-#![feature(const_mut_refs)]
 pub mod uci;
 pub mod bitboard;
 pub mod movegen;
@@ -11,6 +9,7 @@ pub mod zobrist;
 pub mod ttable;
 pub mod settings;
 pub mod magic;
+pub mod psqt;
 
 extern crate log;
 extern crate simplelog;

+ 1 - 1
src/movegen.rs

@@ -389,7 +389,7 @@ impl Iterator for MoveGenerator {
                             let side = self.side;
                             for q in &mut self.quiets {
                                 let score = countermoves.get_score(side, lm, *q);
-                                if score != 0 {
+                                if score > 0 {
                                     self.counters.push((*q, score));
                                     *q = Move::nullmove();
                                 }

+ 24 - 0
src/psqt.rs

@@ -0,0 +1,24 @@
+use std::iter::Sum;
+
+use crate::bitboard::{Bitboard, square};
+use crate::movegen::BitboardIterator;
+
+
+pub const PAWN_PST: PieceSquareTable<i16> = PieceSquareTable{
+    board:
+    [
+        0; 64
+    ]
+};
+
+
+pub struct PieceSquareTable<T: Sum + Copy> {
+    pub board: [T; 64],
+}
+
+
+impl<T: Sum + Copy> PieceSquareTable<T> {
+    pub fn score_bitboard(&self, b: Bitboard) -> T {
+        BitboardIterator(b).map(|bit| self.board[square(bit) as usize]).sum()
+    }
+}

+ 8 - 1
src/search.rs

@@ -377,12 +377,19 @@ pub fn negamax(game: &mut Board, sc: &mut SearchControl, hash: &mut Cache, mut a
 
     if let Some(e) = &cache_entry {
         if e.depth() as i32 >= depth {
-            //println!("TABLE HIT!");
             match e.entry_type {
                 EntryType::Value => {
                     if e.halfmove_age as u16 != sc.halfmove_age {
                         return e.value();
                     }
+                    else {
+                        if depth as u8 == e.depth() {
+                            return e.value();
+                        }
+                        else {
+                            return 0;
+                        }
+                    }
                 },
                 EntryType::LowerBound => {
                     if e.value() >= beta { return beta; }