void Iterate(POS *p, int *pv) { int val = 0, cur_val = 0; U64 nps = 0; Timer.SetIterationTiming(); int max_root_depth = Timer.GetData(MAX_DEPTH); root_side = p->side; SetAsymmetricEval(p->side); // Are we operating in slowdown mode or on node limit? Timer.special_mode = 0; if (Timer.nps_limit || Timer.GetData(MAX_NODES) > 0) Timer.special_mode = 1; // Search with increasing depth for (root_depth = 1; root_depth <= max_root_depth; root_depth++) { int elapsed = Timer.GetElapsedTime(); if (elapsed) nps = nodes * 1000 / elapsed; #if defined _WIN32 || defined _WIN64 printf("info depth %d time %d nodes %I64d nps %I64d\n", root_depth, elapsed, nodes, nps); #else printf("info depth %d time %d nodes %lld nps %lld\n", root_depth, elapsed, nodes, nps); #endif if (use_aspiration) cur_val = Widen(p, root_depth, pv, cur_val); else cur_val = SearchRoot(p, 0, -INF, INF, root_depth, pv); // full window search // don't search too deep with only one move available if (root_depth == 8 && !fl_has_choice && !Timer.IsInfiniteMode() ) break; if (abort_search || Timer.FinishIteration()) break; val = cur_val; } }
void UciLoop(void) { char command[4096], token[180], *ptr; POS p[1]; setbuf(stdin, NULL); setbuf(stdout, NULL); SetPosition(p, START_POS); AllocTrans(16); for (;;) { ReadLine(command, sizeof(command)); ptr = ParseToken(command, token); // checks if Rodent should play with an opening book // UseBook remains for backward compatibly if ((strstr(command, "setoption name OwnBook value")) || (strstr(command, "setoption name UseBook value"))) use_book = (strstr(command, "value true") != 0); if (strstr(command, "setoption name UCI_LimitStrength value")) Param.fl_weakening = (strstr(command, "value true") != 0); if (strcmp(token, "uci") == 0) { printf("id name %s\n", PROG_NAME); printf("id author Pawel Koziol (based on Sungorus 1.4 by Pablo Vazquez)\n"); printf("option name Hash type spin default 16 min 1 max 4096\n"); printf("option name Clear Hash type button\n"); if (panel_style > 0) { printf("option name PawnValue type spin default %d min 0 max 1200\n", Param.pc_value[P]); printf("option name KnightValue type spin default %d min 0 max 1200\n", Param.pc_value[N]); printf("option name BishopValue type spin default %d min 0 max 1200\n", Param.pc_value[B]); printf("option name RookValue type spin default %d min 0 max 1200\n", Param.pc_value[R]); printf("option name QueenValue type spin default %d min 0 max 1200\n", Param.pc_value[Q]); printf("option name KeepPawn type spin default %d min -200 max 200\n", Param.keep_pc[P]); printf("option name KeepKnight type spin default %d min -200 max 200\n", Param.keep_pc[N]); printf("option name KeepBishop type spin default %d min -200 max 200\n", Param.keep_pc[B]); printf("option name KeepRook type spin default %d min -200 max 200\n", Param.keep_pc[R]); printf("option name KeepQueen type spin default %d min -200 max 200\n", Param.keep_pc[Q]); printf("option name BishopPair type spin default %d min -100 max 100\n", Param.bish_pair); if (panel_style == 2) printf("option name KnightPair type spin default %d min -100 max 100\n", Param.knight_pair); printf("option name ExchangeImbalance type spin default %d min -100 max 100\n", Param.exchange_imbalance); printf("option name KnightLikesClosed type spin default %d min 0 max 10\n", Param.np_bonus); if (panel_style == 2) printf("option name RookLikesOpen type spin default %d min 0 max 10\n", Param.rp_malus); printf("option name Material type spin default %d min 0 max 500\n", Param.mat_perc); printf("option name OwnAttack type spin default %d min 0 max 500\n", dyn_weights[DF_OWN_ATT]); printf("option name OppAttack type spin default %d min 0 max 500\n", dyn_weights[DF_OPP_ATT]); printf("option name OwnMobility type spin default %d min 0 max 500\n", dyn_weights[DF_OWN_MOB]); printf("option name OppMobility type spin default %d min 0 max 500\n", dyn_weights[DF_OPP_MOB]); printf("option name KingTropism type spin default %d min -50 max 500\n", weights[F_TROPISM]); printf("option name PiecePlacement type spin default %d min 0 max 500\n", Param.pst_perc); printf("option name PiecePressure type spin default %d min 0 max 500\n", weights[F_PRESSURE]); printf("option name PassedPawns type spin default %d min 0 max 500\n", weights[F_PASSERS]); printf("option name PawnStructure type spin default %d min 0 max 500\n", weights[F_PAWNS]); printf("option name Outposts type spin default %d min 0 max 500\n", weights[F_OUTPOST]); printf("option name Lines type spin default %d min 0 max 500\n", weights[F_LINES]); if (panel_style == 2) { printf("option name PawnShield type spin default %d min 0 max 500\n", Param.shield_perc); printf("option name PawnStorm type spin default %d min 0 max 500\n", Param.storm_perc); } printf("option name PstStyle type spin default %d min 0 max 2\n", Param.pst_style); printf("option name MobilityStyle type spin default %d min 0 max 1\n", Param.mob_style); if (panel_style == 2) { printf("option name DoubledPawnMg type spin default %d min -100 max 0\n", Param.doubled_malus_mg); printf("option name DoubledPawnEg type spin default %d min -100 max 0\n", Param.doubled_malus_eg); printf("option name IsolatedPawnMg type spin default %d min -100 max 0\n", Param.isolated_malus_mg); printf("option name IsolatedPawnEg type spin default %d min -100 max 0\n", Param.isolated_malus_eg); printf("option name IsolatedOnOpenMg type spin default %d min -100 max 0\n", Param.isolated_open_malus); printf("option name BackwardPawnMg type spin default %d min -100 max 0\n", Param.backward_malus_base); printf("option name BackwardPawnEg type spin default %d min -100 max 0\n", Param.backward_malus_eg); printf("option name BackwardOnOpenMg type spin default %d min -100 max 0\n", Param.backward_open_malus); } // Strength settings - we use either Elo slider with an approximate formula // or separate options for nodes per second reduction and eval blur if (fl_elo_slider == 0) { printf("option name NpsLimit type spin default %d min 0 max 5000000\n", Timer.nps_limit); printf("option name EvalBlur type spin default %d min 0 max 5000000\n", Param.eval_blur); } else { printf("option name UCI_LimitStrength type check default false\n"); printf("option name UCI_Elo type spin default %d min 800 max 2800\n", Param.elo); } printf("option name Contempt type spin default %d min -250 max 250\n", Param.draw_score); printf("option name SlowMover type spin default %d min 10 max 500\n", time_percentage); printf("option name Selectivity type spin default %d min 0 max 200\n", hist_perc); printf("option name OwnBook type check default true\n"); printf("option name GuideBookFile type string default guide.bin\n"); printf("option name MainBookFile type string default rodent.bin\n"); printf("option name BookFilter type spin default %d min 0 max 5000000\n", Param.book_filter); } if (panel_style == 0) { printf("option name PersonalityFile type string default rodent.txt\n"); printf("option name OwnBook type check default true\n"); if (fl_separate_books) { printf("option name GuideBookFile type string default guide.bin\n"); printf("option name MainBookFile type string default rodent.bin\n"); } } printf("uciok\n"); } else if (strcmp(token, "isready") == 0) { printf("readyok\n"); } else if (strcmp(token, "setoption") == 0) { ParseSetoption(ptr); } else if (strcmp(token, "position") == 0) { ParsePosition(p, ptr); } else if (strcmp(token, "perft") == 0) { ptr = ParseToken(ptr, token); int depth = atoi(token); if (depth == 0) depth = 5; Timer.SetStartTime(); nodes = Perft(p, 0, depth); #if defined _WIN32 || defined _WIN64 printf (" perft %d : %I64d nodes in %d miliseconds\n", depth, nodes, Timer.GetElapsedTime() ); #else printf(" perft %d : %lld nodes in %d miliseconds\n", depth, nodes, Timer.GetElapsedTime()); #endif } else if (strcmp(token, "print") == 0) { PrintBoard(p); } else if (strcmp(token, "eval") == 0) { SetAsymmetricEval(p->side); Eval.Print(p); } else if (strcmp(token, "step") == 0) { ParseMoves(p, ptr); } else if (strcmp(token, "go") == 0) { ParseGo(p, ptr); } else if (strcmp(token, "bench") == 0) { ptr = ParseToken(ptr, token); Bench(atoi(token)); } else if (strcmp(token, "quit") == 0) { return; } } }