From 087586af5bf746a740c0c6bc3a3fec7e72fecd40 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 6 Nov 2011 21:09:45 +0200 Subject: [PATCH] UCT local_tree_rootgoal -> local_tree_eval = {root,each} --- uct/internal.h | 5 ++++- uct/uct.c | 28 ++++++++++++++++++++-------- uct/walk.c | 6 +++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 80810cc..71bc543 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -78,7 +78,10 @@ struct uct { floating_t local_tree_depth_decay; bool local_tree_allseq; bool local_tree_neival; - bool local_tree_rootgoal; + enum { + LTE_ROOT, + LTE_EACH, + } local_tree_eval; bool local_tree_rootchoose; char *banner; diff --git a/uct/uct.c b/uct/uct.c index 6a2d748..75bdbb3 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -562,7 +562,7 @@ uct_state_init(char *arg, struct board *b) u->tenuki_d = 4; u->local_tree_aging = 80; u->local_tree_depth_decay = 1.5; - u->local_tree_rootgoal = true; + u->local_tree_eval = LTE_ROOT; u->local_tree_neival = true; u->max_slaves = -1; @@ -901,18 +901,30 @@ uct_state_init(char *arg, struct board *b) * computed just based on terminal status * of the coordinate, but also its neighbors. */ u->local_tree_neival = !optval || atoi(optval); - } else if (!strcasecmp(optname, "local_tree_rootgoal")) { - /* If enabled, all moves within a tree branch - * are considered wrt. their merit reaching - * tachtical goal of making the first move - * in the branch survive. */ - u->local_tree_rootgoal = !optval || atoi(optval); + } else if (!strcasecmp(optname, "local_tree_eval")) { + /* How is the value inserted in the local tree + * determined. */ + if (!strcasecmp(optval, "root")) + /* All moves within a tree branch are + * considered wrt. their merit + * reaching tachtical goal of making + * the first move in the branch + * survive. */ + u->local_tree_eval = LTE_ROOT; + else if (!strcasecmp(optval, "each")) + /* Each move is considered wrt. + * its own survival. */ + u->local_tree_eval = LTE_EACH; + else { + fprintf(stderr, "uct: unknown local_tree_eval %s\n", optval); + exit(1); + } } else if (!strcasecmp(optname, "local_tree_rootchoose")) { /* If disabled, only moves within the local * tree branch are considered; the values * of the branch roots (i.e. root children) * are ignored. This may make sense together - * with "rootgoal", we consider only moves + * with eval!=each, we consider only moves * that influence the goal, not the "rating" * of the goal itself. (The real solution * will be probably using criticality to pick diff --git a/uct/walk.c b/uct/walk.c index aa58fea..999f0cf 100644 --- a/uct/walk.c +++ b/uct/walk.c @@ -224,7 +224,7 @@ record_local_sequence(struct uct *u, struct tree *t, struct board *endb, lnode->u.playouts++; double sval = 0.5; - if (u->local_tree_rootgoal) { + if (u->local_tree_eval != LTE_EACH) { sval = local_value(u, endb, node_coord(descent[di].node), seq_color); LTREE_DEBUG fprintf(stderr, "(goal %s[%s %1.3f][%d]) ", coord2sstr(node_coord(descent[di].node), t->board), @@ -236,7 +236,7 @@ record_local_sequence(struct uct *u, struct tree *t, struct board *endb, while (di < dlen && (di == di0 || descent[di].node->d < u->tenuki_d)) { enum stone color = (di - di0) % 2 ? stone_other(seq_color) : seq_color; double rval; - if (u->local_tree_rootgoal) + if (u->local_tree_eval != LTE_EACH) rval = sval; else rval = local_value(u, endb, node_coord(descent[di].node), color); @@ -250,7 +250,7 @@ record_local_sequence(struct uct *u, struct tree *t, struct board *endb, /* Add lnode for tenuki (pass) if we descended further. */ if (di < dlen) { - double rval = u->local_tree_rootgoal ? sval : 0.5; + double rval = u->local_tree_eval != LTE_EACH ? sval : 0.5; LTREE_DEBUG fprintf(stderr, "pass "); lnode = tree_get_node(t, lnode, pass, true); assert(lnode); -- 2.11.4.GIT