Compactify timing code by figuring out who is black first
[uci2wb.git] / UCI2WB.c
index d7e9671..3354603 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -128,17 +128,17 @@ Play(int nr)
 void\r
 StartSearch(char *ponder)\r
 {      // send the 'go' command to engine. Suffix by ponder.\r
-       int x = (ponder[0] != 0);\r
-       int nr = moveNr + x; // we ponder for one move ahead!\r
-       fprintf(toE, "\ngo btime %d wtime %d", stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime);\r
-       DPRINT(    "\n# go btime %d wtime %d", stm == BLACK ^ x ^ sc=='s' ? myTime : hisTime, stm == WHITE ^ x ^ sc=='s' ? myTime : hisTime);\r
+       int x = (ponder[0] != 0);                   // during ponder stm is the opponent\r
+       int black = (stm == BLACK ^ x ^ sc == 's'); // set if our color is what the engine calls black\r
+       int nr = moveNr + x;                        // we ponder for one move ahead!\r
+       fprintf(toE, "\ngo%s btime %d wtime %d", ponder, black ? myTime : hisTime, !black ? myTime : hisTime);\r
+       DPRINT(    "\n# go%s btime %d wtime %d", ponder, black ? myTime : hisTime, !black ? myTime : hisTime);\r
        if(sTime > 0) { fprintf(toE, " movetime %d", sTime); DPRINT(" movetime %d", sTime); } else\r
        if(mps) { fprintf(toE, " movestogo %d", mps*(nr/(2*mps)+1)-nr/2); DPRINT(" movestogo %d", mps*(nr/(2*mps)+1)-nr/2); }\r
        if(inc && !suffix) { fprintf(toE, " winc %d binc %d", inc, inc); DPRINT(" winc %d binc %d", inc, inc); }\r
        if(depth > 0) { fprintf(toE, " depth %d", depth); DPRINT(" depth %d", depth); }\r
         if(suffix) { fprintf(toE, suffix, inc); DPRINT(suffix, inc); }\r
-       fprintf(toE, "%s\n", ponder);\r
-       DPRINT("%s\n", ponder);\r
+       fprintf(toE, "\n"); DPRINT("\n");\r
 }\r
 \r
 void\r