static int gtp_genmove(char *s) { int i, j; int color = EMPTY; if (!gtp_decode_color(s, &color)) return gtp_failure("invalid color"); generate_move(&i, &j, color); play_move(i, j, color); gtp_start_response(GTP_SUCCESS); gtp_mprintf("%m", i, j); return gtp_finish_response(); }
/* Function: Generate and play the supposedly best move for either color. * Arguments: color to move * Fails: invalid color * Returns: a move coordinate or "PASS" (or "resign" if resignation_allowed) * * Status: GTP version 2 standard command. */ static int gtp_genmove(char *s) { DataGo move; Player color; if (!gtp_decode_color(s, &color)) return gtp_failure("invalid color"); move = game->gen_move(color); if (IS_RESIGN(move)) return gtp_success("resign"); assert(game->play_move(move)); gtp_start_response(GTP_SUCCESS); if (IS_PASS(move)) gtp_print_vertex(-1, -1); else gtp_print_vertex(move.i, move.j); return gtp_finish_response(); }