mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Cleanup poll()
Reshape this function in preparation for future work. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
18860cce40
commit
5c4f6f6226
1 changed files with 49 additions and 47 deletions
|
@ -2136,61 +2136,63 @@ namespace {
|
||||||
// search.
|
// search.
|
||||||
|
|
||||||
void poll() {
|
void poll() {
|
||||||
int t, data;
|
|
||||||
static int lastInfoTime;
|
|
||||||
|
|
||||||
t = current_search_time();
|
static int lastInfoTime;
|
||||||
|
int t = current_search_time();
|
||||||
|
|
||||||
// Poll for input
|
// Poll for input
|
||||||
data = Bioskey();
|
if (Bioskey())
|
||||||
if(data) {
|
{
|
||||||
char input[256];
|
// We are line oriented, don't read single chars
|
||||||
if(fgets(input, 255, stdin) == NULL)
|
std::string command;
|
||||||
strncpy(input, "quit\n", 5);
|
if (!std::getline(std::cin, command))
|
||||||
if(strncmp(input, "quit", 4) == 0) {
|
command = "quit";
|
||||||
|
|
||||||
|
if (command == "quit")
|
||||||
|
{
|
||||||
AbortSearch = true;
|
AbortSearch = true;
|
||||||
PonderSearch = false;
|
PonderSearch = false;
|
||||||
Quit = true;
|
Quit = true;
|
||||||
}
|
}
|
||||||
else if(strncmp(input, "stop", 4) == 0) {
|
else if(command == "stop")
|
||||||
|
{
|
||||||
AbortSearch = true;
|
AbortSearch = true;
|
||||||
PonderSearch = false;
|
PonderSearch = false;
|
||||||
}
|
}
|
||||||
else if(strncmp(input, "ponderhit", 9) == 0)
|
else if(command == "ponderhit")
|
||||||
ponderhit();
|
ponderhit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print search information
|
// Print search information
|
||||||
if(t < 1000)
|
if (t < 1000)
|
||||||
lastInfoTime = 0;
|
lastInfoTime = 0;
|
||||||
else if(lastInfoTime > t)
|
|
||||||
|
else if (lastInfoTime > t)
|
||||||
// HACK: Must be a new search where we searched less than
|
// HACK: Must be a new search where we searched less than
|
||||||
// NodesBetweenPolls nodes during the first second of search.
|
// NodesBetweenPolls nodes during the first second of search.
|
||||||
lastInfoTime = 0;
|
lastInfoTime = 0;
|
||||||
else if(t - lastInfoTime >= 1000) {
|
|
||||||
|
else if (t - lastInfoTime >= 1000)
|
||||||
|
{
|
||||||
lastInfoTime = t;
|
lastInfoTime = t;
|
||||||
lock_grab(&IOLock);
|
lock_grab(&IOLock);
|
||||||
std::cout << "info nodes " << nodes_searched() << " nps " << nps()
|
std::cout << "info nodes " << nodes_searched() << " nps " << nps()
|
||||||
<< " time " << t << " hashfull " << TT.full() << std::endl;
|
<< " time " << t << " hashfull " << TT.full() << std::endl;
|
||||||
lock_release(&IOLock);
|
lock_release(&IOLock);
|
||||||
if(ShowCurrentLine)
|
if (ShowCurrentLine)
|
||||||
Threads[0].printCurrentLine = true;
|
Threads[0].printCurrentLine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should we stop the search?
|
// Should we stop the search?
|
||||||
if(!PonderSearch && Iteration >= 2 &&
|
if (PonderSearch)
|
||||||
(!InfiniteSearch && (t > AbsoluteMaxSearchTime ||
|
return;
|
||||||
(RootMoveNumber == 1 &&
|
|
||||||
t > MaxSearchTime + ExtraSearchTime) ||
|
|
||||||
(!FailHigh && !fail_high_ply_1() && !Problem &&
|
|
||||||
t > 6*(MaxSearchTime + ExtraSearchTime)))))
|
|
||||||
AbortSearch = true;
|
|
||||||
|
|
||||||
if(!PonderSearch && ExactMaxTime && t >= ExactMaxTime)
|
bool overTime = t > AbsoluteMaxSearchTime
|
||||||
AbortSearch = true;
|
|| (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime)
|
||||||
|
|| ( !FailHigh && !fail_high_ply_1() && !Problem
|
||||||
|
&& t > 6*(MaxSearchTime + ExtraSearchTime));
|
||||||
|
|
||||||
if(!PonderSearch && Iteration >= 3 && MaxNodes
|
if ( (Iteration >= 2 && (!InfiniteSearch && overTime))
|
||||||
&& nodes_searched() >= MaxNodes)
|
|| (ExactMaxTime && t >= ExactMaxTime)
|
||||||
|
|| (Iteration >= 3 && MaxNodes && nodes_searched() >= MaxNodes))
|
||||||
AbortSearch = true;
|
AbortSearch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue