]> git.sesse.net Git - stockfish/blobdiff - src/search.h
Rename and de-templetize sort()
[stockfish] / src / search.h
index c957c34bf6259b1107ddd860209454ffffed9351..4a66b11f48d8bcaf76d1ca95901f975b1143b699 100644 (file)
 #define SEARCH_H_INCLUDED
 
 #include <cstring>
+#include <memory>
+#include <stack>
 #include <vector>
 
+#include "misc.h"
+#include "position.h"
 #include "types.h"
 
-class Position;
 struct SplitPoint;
 
 namespace Search {
@@ -41,7 +44,7 @@ struct Stack {
   Move excludedMove;
   Move killers[2];
   Depth reduction;
-  Value eval;
+  Value staticEval;
   Value evalMargin;
   int skipNullMove;
 };
@@ -53,12 +56,11 @@ struct Stack {
 /// all non-pv moves.
 struct RootMove {
 
-  RootMove(){} // Needed by sort()
   RootMove(Move m) : score(-VALUE_INFINITE), prevScore(-VALUE_INFINITE) {
     pv.push_back(m); pv.push_back(MOVE_NONE);
   }
 
-  bool operator<(const RootMove& m) const { return score < m.score; }
+  bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
   bool operator==(const Move& m) const { return pv[0] == m; }
 
   void extract_pv_from_tt(Position& pos);
@@ -77,9 +79,9 @@ struct RootMove {
 struct LimitsType {
 
   LimitsType() { memset(this, 0, sizeof(LimitsType)); }
-  bool use_time_management() const { return !(movetime | depth | nodes | infinite); }
+  bool use_time_management() const { return !(mate | movetime | depth | nodes | infinite); }
 
-  int times[2], incs[2], movestogo, depth, nodes, movetime, infinite, ponder;
+  int time[COLOR_NB], inc[COLOR_NB], movestogo, depth, nodes, movetime, mate, infinite, ponder;
 };
 
 
@@ -90,13 +92,18 @@ struct SignalsType {
   bool stopOnPonderhit, firstRootMove, stop, failedLowAtRoot;
 };
 
+typedef std::auto_ptr<std::stack<StateInfo> > StateStackPtr;
+
 extern volatile SignalsType Signals;
 extern LimitsType Limits;
 extern std::vector<RootMove> RootMoves;
-extern Position RootPosition;
+extern Position RootPos;
+extern Color RootColor;
+extern Time::point SearchTime;
+extern StateStackPtr SetupStates;
 
 extern void init();
-extern int64_t perft(Position& pos, Depth depth);
+extern size_t perft(Position& pos, Depth depth);
 extern void think();
 
 } // namespace Search