]> git.sesse.net Git - stockfish/commitdiff
De-templetize Position::is_draw()
authorMarco Costalba <mcostalba@gmail.com>
Wed, 10 Apr 2013 20:23:48 +0000 (22:23 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 10 Apr 2013 20:23:48 +0000 (22:23 +0200)
Now that we always check for repetition we don't
need a template anymore.

No functional change.

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

index 5193d20e85c89c8207935559d3a0d60d6ab3e780..210a1ba9d7ad09358800770c89de02d4a90ed966 100644 (file)
@@ -1376,7 +1376,6 @@ Value Position::compute_non_pawn_material(Color c) const {
 /// Position::is_draw() tests whether the position is drawn by material,
 /// repetition, or the 50 moves rule. It does not detect stalemates, this
 /// must be done by the search.
 /// Position::is_draw() tests whether the position is drawn by material,
 /// repetition, or the 50 moves rule. It does not detect stalemates, this
 /// must be done by the search.
-template<bool SkipRepetition>
 bool Position::is_draw() const {
 
   // Draw by material?
 bool Position::is_draw() const {
 
   // Draw by material?
@@ -1389,33 +1388,26 @@ bool Position::is_draw() const {
       return true;
 
   // Draw by repetition?
       return true;
 
   // Draw by repetition?
-  if (!SkipRepetition)
-  {
-      int i = 4, e = std::min(st->rule50, st->pliesFromNull);
+  int i = 4, e = std::min(st->rule50, st->pliesFromNull);
 
 
-      if (i <= e)
-      {
-          StateInfo* stp = st->previous->previous;
+  if (i <= e)
+  {
+      StateInfo* stp = st->previous->previous;
 
 
-          do {
-              stp = stp->previous->previous;
+      do {
+          stp = stp->previous->previous;
 
 
-              if (stp->key == st->key)
-                  return true;
+          if (stp->key == st->key)
+              return true;
 
 
-              i += 2;
+          i += 2;
 
 
-          } while (i <= e);
-      }
+      } while (i <= e);
   }
 
   return false;
 }
 
   }
 
   return false;
 }
 
-// Explicit template instantiations
-template bool Position::is_draw<false>() const;
-template bool Position::is_draw<true>() const;
-
 
 /// Position::flip() flips position with the white and black sides reversed. This
 /// is only useful for debugging especially for finding evaluation symmetry bugs.
 
 /// Position::flip() flips position with the white and black sides reversed. This
 /// is only useful for debugging especially for finding evaluation symmetry bugs.
index c41d31cf01de3179b705551b48b65d4bf4a1f917..7616eadc966414ac63e6189a8d4d58051ef4dfa6 100644 (file)
@@ -179,7 +179,7 @@ public:
   Thread* this_thread() const;
   int64_t nodes_searched() const;
   void set_nodes_searched(int64_t n);
   Thread* this_thread() const;
   int64_t nodes_searched() const;
   void set_nodes_searched(int64_t n);
-  template<bool SkipRepetition> bool is_draw() const;
+  bool is_draw() const;
 
   // Position consistency check, for debugging
   bool pos_is_ok(int* failedStep = NULL) const;
 
   // Position consistency check, for debugging
   bool pos_is_ok(int* failedStep = NULL) const;
index 529a6ffe2876a5345edf6763de9cc232adf6a2d8..055ee8778be9ac8bfb8beaed1b727b54784bdbbf 100644 (file)
@@ -533,7 +533,7 @@ namespace {
     if (!RootNode)
     {
         // Step 2. Check for aborted search and immediate draw
     if (!RootNode)
     {
         // Step 2. Check for aborted search and immediate draw
-        if (Signals.stop || pos.is_draw<false>() || ss->ply > MAX_PLY)
+        if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY)
             return DrawValue[pos.side_to_move()];
 
         // Step 3. Mate distance pruning. Even if we mate at the next move our score
             return DrawValue[pos.side_to_move()];
 
         // Step 3. Mate distance pruning. Even if we mate at the next move our score
@@ -1129,7 +1129,7 @@ split_point_start: // At split points actual search starts from here
     ss->ply = (ss-1)->ply + 1;
 
     // Check for an instant draw or maximum ply reached
     ss->ply = (ss-1)->ply + 1;
 
     // Check for an instant draw or maximum ply reached
-    if (pos.is_draw<false>() || ss->ply > MAX_PLY)
+    if (pos.is_draw() || ss->ply > MAX_PLY)
         return DrawValue[pos.side_to_move()];
 
     // Decide whether or not to include checks, this fixes also the type of
         return DrawValue[pos.side_to_move()];
 
     // Decide whether or not to include checks, this fixes also the type of
@@ -1579,7 +1579,7 @@ void RootMove::extract_pv_from_tt(Position& pos) {
            && pos.is_pseudo_legal(m = tte->move()) // Local copy, TT could change
            && pos.pl_move_is_legal(m, pos.pinned_pieces())
            && ply < MAX_PLY
            && pos.is_pseudo_legal(m = tte->move()) // Local copy, TT could change
            && pos.pl_move_is_legal(m, pos.pinned_pieces())
            && ply < MAX_PLY
-           && (!pos.is_draw<false>() || ply < 2));
+           && (!pos.is_draw() || ply < 2));
 
   pv.push_back(MOVE_NONE); // Must be zero-terminating
 
 
   pv.push_back(MOVE_NONE); // Must be zero-terminating