From 9e2a4e58ffe8b52a5fff8e66b808ed97c153b9ea Mon Sep 17 00:00:00 2001 From: r6144 Date: Tue, 12 Jul 2011 21:09:22 +0800 Subject: [PATCH] Added the unlimited_tree_dump option so that reducing dumpthres actually becomes useful. --- uct/internal.h | 1 + uct/tree.c | 4 ++-- uct/tree.h | 2 +- uct/uct.c | 12 +++++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 3fa4591..fea25c5 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -38,6 +38,7 @@ struct uct { int playout_amaf_cutoff; int dumpthres; int force_seed; + bool unlimited_tree_dump; bool no_tbook; bool fast_alloc; unsigned long max_tree_size; diff --git a/uct/tree.c b/uct/tree.c index ff575c1..ea246f9 100644 --- a/uct/tree.c +++ b/uct/tree.c @@ -223,9 +223,9 @@ tree_node_dump(struct tree *tree, struct tree_node *node, int l, int thres) } void -tree_dump(struct tree *tree, int thres) +tree_dump(struct tree *tree, int thres, bool unlimited) { - if (thres && tree->root->u.playouts / thres > 100) { + if (!unlimited && thres && tree->root->u.playouts / thres > 100) { /* Be a bit sensible about this; the opening tbook can create * huge dumps at first. */ thres = tree->root->u.playouts / 100 * (thres < 1000 ? 1 : thres / 1000); diff --git a/uct/tree.h b/uct/tree.h index b914f16..fdcb933 100644 --- a/uct/tree.h +++ b/uct/tree.h @@ -142,7 +142,7 @@ struct tree { struct tree *tree_init(struct board *board, enum stone color, unsigned long max_tree_size, unsigned long max_pruned_size, unsigned long pruning_threshold, floating_t ltree_aging, int hbits); void tree_done(struct tree *tree); -void tree_dump(struct tree *tree, int thres); +void tree_dump(struct tree *tree, int thres, bool unlimited); void tree_save(struct tree *tree, struct board *b, int thres); void tree_load(struct tree *tree, struct board *b); diff --git a/uct/uct.c b/uct/uct.c index 0d86814..438f4e3 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -148,7 +148,7 @@ uct_notify_play(struct engine *e, struct board *b, struct move *m) /* Stop pondering, required by tree_promote_at() */ uct_pondering_stop(u); if (UDEBUGL(2) && u->slave) - tree_dump(u->t, u->dumpthres); + tree_dump(u->t, u->dumpthres, u->unlimited_tree_dump); if (is_resign(m->coord)) { /* Reset state. */ @@ -324,7 +324,7 @@ uct_search(struct uct *u, struct board *b, struct time_info *ti, enum stone colo } struct uct_thread_ctx *ctx = uct_search_stop(); - if (UDEBUGL(2)) tree_dump(t, u->dumpthres); + if (UDEBUGL(2)) tree_dump(t, u->dumpthres, u->unlimited_tree_dump); if (UDEBUGL(2)) fprintf(stderr, "(avg score %f/%d value %f/%d)\n", u->dynkomi->score.value, u->dynkomi->score.playouts, @@ -489,7 +489,7 @@ uct_dumptbook(struct engine *e, struct board *b, enum stone color) struct tree *t = tree_init(b, color, u->fast_alloc ? u->max_tree_size : 0, u->max_pruned_size, u->pruning_threshold, u->local_tree_aging, 0); tree_load(t, b); - tree_dump(t, 0); + tree_dump(t, 0, true); tree_done(t); } @@ -539,6 +539,7 @@ uct_state_init(char *arg, struct board *b) u->significant_threshold = 50; u->expand_p = 2; u->dumpthres = 1000; + u->unlimited_tree_dump = false; u->playout_amaf = true; u->playout_amaf_nakade = false; u->amaf_prior = false; @@ -598,6 +599,11 @@ uct_state_init(char *arg, struct board *b) * (This value is re-scaled "intelligently" * in case of very large trees.) */ u->dumpthres = atoi(optval); + } else if (!strcasecmp(optname, "unlimited_tree_dump")) { + /* If true, dumpthres is not increased even if the number of + * playouts is much larger than it. Good for debugging, but could + * lead to too much verbosity in actual games. */ + u->unlimited_tree_dump = true; } else if (!strcasecmp(optname, "resign_threshold") && optval) { /* Resign when this ratio of games is lost * after GJ_MINGAMES sample is taken. */ -- 2.11.4.GIT