From cf9979fdb20af55a272cc219b277d5278487df43 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 26 May 2011 12:26:22 +0200 Subject: [PATCH] UCT reporting: Introduce new option, factor out uct_progress_text() So far, only value UR_TEXT is supported. --- uct/internal.h | 4 ++++ uct/uct.c | 11 +++++++++++ uct/walk.c | 14 +++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/uct/internal.h b/uct/internal.h index 417397b..5e8c346 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -26,6 +26,10 @@ struct joseki_dict; /* Internal engine state. */ struct uct { int debug_level; + enum uct_reporting { + UR_TEXT, + } reporting; + int games, gamelen; floating_t resign_threshold, sure_win_threshold; double best2_ratio, bestr_ratio; diff --git a/uct/uct.c b/uct/uct.c index 7913923..24e6002 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -589,6 +589,17 @@ uct_state_init(char *arg, struct board *b) u->debug_level = atoi(optval); else u->debug_level++; + } else if (!strcasecmp(optname, "reporting") && optval) { + /* The format of output for detailed progress + * information (such as current best move and + * its value, etc.). */ + if (!strcasecmp(optval, "text")) { + /* Plaintext traditional output. */ + u->reporting = UR_TEXT; + } else { + fprintf(stderr, "UCT: Invalid reporting format %s\n", optval); + exit(1); + } } else if (!strcasecmp(optname, "dumpthres") && optval) { /* When dumping the UCT tree on output, include * nodes with at least this many playouts. diff --git a/uct/walk.c b/uct/walk.c index c9124b2..6ff7cbc 100644 --- a/uct/walk.c +++ b/uct/walk.c @@ -23,8 +23,9 @@ #define DESCENT_DLEN 512 + void -uct_progress_status(struct uct *u, struct tree *t, enum stone color, int playouts, bool final) +uct_progress_text(struct uct *u, struct tree *t, enum stone color, int playouts, bool final) { if (!UDEBUGL(0)) return; @@ -79,6 +80,17 @@ uct_progress_status(struct uct *u, struct tree *t, enum stone color, int playout fprintf(stderr, "\n"); } +void +uct_progress_status(struct uct *u, struct tree *t, enum stone color, int playouts, bool final) +{ + switch (u->reporting) { + case UR_TEXT: + uct_progress_text(u, t, color, playouts, final); + break; + default: assert(0); + } +} + static void record_amaf_move(struct playout_amafmap *amaf, coord_t coord, enum stone color) -- 2.11.4.GIT