]> git.sesse.net Git - stockfish/commitdiff
Make a version of Position::do_move() without the givesCheck parameter
authorAram Tumanian <aram_tumanian@ukr.net>
Fri, 11 Nov 2016 13:02:28 +0000 (15:02 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 12 Nov 2016 08:55:12 +0000 (09:55 +0100)
In 10 of 12 calls total to Position::do_move()the givesCheck argument is
simply gives_check(m). So it's reasonable to make an overload without
this parameter, which wraps the existing version.

No functional change.

src/position.h
src/search.cpp
src/syzygy/tbprobe.cpp
src/uci.cpp

index 21ab63fe1d898867aacc7c3fca91ec14d12b86ad..989282772a1cf765e354eca643166fa74ab8d809 100644 (file)
@@ -128,6 +128,7 @@ public:
   bool opposite_bishops() const;
 
   // Doing and undoing moves
   bool opposite_bishops() const;
 
   // Doing and undoing moves
+  void do_move(Move m, StateInfo& newSt);
   void do_move(Move m, StateInfo& newSt, bool givesCheck);
   void undo_move(Move m);
   void do_null_move(StateInfo& newSt);
   void do_move(Move m, StateInfo& newSt, bool givesCheck);
   void undo_move(Move m);
   void do_null_move(StateInfo& newSt);
@@ -412,4 +413,8 @@ inline void Position::move_piece(Piece pc, Square from, Square to) {
   pieceList[pc][index[to]] = to;
 }
 
   pieceList[pc][index[to]] = to;
 }
 
+inline void Position::do_move(Move m, StateInfo& newSt) {
+  do_move(m, newSt, gives_check(m));
+}
+
 #endif // #ifndef POSITION_H_INCLUDED
 #endif // #ifndef POSITION_H_INCLUDED
index 7f933a466151a6e29bb375d92ff698a8956402c2..6699991a8d5237932f0b98f10d42bce308f0a62c 100644 (file)
@@ -113,8 +113,8 @@ namespace {
           std::copy(newPv.begin(), newPv.begin() + 3, pv);
 
           StateInfo st[2];
           std::copy(newPv.begin(), newPv.begin() + 3, pv);
 
           StateInfo st[2];
-          pos.do_move(newPv[0], st[0], pos.gives_check(newPv[0]));
-          pos.do_move(newPv[1], st[1], pos.gives_check(newPv[1]));
+          pos.do_move(newPv[0], st[0]);
+          pos.do_move(newPv[1], st[1]);
           expectedPosKey = pos.key();
           pos.undo_move(newPv[1]);
           pos.undo_move(newPv[0]);
           expectedPosKey = pos.key();
           pos.undo_move(newPv[1]);
           pos.undo_move(newPv[0]);
@@ -234,7 +234,7 @@ uint64_t Search::perft(Position& pos, Depth depth) {
           cnt = 1, nodes++;
       else
       {
           cnt = 1, nodes++;
       else
       {
-          pos.do_move(m, st, pos.gives_check(m));
+          pos.do_move(m, st);
           cnt = leaf ? MoveList<LEGAL>(pos).size() : perft<false>(pos, depth - ONE_PLY);
           nodes += cnt;
           pos.undo_move(m);
           cnt = leaf ? MoveList<LEGAL>(pos).size() : perft<false>(pos, depth - ONE_PLY);
           nodes += cnt;
           pos.undo_move(m);
@@ -801,7 +801,7 @@ namespace {
             {
                 ss->currentMove = move;
                 ss->counterMoves = &thisThread->counterMoveHistory[pos.moved_piece(move)][to_sq(move)];
             {
                 ss->currentMove = move;
                 ss->counterMoves = &thisThread->counterMoveHistory[pos.moved_piece(move)][to_sq(move)];
-                pos.do_move(move, st, pos.gives_check(move));
+                pos.do_move(move, st);
                 value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth, !cutNode);
                 pos.undo_move(move);
                 if (value >= rbeta)
                 value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth, !cutNode);
                 pos.undo_move(move);
                 if (value >= rbeta)
@@ -1600,7 +1600,7 @@ bool RootMove::extract_ponder_from_tt(Position& pos) {
     if (!pv[0])
         return false;
 
     if (!pv[0])
         return false;
 
-    pos.do_move(pv[0], st, pos.gives_check(pv[0]));
+    pos.do_move(pv[0], st);
     TTEntry* tte = TT.probe(pos.key(), ttHit);
 
     if (ttHit)
     TTEntry* tte = TT.probe(pos.key(), ttHit);
 
     if (ttHit)
index 9debcc6f9393409494ea91af9a768b6fbea2ea0d..22b3697ce44a1d1c8d1b5d5fbf656330d508adcb 100644 (file)
@@ -1207,7 +1207,7 @@ WDLScore search(Position& pos, ProbeState* result) {
 
         moveCount++;
 
 
         moveCount++;
 
-        pos.do_move(move, st, pos.gives_check(move));
+        pos.do_move(move, st);
         value = -search(pos, result);
         pos.undo_move(move);
 
         value = -search(pos, result);
         pos.undo_move(move);
 
@@ -1455,7 +1455,7 @@ int Tablebases::probe_dtz(Position& pos, ProbeState* result) {
     {
         bool zeroing = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN;
 
     {
         bool zeroing = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN;
 
-        pos.do_move(move, st, pos.gives_check(move));
+        pos.do_move(move, st);
 
         // For zeroing moves we want the dtz of the move _before_ doing it,
         // otherwise we will get the dtz of the next move sequence. Search the
 
         // For zeroing moves we want the dtz of the move _before_ doing it,
         // otherwise we will get the dtz of the next move sequence. Search the
@@ -1529,7 +1529,7 @@ bool Tablebases::root_probe(Position& pos, Search::RootMoves& rootMoves, Value&
     // Probe each move
     for (size_t i = 0; i < rootMoves.size(); ++i) {
         Move move = rootMoves[i].pv[0];
     // Probe each move
     for (size_t i = 0; i < rootMoves.size(); ++i) {
         Move move = rootMoves[i].pv[0];
-        pos.do_move(move, st, pos.gives_check(move));
+        pos.do_move(move, st);
         int v = 0;
 
         if (pos.checkers() && dtz > 0) {
         int v = 0;
 
         if (pos.checkers() && dtz > 0) {
@@ -1665,7 +1665,7 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, Val
     // Probe each move
     for (size_t i = 0; i < rootMoves.size(); ++i) {
         Move move = rootMoves[i].pv[0];
     // Probe each move
     for (size_t i = 0; i < rootMoves.size(); ++i) {
         Move move = rootMoves[i].pv[0];
-        pos.do_move(move, st, pos.gives_check(move));
+        pos.do_move(move, st);
         WDLScore v = -Tablebases::probe_wdl(pos, &result);
         pos.undo_move(move);
 
         WDLScore v = -Tablebases::probe_wdl(pos, &result);
         pos.undo_move(move);
 
index 0b3e3a51ddc92fb60c55ede46d6e69349cf4cf49..0f1c6943b6377c73b3b0648ba2875f90ef7e5371 100644 (file)
@@ -76,7 +76,7 @@ namespace {
     while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE)
     {
         States->push_back(StateInfo());
     while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE)
     {
         States->push_back(StateInfo());
-        pos.do_move(m, States->back(), pos.gives_check(m));
+        pos.do_move(m, States->back());
     }
   }
 
     }
   }