From 61b284978c7bb832000cd4a7ce03e4720df9510d Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 23 Dec 2010 18:38:17 +0100 Subject: [PATCH] Debugging: Introduce -D (debug_boardprint) for more gogui friendliness --- debug.h | 3 +++ gtp.c | 14 +++++++------- zzgo.c | 8 ++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/debug.h b/debug.h index 99a283a..ab69790 100644 --- a/debug.h +++ b/debug.h @@ -1,6 +1,8 @@ #ifndef ZZGO_DEBUG_H #define ZZGO_DEBUG_H +#include + #ifdef DEBUG #define DEBUGL_(l, n) (unlikely((l) > (n))) #define DEBUG_MODE (true) @@ -10,6 +12,7 @@ #endif extern int debug_level; +extern bool debug_boardprint; #define DEBUGL(n) DEBUGL_(debug_level, n) diff --git a/gtp.c b/gtp.c index 80ef1c6..6e8728f 100644 --- a/gtp.c +++ b/gtp.c @@ -196,7 +196,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char } else if (!strcasecmp(cmd, "clear_board") || !strcasecmp(cmd, "kgs-game_over")) { board_clear(board); - if (DEBUGL(1)) + if (DEBUGL(1) && debug_boardprint) board_print(board, stderr); if (!strcasecmp(cmd, "kgs-game_over")) { if (DEBUGL(0)) @@ -213,7 +213,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char next_tok(arg); sscanf(arg, "%f", &board->komi); - if (DEBUGL(1)) + if (DEBUGL(1 && debug_boardprint)) board_print(board, stderr); gtp_reply(id, NULL); @@ -260,7 +260,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char } gtp_error(id, "illegal move", NULL); } else { - if (DEBUGL(1)) + if (DEBUGL(1) && debug_boardprint) board_print_custom(board, stderr, engine->printhook); gtp_reply(id, reply, NULL); } @@ -292,7 +292,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char char *str = coord2str(*c, board); if (DEBUGL(1)) fprintf(stderr, "playing move %s\n", str); - if (DEBUGL(1)) { + if (DEBUGL(1) && debug_boardprint) { board_print_custom(board, stderr, engine->printhook); } gtp_reply(id, str, NULL); @@ -322,7 +322,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char } if (DEBUGL(3)) fprintf(stderr, "proposing moves %s\n", reply); - if (DEBUGL(4)) + if (DEBUGL(4) && debug_boardprint) board_print_custom(board, stderr, engine->printhook); gtp_reply(id, reply, NULL); if (stats_size > 0) { @@ -354,7 +354,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char board->handicap++; next_tok(arg); } while (*arg); - if (DEBUGL(1)) + if (DEBUGL(1) && debug_boardprint) board_print(board, stderr); gtp_reply(id, NULL); @@ -369,7 +369,7 @@ gtp_parse(struct board *board, struct engine *engine, struct time_info *ti, char gtp_prefix('=', id); board_handicap(board, stones, id == NO_REPLY ? NULL : stdout); - if (DEBUGL(1)) + if (DEBUGL(1) && debug_boardprint) board_print(board, stderr); if (id == NO_REPLY) return P_OK; putchar('\n'); diff --git a/zzgo.c b/zzgo.c index b87489d..3ce5bf5 100644 --- a/zzgo.c +++ b/zzgo.c @@ -25,6 +25,7 @@ #include "network.h" int debug_level = 3; +bool debug_boardprint = true; long verbose_logs = 0; int seed; @@ -70,7 +71,7 @@ static void usage(char *name) { fprintf(stderr, "Pachi version %s\n", PACHI_VERSION); fprintf(stderr, "Usage: %s [-e random|replay|patternscan|montecarlo|uct|distributed]\n" - " [-d DEBUG_LEVEL] [-s RANDOM_SEED] [-t TIME_SETTINGS] [-u TEST_FILENAME]\n" + " [-d DEBUG_LEVEL] [-D] [-s RANDOM_SEED] [-t TIME_SETTINGS] [-u TEST_FILENAME]\n" " [-g [HOST:]GTP_PORT] [-l [HOST:]LOG_PORT] [-f FBOOKFILE] [ENGINE_ARGS]\n", name); } @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) seed = time(NULL) ^ getpid(); int opt; - while ((opt = getopt(argc, argv, "e:d:f:g:l:s:t:u:")) != -1) { + while ((opt = getopt(argc, argv, "e:d:Df:g:l:s:t:u:")) != -1) { switch (opt) { case 'e': if (!strcasecmp(optarg, "random")) { @@ -112,6 +113,9 @@ int main(int argc, char *argv[]) case 'd': debug_level = atoi(optarg); break; + case 'D': + debug_boardprint = false; + break; case 'f': fbookfile = strdup(optarg); break; -- 2.11.4.GIT