]> git.sesse.net Git - stockfish/commitdiff
Update SEE to return a Value
authorMarco Costalba <mcostalba@gmail.com>
Sun, 16 Feb 2014 12:06:31 +0000 (13:06 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 16 Feb 2014 12:06:31 +0000 (13:06 +0100)
It seems more natural because the actual returned
value is from PieceValue[] array.

No functional change.

src/movepick.cpp
src/movepick.h
src/position.cpp
src/position.h
src/search.cpp

index 09f7611c527b8e397f6422c2901f7a48854726cd..539c486852ee278e0295deb7a53919a7fd634ac6 100644 (file)
@@ -193,12 +193,12 @@ void MovePicker::score<EVASIONS>() {
   // is not under attack, ordered by history value, then bad-captures and quiet
   // moves with a negative SEE. This last group is ordered by the SEE score.
   Move m;
   // is not under attack, ordered by history value, then bad-captures and quiet
   // moves with a negative SEE. This last group is ordered by the SEE score.
   Move m;
-  int seeScore;
+  Value seeScore;
 
   for (ExtMove* it = moves; it != end; ++it)
   {
       m = it->move;
 
   for (ExtMove* it = moves; it != end; ++it)
   {
       m = it->move;
-      if ((seeScore = pos.see_sign(m)) < 0)
+      if ((seeScore = pos.see_sign(m)) < VALUE_ZERO)
           it->score = seeScore - HistoryStats::Max; // At the bottom
 
       else if (pos.capture(m))
           it->score = seeScore - HistoryStats::Max; // At the bottom
 
       else if (pos.capture(m))
@@ -317,7 +317,7 @@ Move MovePicker::next_move<false>() {
           move = pick_best(cur++, end)->move;
           if (move != ttMove)
           {
           move = pick_best(cur++, end)->move;
           if (move != ttMove)
           {
-              if (pos.see_sign(move) >= 0)
+              if (pos.see_sign(move) >= VALUE_ZERO)
                   return move;
 
               // Losing capture, move it to the tail of the array
                   return move;
 
               // Losing capture, move it to the tail of the array
index c4676ca4f6e9f5be4b50be4462f92a3286ee9412..caec8d4ab37b4c73e71f963f32e546cf0ba54e99 100644 (file)
@@ -103,7 +103,8 @@ private:
   Move ttMove;
   ExtMove killers[6];
   Square recaptureSquare;
   Move ttMove;
   ExtMove killers[6];
   Square recaptureSquare;
-  int captureThreshold, stage;
+  Value captureThreshold;
+  int stage;
   ExtMove *cur, *end, *endQuiets, *endBadCaptures;
   ExtMove moves[MAX_MOVES];
 };
   ExtMove *cur, *end, *endQuiets, *endBadCaptures;
   ExtMove moves[MAX_MOVES];
 };
index 72681e8d694e68d4c2f709dccf9a54b560aafa06..78fccbb2891d8fb70b1d7e5d406ba985c88daccf 100644 (file)
@@ -1013,7 +1013,7 @@ void Position::undo_null_move() {
 /// Position::see() is a static exchange evaluator: It tries to estimate the
 /// material gain or loss resulting from a move.
 
 /// Position::see() is a static exchange evaluator: It tries to estimate the
 /// material gain or loss resulting from a move.
 
-int Position::see_sign(Move m) const {
+Value Position::see_sign(Move m) const {
 
   assert(is_ok(m));
 
 
   assert(is_ok(m));
 
@@ -1021,16 +1021,17 @@ int Position::see_sign(Move m) const {
   // is not less then capturing one. Note that king moves always return
   // here because king midgame value is set to 0.
   if (PieceValue[MG][moved_piece(m)] <= PieceValue[MG][piece_on(to_sq(m))])
   // is not less then capturing one. Note that king moves always return
   // here because king midgame value is set to 0.
   if (PieceValue[MG][moved_piece(m)] <= PieceValue[MG][piece_on(to_sq(m))])
-      return 1;
+      return VALUE_KNOWN_WIN;
 
   return see(m);
 }
 
 
   return see(m);
 }
 
-int Position::see(Move m) const {
+Value Position::see(Move m) const {
 
   Square from, to;
   Bitboard occupied, attackers, stmAttackers;
 
   Square from, to;
   Bitboard occupied, attackers, stmAttackers;
-  int swapList[32], slIndex = 1;
+  Value swapList[32];
+  int slIndex = 1;
   PieceType captured;
   Color stm;
 
   PieceType captured;
   Color stm;
 
@@ -1046,7 +1047,7 @@ int Position::see(Move m) const {
   // handled correctly. Simply return 0 that is always the correct value
   // unless in the rare case the rook ends up under attack.
   if (type_of(m) == CASTLING)
   // handled correctly. Simply return 0 that is always the correct value
   // unless in the rare case the rook ends up under attack.
   if (type_of(m) == CASTLING)
-      return 0;
+      return VALUE_ZERO;
 
   if (type_of(m) == ENPASSANT)
   {
 
   if (type_of(m) == ENPASSANT)
   {
index 5d3048ae5cfdf305c34ca78683de2ab6683d5b4b..03aa97d83a6cec9fccae25ddac607fbce14c6030 100644 (file)
@@ -141,8 +141,8 @@ public:
   void undo_null_move();
 
   // Static exchange evaluation
   void undo_null_move();
 
   // Static exchange evaluation
-  int see(Move m) const;
-  int see_sign(Move m) const;
+  Value see(Move m) const;
+  Value see_sign(Move m) const;
 
   // Accessing hash keys
   Key key() const;
 
   // Accessing hash keys
   Key key() const;
index 01d2a387e3aefa2592ff476d824063d41e1f81f4..0d1a401c6b715c489426047e308e60490fea203c 100644 (file)
@@ -779,7 +779,7 @@ moves_loop: // When in check and at SpNode search starts from here
                  || pos.advanced_pawn_push(move);
 
       // Step 12. Extend checks
                  || pos.advanced_pawn_push(move);
 
       // Step 12. Extend checks
-      if (givesCheck && pos.see_sign(move) >= 0)
+      if (givesCheck && pos.see_sign(move) >= VALUE_ZERO)
           ext = ONE_PLY;
 
       // Singular extension search. If all moves but one fail low on a search of
           ext = ONE_PLY;
 
       // Singular extension search. If all moves but one fail low on a search of
@@ -850,7 +850,7 @@ moves_loop: // When in check and at SpNode search starts from here
           }
 
           // Prune moves with negative SEE at low depths
           }
 
           // Prune moves with negative SEE at low depths
-          if (predictedDepth < 4 * ONE_PLY && pos.see_sign(move) < 0)
+          if (predictedDepth < 4 * ONE_PLY && pos.see_sign(move) < VALUE_ZERO)
           {
               if (SpNode)
                   splitPoint->mutex.lock();
           {
               if (SpNode)
                   splitPoint->mutex.lock();
@@ -1175,7 +1175,7 @@ moves_loop: // When in check and at SpNode search starts from here
               continue;
           }
 
               continue;
           }
 
-          if (futilityBase < beta && pos.see(move) <= 0)
+          if (futilityBase < beta && pos.see(move) <= VALUE_ZERO)
           {
               bestValue = std::max(bestValue, futilityBase);
               continue;
           {
               bestValue = std::max(bestValue, futilityBase);
               continue;
@@ -1193,7 +1193,7 @@ moves_loop: // When in check and at SpNode search starts from here
           && (!InCheck || evasionPrunable)
           &&  move != ttMove
           &&  type_of(move) != PROMOTION
           && (!InCheck || evasionPrunable)
           &&  move != ttMove
           &&  type_of(move) != PROMOTION
-          &&  pos.see_sign(move) < 0)
+          &&  pos.see_sign(move) < VALUE_ZERO)
           continue;
 
       // Check for legality just before making the move
           continue;
 
       // Check for legality just before making the move