]> git.sesse.net Git - stockfish/commitdiff
Remove redundant argument in think()
authorMarco Costalba <mcostalba@gmail.com>
Thu, 15 Jul 2010 15:05:56 +0000 (17:05 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 15 Jul 2010 16:14:30 +0000 (17:14 +0100)
We don't need to pass side_to_move because we can get
it directly from the position object.

Note that in benchmark we always used to pass '0' and
it was a bug, but with no effect because was used only
in time[] and increment[], set always to 0 for both
colors.

Also additional small cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/benchmark.cpp
src/evaluate.cpp
src/move.h
src/position.h
src/search.cpp
src/search.h
src/uci.cpp

index ee262ba5bc1c2407b14f95c8f6036dfd6945eef4..e23afb1422cd2709427f0d69f3e9c050bc7ec776 100644 (file)
@@ -159,7 +159,7 @@ void benchmark(const string& commandLine) {
           cerr << "\nPerft " << maxDepth << " result (nodes searched): " << perftCnt << endl << endl;
           totalNodes += perftCnt;
       } else {
-          if (!think(pos, false, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
+          if (!think(pos, false, false, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
               break;
           totalNodes += nodes_searched();
       }
index 73ffcfb053057a6a203674dff264702940f55110..0249ee3b2a35c24071feb935069ed2e106926e59 100644 (file)
@@ -1064,9 +1064,8 @@ namespace {
   }
 
 
-  // scale_by_game_phase() interpolates between a middle game and an endgame
-  // score, based on game phase.  It also scales the return value by a
-  // ScaleFactor array.
+  // scale_by_game_phase() interpolates between a middle game and an endgame score,
+  // based on game phase. It also scales the return value by a ScaleFactor array.
 
   Value scale_by_game_phase(const Score& v, Phase ph, const ScaleFactor sf[]) {
 
@@ -1076,7 +1075,7 @@ namespace {
 
     Value eg = eg_value(v);
     ScaleFactor f = sf[eg > Value(0) ? WHITE : BLACK];
-    Value ev = Value((eg * f) / int(SCALE_FACTOR_NORMAL));
+    Value ev = Value((eg * f) / SCALE_FACTOR_NORMAL);
 
     int result = (mg_value(v) * ph + ev * (128 - ph)) / 128;
     return Value(result & ~(GrainSize - 1));
index 765328713a7201d4a49770752b5fe86b805d8693..bbc2ec099c1134163521a86e26fc1c3ea3d8c5cf 100644 (file)
@@ -201,8 +201,8 @@ inline Move make_ep_move(Square from, Square to) {
 //// Prototypes
 ////
 
-extern std::ostream& operator<<(std::ostream &os, Move m);
-extern Move move_from_string(const Position &pos, const std::string &str);
+extern std::ostream& operator<<(std::ostreamos, Move m);
+extern Move move_from_string(const Positionpos, const std::string &str);
 extern const std::string move_to_string(Move m);
 extern bool move_is_ok(Move m);
 
index be43c2e41e2bf13c2926f2a163f54725726f9cae..826fa13bfa85233cfe7931e4606e237ffa6bede8 100644 (file)
@@ -51,7 +51,7 @@
 ////
 
 /// FEN string for the initial position
-const std::string StartPosition = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
+const std::string StartPositionFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
 
 /// Maximum number of plies per game (220 should be enough, because the
 /// maximum search depth is 100, and during position setup we reset the
index fa544a1754ae4cb0f6b39ac5157d8afc59091985..d1642827f540263686c57b5100b98d0e268aa2fc 100644 (file)
@@ -411,9 +411,8 @@ int perft(Position& pos, Depth depth)
 /// search-related global variables, and calls root_search(). It returns false
 /// when a quit command is received during the search.
 
-bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
-           int time[], int increment[], int movesToGo, int maxDepth,
-           int maxNodes, int maxTime, Move searchMoves[]) {
+bool think(const Position& pos, bool infinite, bool ponder, int time[], int increment[],
+           int movesToGo, int maxDepth, int maxNodes, int maxTime, Move searchMoves[]) {
 
   // Initialize global search variables
   StopOnPonderhit = AbortSearch = Quit = AspirationFailLow = false;
@@ -486,8 +485,8 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
   TM.wake_sleeping_threads();
 
   // Set thinking time
-  int myTime = time[side_to_move];
-  int myIncrement = increment[side_to_move];
+  int myTime = time[pos.side_to_move()];
+  int myIncrement = increment[pos.side_to_move()];
   if (UseTimeManagement)
   {
       if (!movesToGo) // Sudden death time control
index d2dc6eba58257f30364baf364fd27b5e35fd546f..61a33242124f3f68515d4d87a9907af9a5c49a64 100644 (file)
@@ -72,11 +72,9 @@ struct SearchStack {
 extern void init_search();
 extern void init_threads();
 extern void exit_threads();
-extern bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
-                  int time[], int increment[], int movesToGo, int maxDepth,
-                  int maxNodes, int maxTime, Move searchMoves[]);
-extern int perft(Position &pos, Depth depth);
+extern int perft(Position& pos, Depth depth);
 extern int64_t nodes_searched();
-
+extern bool think(const Position& pos, bool infinite, bool ponder, int time[], int increment[],
+                  int movesToGo, int maxDepth, int maxNodes, int maxTime, Move searchMoves[]);
 
 #endif // !defined(SEARCH_H_INCLUDED)
index db9e6220fca0574ca8d449023c2212d81de07845..60d10b0b70368c5e05250e3fe7f63593048ee2e6 100644 (file)
@@ -79,7 +79,7 @@ namespace {
 
 void uci_main_loop() {
 
-  RootPosition.from_fen(StartPosition);
+  RootPosition.from_fen(StartPositionFEN);
   string command;
 
   do {
@@ -127,7 +127,7 @@ namespace {
     {
         push_button("New Game");
         Position::init_piece_square_tables();
-        RootPosition.from_fen(StartPosition);
+        RootPosition.from_fen(StartPositionFEN);
     }
     else if (token == "isready")
         cout << "readyok" << endl;
@@ -149,9 +149,9 @@ namespace {
     else if (token == "eval")
     {
         EvalInfo ei;
-        cout << "Incremental mg: " << mg_value(RootPosition.value())
+        cout << "Incremental mg: "   << mg_value(RootPosition.value())
              << "\nIncremental eg: " << eg_value(RootPosition.value())
-             << "\nFull eval: " << evaluate(RootPosition, ei) << endl;
+             << "\nFull eval: "      << evaluate(RootPosition, ei) << endl;
     }
     else if (token == "key")
         cout << "key: " << hex << RootPosition.get_key()
@@ -180,7 +180,7 @@ namespace {
         return;
 
     if (token == "startpos")
-        RootPosition.from_fen(StartPosition);
+        RootPosition.from_fen(StartPositionFEN);
     else if (token == "fen")
     {
         string fen;
@@ -209,7 +209,7 @@ namespace {
                     RootPosition.reset_game_ply();
             }
             // Our StateInfo st is about going out of scope so copy
-            // its content inside RootPosition before they disappear.
+            // its content inside RootPosition before it disappears.
             RootPosition.detach();
         }
     }
@@ -300,8 +300,8 @@ namespace {
 
     assert(RootPosition.is_ok());
 
-    return think(RootPosition, infinite, ponder, RootPosition.side_to_move(),
-                 time, inc, movesToGo, depth, nodes, moveTime, searchMoves);
+    return think(RootPosition, infinite, ponder, time, inc, movesToGo,
+                 depth, nodes, moveTime, searchMoves);
   }
 
   void perft(UCIInputParser& uip) {