void set_non_pv_scores(const Position& pos);
void sort() { insertion_sort<RootMove, Base::iterator>(begin(), end()); }
- void sort_multipv(int n) { insertion_sort<RootMove, Base::iterator>(begin(), begin() + n); }
+ void sort_multipv(int n) { insertion_sort<RootMove, Base::iterator>(begin(), begin() + n + 1); }
};
wait_for_stop_or_ponderhit();
cout << "bestmove " << bookMove << endl;
- return true;
+ return !QuitRequest;
}
}
<< move_to_san(pos, ponderMove) // Works also with MOVE_NONE
<< endl;
+ // Return from think() with unchanged position
+ pos.undo_move(bestMove);
+
LogFile.close();
}
// Write PV lines to transposition table, in case the relevant entries
// have been overwritten during the search.
- for (int i = 0; i < MultiPV; i++)
+ for (int i = 0; i < Min(MultiPV, (int)rml.size()); i++)
rml[i].insert_pv_in_tt(pos);
return alpha;
}
- // current_search_time() returns the number of milliseconds which have passed
- // since the beginning of the current search.
+ // init_ss_array() does a fast reset of the first entries of a SearchStack
+ // array and of all the excludedMove and skipNullMove entries.
- int current_search_time() {
+ void init_ss_array(SearchStack* ss, int size) {
- return get_system_time() - SearchStartTime;
+ for (int i = 0; i < size; i++, ss++)
+ {
+ ss->excludedMove = MOVE_NONE;
+ ss->skipNullMove = false;
+ ss->reduction = DEPTH_ZERO;
+ ss->sp = NULL;
+
+ if (i < 3)
+ ss->killers[0] = ss->killers[1] = ss->mateKiller = MOVE_NONE;
+ }
}
return s.str();
}
- // nps() computes the current nodes/second count.
+
+ // current_search_time() returns the number of milliseconds which have passed
+ // since the beginning of the current search.
+
+ int current_search_time() {
+
+ return get_system_time() - SearchStartTime;
+ }
+
+
+ // nps() computes the current nodes/second count
int nps(const Position& pos) {
bool noMoreTime = t > TimeMgr.maximum_time()
|| stillAtFirstMove;
- if ( (Iteration >= 3 && UseTimeManagement && noMoreTime)
+ if ( (UseTimeManagement && noMoreTime)
|| (ExactMaxTime && t >= ExactMaxTime)
- || (Iteration >= 3 && MaxNodes && pos.nodes_searched() >= MaxNodes))
+ || (MaxNodes && pos.nodes_searched() >= MaxNodes)) // FIXME
StopRequest = true;
}
- // init_ss_array() does a fast reset of the first entries of a SearchStack
- // array and of all the excludedMove and skipNullMove entries.
-
- void init_ss_array(SearchStack* ss, int size) {
-
- for (int i = 0; i < size; i++, ss++)
- {
- ss->excludedMove = MOVE_NONE;
- ss->skipNullMove = false;
- ss->reduction = DEPTH_ZERO;
- ss->sp = NULL;
-
- if (i < 3)
- ss->killers[0] = ss->killers[1] = ss->mateKiller = MOVE_NONE;
- }
- }
-
-
// wait_for_stop_or_ponderhit() is called when the maximum depth is reached
// while the program is pondering. The point is to work around a wrinkle in
// the UCI protocol: When pondering, the engine is not allowed to give a
// "bestmove" before the GUI sends it a "stop" or "ponderhit" command.
// We simply wait here until one of these commands is sent, and return,
- // after which the bestmove and pondermove will be printed (in id_loop()).
+ // after which the bestmove and pondermove will be printed.
void wait_for_stop_or_ponderhit() {
while (true)
{
+ // Wait for a command from stdin
if (!std::getline(std::cin, command))
command = "quit";