]> git.sesse.net Git - stockfish/commitdiff
Add psqt ordering when there is no history
authorMarco Costalba <mcostalba@gmail.com>
Wed, 15 Oct 2008 06:18:05 +0000 (07:18 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 15 Oct 2008 06:18:05 +0000 (07:18 +0100)
This seems to increase strenght (about 15 ELO),
still to test some variations on this theme that
could increase ELO even more.

Idea from Rebel (http://members.home.nl/matador/chess840.htm)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movepick.cpp
src/position.h

index 4d2d31167ea2db2641c582c545ba3c6c46b1a0fe..d0ceaf1c23e8166263e88d10401c035e9cc0d2e5 100644 (file)
@@ -246,15 +246,36 @@ void MovePicker::score_captures() {
 }
 
 void MovePicker::score_noncaptures() {
-  for(int i = 0; i < numOfMoves; i++) {
-    Move m = moves[i].move;
-    if(m == killer1)
-      moves[i].score = HistoryMax + 2;
-    else if(m == killer2)
-      moves[i].score = HistoryMax + 1;
-    else
-      moves[i].score = H.move_ordering_score(pos->piece_on(move_from(m)), m);
+
+  bool all_zero = true;
+  for (int i = 0; i < numOfMoves; i++)
+  {
+      Move m = moves[i].move;
+      if (m == killer1)
+      {
+          moves[i].score = HistoryMax + 2;
+          all_zero = false;
+      }
+      else if (m == killer2)
+      {
+          moves[i].score = HistoryMax + 1;
+          all_zero = false;
+      }
+      else
+      {
+          moves[i].score = H.move_ordering_score(pos->piece_on(move_from(m)), m);
+          if (all_zero && moves[i].score != 0)
+              all_zero = false;
+      }
   }
+  if (!all_zero)
+      return;
+
+  // If we don't have at least one history score then
+  // try to order using psq tables difference between 
+  // from square and to square.
+  for (int i = 0; i < numOfMoves; i++)
+      moves[i].score = pos->mg_pst_delta(moves[i].move);
 }
 
 void MovePicker::score_evasions() {
index 9acb29669e1633fe76159abcf5ea8241f4e3f8c8..25596bf6a2add681047ef5085006cb3640782dff 100644 (file)
@@ -278,6 +278,7 @@ public:
   Value eg_value() const;
   Value non_pawn_material(Color c) const;
   Phase game_phase() const;
+  Value mg_pst_delta(Move m) const;
 
   // Game termination checks
   bool is_mate();
@@ -681,6 +682,11 @@ inline Value Position::mg_pst(Color c, PieceType pt, Square s) const {
   return MgPieceSquareTable[piece_of_color_and_type(c, pt)][s];
 }
 
+inline Value Position::mg_pst_delta(Move m) const {
+  return MgPieceSquareTable[piece_on(move_from(m))][move_to(m)]
+        -MgPieceSquareTable[piece_on(move_from(m))][move_from(m)];
+}
+
 inline Value Position::eg_pst(Color c, PieceType pt, Square s) const {
   return EgPieceSquareTable[piece_of_color_and_type(c, pt)][s];
 }