From 4825703063ec038e693483d137fe53b05e19c2e0 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Tue, 17 Aug 2010 22:47:47 +0200 Subject: [PATCH] UCT local_tree_rootseqval: Implement --- uct/internal.h | 1 + uct/uct.c | 7 +++++++ uct/walk.c | 13 +++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 0afe868..c93d50f 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -89,6 +89,7 @@ struct uct { /* Playout-localtree integration. */ bool local_tree_playout; // can be true only if ELO playout bool local_tree_pseqroot; + bool local_tree_rootseqval; char *banner; diff --git a/uct/uct.c b/uct/uct.c index 49820b0..e5d38bc 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -909,6 +909,13 @@ uct_state_init(char *arg, struct board *b) * is on, we make probability distribution from * sequences first moves instead. */ u->local_tree_pseqroot = !optval || atoi(optval); + } else if (!strcasecmp(optname, "local_tree_rootseqval")) { + /* By default, expected node value is computed by + * summing up values through the whole descent. + * With this settings, expected node value for + * each sequence is the value at the root of the + * sequence. */ + u->local_tree_rootseqval = !optval || atoi(optval); /** Other heuristics */ } else if (!strcasecmp(optname, "significant_threshold") && optval) { diff --git a/uct/walk.c b/uct/walk.c index 1ded011..2e77d58 100644 --- a/uct/walk.c +++ b/uct/walk.c @@ -400,6 +400,13 @@ record_local_sequence(struct uct *u, struct tree *t, if (is_pass(descent[di].node->coord)) return; + /* Transform the rval appropriately, based on the expected + * result at the root of the sequence. */ + if (u->local_tree_rootseqval) { + float expval = descent[di - 1].value.value; + rval = stats_temper_value(rval, expval, u->local_tree); + } + #define LTREE_DEBUG if (UDEBUGL(6)) LTREE_DEBUG fprintf(stderr, "recording result %f in local %s sequence: ", rval, stone2str(seq_color)); @@ -616,8 +623,10 @@ uct_playout(struct uct *u, struct board *b, enum stone player_color, struct tree if (u->local_tree && n->parent && !is_pass(n->coord) && dlen > 0) { /* Possibly transform the rval appropriately. */ - floating_t expval = seq_value.value / seq_value.playouts; - rval = stats_temper_value(rval, expval, u->local_tree); + if (!u->local_tree_rootseqval) { + floating_t expval = seq_value.value / seq_value.playouts; + rval = stats_temper_value(rval, expval, u->local_tree); + } /* Get the local sequences and record them in ltree. */ /* We will look for sequence starts in our descent -- 2.11.4.GIT