#ifndef SEARCH_H_INCLUDED
#define SEARCH_H_INCLUDED
-#include <memory> // For std::auto_ptr
+#include <atomic>
+#include <memory> // For std::unique_ptr
#include <stack>
#include <vector>
#include "position.h"
#include "types.h"
-struct SplitPoint;
-
namespace Search {
/// Stack struct keeps track of the information we need to remember from nodes
/// its own array of Stack objects, indexed by the current ply.
struct Stack {
- SplitPoint* splitPoint;
Move* pv;
int ply;
Move currentMove;
- Move ttMove;
Move excludedMove;
Move killers[2];
- Depth reduction;
Value staticEval;
bool skipEarlyPruning;
int moveCount;
explicit RootMove(Move m) : pv(1, m) {}
- bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
+ bool operator<(const RootMove& m) const { return m.score < score; } // Descending sort
bool operator==(const Move& m) const { return pv[0] == m; }
void insert_pv_in_tt(Position& pos);
bool extract_ponder_from_tt(Position& pos);
TimePoint startTime;
};
-/// The SignalsType struct stores volatile flags updated during the search
+/// The SignalsType struct stores atomic flags updated during the search
/// typically in an async fashion e.g. to stop the search by the GUI.
struct SignalsType {
- bool stop, stopOnPonderhit, firstRootMove, failedLowAtRoot;
+ std::atomic_bool stop, stopOnPonderhit;
};
typedef std::unique_ptr<std::stack<StateInfo>> StateStackPtr;
-extern volatile SignalsType Signals;
+extern SignalsType Signals;
extern LimitsType Limits;
extern StateStackPtr SetupStates;
void init();
-void reset();
-template<bool Root> uint64_t perft(Position& pos, Depth depth);
+void clear();
+template<bool Root = true> uint64_t perft(Position& pos, Depth depth);
} // namespace Search