static void send_pv() { char pv_string[StringSize]; board_t board[1]; int move; char move_string[StringSize]; ASSERT(State->state!=WAIT); if (Uci->best_depth == 0) return; // xboard search information if (XB->post) { if (State->state == THINK || State->state == ANALYSE) { line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); xboard_send(XBoard,"%d %+d %.0f %lld %s",Uci->best_depth,Uci->best_score,Uci->time*100.0,Uci->node_nb,pv_string); } else if (State->state == PONDER && option_get_bool("ShowPonder")) { game_get_board(Game,board); move = State->exp_move; if (move != MoveNone && move_is_legal(move,board)) { move_to_san(move,board,move_string,256); line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); xboard_send(XBoard,"%d %+d %.0f %lld (%s) %s",Uci->best_depth,Uci->best_score,Uci->time*100.0,Uci->node_nb,move_string,pv_string); } } } // kibitz if ((Uci->searching && option_get_bool("KibitzPV") && Uci->time >= option_get_double("KibitzDelay")) || (!Uci->searching && option_get_bool("KibitzMove"))) { if (State->state == THINK || State->state == ANALYSE) { line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); xboard_send(XBoard,"%s depth=%d time=%.2f node=%lld speed=%.0f score=%+.2f pv=\"%s\"",option_get_string("KibitzCommand"),Uci->best_depth,Uci->time,Uci->node_nb,Uci->speed,double(Uci->best_score)/100.0,pv_string); } else if (State->state == PONDER) { game_get_board(Game,board); move = State->exp_move; if (move != MoveNone && move_is_legal(move,board)) { move_to_san(move,board,move_string,256); line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); xboard_send(XBoard,"%s depth=%d time=%.2f node=%lld speed=%.0f score=%+.2f pv=\"(%s) %s\"",option_get_string("KibitzCommand"),Uci->best_depth,Uci->time,Uci->node_nb,Uci->speed,double(Uci->best_score)/100.0,move_string,pv_string); } } } }
static void send_pv() { char pv_string[StringSize]; board_t board[1]; int move; char move_string[256]; char tb_string[256]; ASSERT(State->state!=WAIT); if (Uci->best_depth == 0) return; // move_string[0]='\0'; // xboard search information if (XB->post && Uci->time >= option_get_double("PostDelay")) { if (State->state == THINK || State->state == ANALYSE) { line_to_san(Uci->best_pv,Uci->board,pv_string,sizeof(pv_string)); tb_to_string(tb_string,sizeof(tb_string)); if(Uci->depth==-1) //hack to clear the engine output window xboard_send(XBoard,"%d %+d %.0f " S64_FORMAT " ",0,Uci->best_score,Uci->time*100.0,Uci->node_nb); xboard_send(XBoard,"%d %+d %.0f " S64_FORMAT " %s %s",Uci->best_depth,Uci->best_score,Uci->time*100.0,Uci->node_nb,pv_string,tb_string); } else if (State->state == PONDER && option_get_bool("ShowPonder")) { game_get_board(Game,board); move = State->exp_move; if (move != MoveNone && move_is_legal(move,board)) { move_to_san(move,board,move_string,sizeof(move_string)); line_to_san(Uci->best_pv,Uci->board,pv_string,sizeof(pv_string)); tb_to_string(tb_string,sizeof(tb_string)); xboard_send(XBoard,"%d %+d %.0f " S64_FORMAT " (%s) %s %s",Uci->best_depth,Uci->best_score,Uci->time*100.0,Uci->node_nb,move_string,pv_string,tb_string); } } } // kibitz if ((Uci->searching && option_get_bool("KibitzPV") && Uci->time >= option_get_double("KibitzDelay")) || (!Uci->searching && option_get_bool("KibitzMove"))) { if (State->state == THINK || State->state == ANALYSE) { line_to_san(Uci->best_pv,Uci->board,pv_string,sizeof(pv_string)); xboard_send(XBoard,"%s depth=%d time=%.2f node=" S64_FORMAT " speed=%.0f score=%+.2f pv=\"%s\"",option_get_string("KibitzCommand"),Uci->best_depth,Uci->time,Uci->node_nb,Uci->speed,double(Uci->best_score)/100.0,pv_string); } else if (State->state == PONDER) { game_get_board(Game,board); move = State->exp_move; if (move != MoveNone && move_is_legal(move,board)) { move_to_san(move,board,move_string,sizeof(move_string)); line_to_san(Uci->best_pv,Uci->board,pv_string,sizeof(pv_string)); xboard_send(XBoard,"%s depth=%d time=%.2f node=" S64_FORMAT " speed=%.0f score=%+.2f pv=\"(%s) %s\"",option_get_string("KibitzCommand"),Uci->best_depth,Uci->time,Uci->node_nb,Uci->speed,double(Uci->best_score)/100.0,move_string,pv_string); } } } }
const std::string pretty_pv(const Position &pos, int time, int depth, uint64_t nodes, Value score, Move pv[]) { std::stringstream s; // Depth s << std::setw(2) << std::setfill(' ') << depth << " "; // Score s << std::setw(8) << score_string(score); // Time s << std::setw(8) << std::setfill(' ') << time_string(time) << " "; // Nodes if(nodes < 1000000ULL) s << std::setw(8) << std::setfill(' ') << nodes << " "; else if(nodes < 1000000000ULL) s << std::setw(7) << std::setfill(' ') << nodes/1000ULL << 'k' << " "; else s << std::setw(7) << std::setfill(' ') << nodes/1000000ULL << 'M' << " "; // PV s << line_to_san(pos, pv, 30, true, 0); return s.str(); }
static void epd_test_file(const char file_name[]) { FILE * file; int hit, tot; char epd[StringSize]; char am[StringSize], bm[StringSize], id[StringSize]; board_t board[1]; char string[StringSize]; int move; char pv_string[StringSize]; bool correct; double depth_tot, time_tot, node_tot; ASSERT(file_name!=NULL); // init file = fopen(file_name,"r"); if (file == NULL) my_fatal("epd_test_file(): can't open file \"%s\": %s\n",file_name,strerror(errno)); hit = 0; tot = 0; depth_tot = 0.0; time_tot = 0.0; node_tot = 0.0; // loop while (my_file_read_line(file,epd,StringSize)) { if (UseTrace) printf("%s\n",epd); if (!epd_get_op(epd,"am",am,StringSize)) strcpy(am,""); if (!epd_get_op(epd,"bm",bm,StringSize)) strcpy(bm,""); if (!epd_get_op(epd,"id",id,StringSize)) strcpy(id,""); if (my_string_empty(am) && my_string_empty(bm)) { my_fatal("epd_test(): no am or bm field in EPD\n"); } // init uci_send_ucinewgame(Uci); uci_send_isready_sync(Uci); ASSERT(!Uci->searching); // position if (!board_from_fen(board,epd)) ASSERT(false); if (!board_to_fen(board,string,StringSize)) ASSERT(false); engine_send(Engine,"position fen %s",string); // search engine_send(Engine,"go movetime %.0f depth %d",MaxTime*1000.0,MaxDepth); // engine_send(Engine,"go infinite"); // engine data board_copy(Uci->board,board); uci_clear(Uci); Uci->searching = true; Uci->pending_nb++; FirstMove = MoveNone; FirstDepth = 0; FirstSelDepth = 0; FirstScore = 0; FirstTime = 0.0; FirstNodeNb = 0; line_clear(FirstPV); LastMove = MoveNone; LastDepth = 0; LastSelDepth = 0; LastScore = 0; LastTime = 0.0; LastNodeNb = 0; line_clear(LastPV); // parse engine output while (engine_step()) { // stop search? if (Uci->depth > MaxDepth || Uci->time >= MaxTime || (Uci->depth - FirstDepth >= DepthDelta && Uci->depth > MinDepth && Uci->time >= MinTime && is_solution(FirstMove,board,bm,am))) { engine_send(Engine,"stop"); } } move = FirstMove; correct = is_solution(move,board,bm,am); if (correct) hit++; tot++; if (correct) { depth_tot += double(FirstDepth); time_tot += FirstTime; node_tot += double(FirstNodeNb); } printf("%s %d %4d %4d",id,correct,hit,tot); if (!line_to_san(LastPV,Uci->board,pv_string,StringSize)) ASSERT(false); printf(" - %2d %6.2f %9lld %+6.2f %s\n",FirstDepth,FirstTime,FirstNodeNb,double(LastScore)/100.0,pv_string); } printf("%d/%d",hit,tot); if (hit != 0) { depth_tot /= double(hit); time_tot /= double(hit); node_tot /= double(hit); printf(" - %.1f %.2f %.0f",depth_tot,time_tot,node_tot); } printf("\n"); fclose(file); }