No, the engine should use the WB time command. I should just use the given nps factor to convert it to the number of nodes left on its "clock".
I am sorry I messed up by not saving the old xboard2uci.c so that I cannot make a proper diff. But it was really a very simple patch. Most o it I already posted on CCC, and concerned the sending of the UCI go command:
- Code: Select all
engine_send_queue(Engine,"go");
if (XB->time_limit) {
// fixed time per move
if(node_rate > 0)
engine_send_queue(Engine," nodes %.0f",XB->time_max*(double)node_rate);
else
engine_send_queue(Engine," movetime %.0f",XB->time_max*1000.0);
} else {
// time controls
if(node_rate > 0) {
double time;
move_nb = 40;
if (XB->mps != 0) move_nb = XB->mps - (Uci->board->move_nb % XB->mps);
time = XB->my_time / move_nb;
if(XB->inc != 0) time += XB->inc;
if(time > XB->my_time) time = XB->my_time;
engine_send_queue(Engine," nodes %.0f",time*node_rate);
} else {
if (colour_is_white(Uci->board->turn)) {
engine_send_queue(Engine," wtime %.0f btime %.0f",XB->my_time*1000.0,XB->opp_time*1000.0);
} else {
engine_send_queue(Engine," wtime %.0f btime %.0f",XB->opp_time*1000.0,XB->my_time*1000.0);
}
if (XB->inc != 0.0) engine_send_queue(Engine," winc %.0f binc %.0f",XB->inc*1000.0,XB->inc*1000.0);
if (XB->mps != 0) {
move_nb = XB->mps - (Uci->board->move_nb % XB->mps);
ASSERT(move_nb>=1&&move_nb<=XB->mps);
engine_send_queue(Engine," movestogo %d",move_nb);
}
}
}
if (XB->depth_limit) engine_send_queue(Engine," depth %d",XB->depth_max);
The only other places where I made a change are one added feature command in send_xboard_options():
- Code: Select all
gui_send(GUI,"feature usermove=1");
gui_send(GUI,"feature nps=1");
if (XB->has_feature_memory){
plus the delaration of a global variable node_rate:
- Code: Select all
// constants
static const bool UseDebug = FALSE;
static const bool DelayPong = FALSE;
int node_rate = -1;
setting it in the new recognition of the WB nps command:
- Code: Select all
} else if (match(string,"nps *")) {
// fake WB play-by-nodes mode
node_rate = atoi(Star[0]);
} else if (match(string,"playother")) {
and clearing it on a WB new command in xboard2uci_gui_step():
- Code: Select all
XB->new_hack = TRUE;
XB->result = FALSE;
XB->depth_limit = FALSE;
node_rate = -1;
That is really all. Looking at this it seems you might prefer to declare the node_rate as a member of the XB structure.
I put the assumed number of remaining moves in a sudden-death game to 40 here; perhaps it would be better to change that to 30. In the worst cae that would lead to allocating more time to early moves than to later moves, which usually is not so bad for playing strength anyway. And there might be engines that implement 'go nodes' in such a way that they do not always use that exact number of nodes, but actually stop early, so that their average time use is below the limit we give anyway. So it seems good to set a generous limit. An alternative might be to multiply time by 1.2 just before testing if it exceeds XB->my_time, to bias time allocation towards early moves.