Introduce helper function Search::reset() which clears all kind of search
memory, in order to restore a deterministic search state.
Generalize TT.clear() into Search::reset() for the following use cases:
- bench: needed to guarantee deterministic bench (ie. if you call bench from
interactive command line twice in a row you get the same value).
- Clear Hash: restore clean search state, which is the purpose of this button.
- ucinewgame: ditto.
No functional change.
Resolves #346
Options["Hash"] = ttSize;
Options["Threads"] = threads;
Options["Hash"] = ttSize;
Options["Threads"] = threads;
if (limitType == "time")
limits.movetime = stoi(limit); // movetime is in ms
if (limitType == "time")
limits.movetime = stoi(limit); // movetime is in ms
#define MOVEPICK_H_INCLUDED
#include <algorithm> // For std::max
#define MOVEPICK_H_INCLUDED
#include <algorithm> // For std::max
+#include <cstring> // For std::memset
#include "movegen.h"
#include "position.h"
#include "movegen.h"
#include "position.h"
const T* operator[](Piece pc) const { return table[pc]; }
T* operator[](Piece pc) { return table[pc]; }
const T* operator[](Piece pc) const { return table[pc]; }
T* operator[](Piece pc) { return table[pc]; }
+ void clear() { std::memset(table, 0, sizeof(table)); }
void update(Piece pc, Square to, Move m) {
void update(Piece pc, Square to, Move m) {
+/// Search::reset() clears all search memory, to restore a deterministic state
+
+void Search::reset () {
+
+ TT.clear();
+ History.clear();
+ CounterMovesHistory.clear();
+ Gains.clear();
+ Countermoves.clear();
+}
+
+
/// Search::perft() is our utility to verify move generation. All the leaf nodes
/// up to the given depth are generated and counted and the sum returned.
template<bool Root>
/// Search::perft() is our utility to verify move generation. All the leaf nodes
/// up to the given depth are generated and counted and the sum returned.
template<bool Root>
void init();
void think();
void init();
void think();
template<bool Root> uint64_t perft(Position& pos, Depth depth);
} // namespace Search
template<bool Root> uint64_t perft(Position& pos, Depth depth);
} // namespace Search
#include "search.h"
#include "thread.h"
#include "timeman.h"
#include "search.h"
#include "thread.h"
#include "timeman.h"
#include "uci.h"
using namespace std;
#include "uci.h"
using namespace std;
else if (token == "ucinewgame")
{
else if (token == "ucinewgame")
{
Time.availableNodes = 0;
}
else if (token == "isready") sync_cout << "readyok" << sync_endl;
Time.availableNodes = 0;
}
else if (token == "isready") sync_cout << "readyok" << sync_endl;
#include <ostream>
#include "misc.h"
#include <ostream>
#include "misc.h"
#include "thread.h"
#include "tt.h"
#include "uci.h"
#include "thread.h"
#include "tt.h"
#include "uci.h"
namespace UCI {
/// 'On change' actions, triggered by an option's value change
namespace UCI {
/// 'On change' actions, triggered by an option's value change
-void on_clear_hash(const Option&) { TT.clear(); }
+void on_clear_hash(const Option&) { Search::reset(); }
void on_hash_size(const Option& o) { TT.resize(o); }
void on_logger(const Option& o) { start_logger(o); }
void on_threads(const Option&) { Threads.read_uci_options(); }
void on_hash_size(const Option& o) { TT.resize(o); }
void on_logger(const Option& o) { start_logger(o); }
void on_threads(const Option&) { Threads.read_uci_options(); }