static void mess() { // clear state variables State->resign_nb = 0; State->exp_move = MoveNone; my_timer_reset(State->timer); // abort a possible search stop_search(); // calculate the new state if (false) { } else if (!active()) { State->state = WAIT; my_log("POLYGLOT WAIT\n"); } else if (XB->analyse) { State->state = ANALYSE; my_log("POLYGLOT ANALYSE\n"); } else if (State->computer[game_turn(Game)]) { State->state = THINK; my_log("POLYGLOT THINK\n"); } else { State->state = WAIT; my_log("POLYGLOT WAIT\n"); } search_update(); }
static void search_forw (int new_search) { int found = 0; char *p, *loc; search_forw_flg = 1; if (gl_search_mode == 0) { search_last = hist_pos = hist_last; search_update(0); gl_search_mode = 1; gl_buf[0] = 0; gl_fixup(search_prompt, 0, 0); } else if (search_pos > 0) { while (!found) { p = hist_next(); if (*p == 0) { /* not found, done looking */ gl_buf[0] = 0; gl_fixup(search_prompt, 0, 0); found = 1; } else if ((loc = strstr(p, search_string)) != 0) { strcpy(gl_buf, p); gl_fixup(search_prompt, 0, (int)(loc - p)); if (new_search) search_last = hist_pos; found = 1; } } } else { gl_putc('\007'); } }
static void end_protected_command(){ if(Uci->ready){ // not init faze uci_send_isready_sync(Uci); // gobble up spurious "bestmove" } update_remaining_time(); search_update(); // relaunch search if necessary }
static void search_addchar (int c) { char *loc; search_update(c); if (c < 0) { if (search_pos > 0) { hist_pos = search_last; } else { gl_buf[0] = 0; hist_pos = hist_last; } strcpy(gl_buf, hist_buf[hist_pos]); } if ((loc = strstr(gl_buf, search_string)) != 0) { gl_fixup(search_prompt, 0, (int)(loc - gl_buf)); } else if (search_pos > 0) { if (search_forw_flg) { search_forw(0); } else { search_back(0); } } else { gl_fixup(search_prompt, 0, 0); } }
static void no_mess(int move) { ASSERT(move_is_ok(move)); // just received a move, calculate the new state if (false) { } else if (!active()) { stop_search(); // abort a possible search State->state = WAIT; State->exp_move = MoveNone; my_log("POLYGLOT WAIT\n"); } else if (State->state == WAIT) { ASSERT(State->computer[game_turn(Game)]); ASSERT(!State->computer[colour_opp(game_turn(Game))]); ASSERT(!XB->analyse); my_log("POLYGLOT WAIT -> THINK\n"); State->state = THINK; State->exp_move = MoveNone; } else if (State->state == THINK) { ASSERT(!State->computer[game_turn(Game)]); ASSERT(State->computer[colour_opp(game_turn(Game))]); ASSERT(!XB->analyse); if (ponder() && ponder_move_is_ok(Uci->ponder_move)) { my_log("POLYGLOT THINK -> PONDER\n"); State->state = PONDER; State->exp_move = Uci->ponder_move; } else { my_log("POLYGLOT THINK -> WAIT\n"); State->state = WAIT; State->exp_move = MoveNone; } } else if (State->state == PONDER) { ASSERT(State->computer[game_turn(Game)]); ASSERT(!State->computer[colour_opp(game_turn(Game))]); ASSERT(!XB->analyse); if (move == State->exp_move && Uci->searching) { ASSERT(Uci->searching); ASSERT(Uci->pending_nb>=1); my_timer_reset(State->timer); my_timer_start(State->timer); my_log("POLYGLOT PONDER -> THINK (*** HIT ***)\n"); engine_send(Engine,"ponderhit"); State->state = THINK; State->exp_move = MoveNone; send_pv(); // update display return; // do not launch a new search } else { my_log("POLYGLOT PONDER -> THINK (miss)\n"); stop_search(); State->state = THINK; State->exp_move = MoveNone; } } else if (State->state == ANALYSE) { ASSERT(XB->analyse); my_log("POLYGLOT ANALYSE -> ANALYSE\n"); stop_search(); } else { ASSERT(false); } search_update(); }