From f2abeaa4a712d422d7c37a9622567cc9c3c63f0b Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Tue, 13 Oct 2009 17:08:59 +0200 Subject: [PATCH] UCT: Support val_extra to control the value term --- uct/internal.h | 1 + uct/uct.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/uct/internal.h b/uct/internal.h index da93141..cbe5471 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -32,6 +32,7 @@ struct uct { float val_scale; int val_points; + bool val_extra; struct uct_policy *policy; struct tree *t; diff --git a/uct/uct.c b/uct/uct.c index 22ebaa8..63a9fdb 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -260,7 +260,10 @@ uct_playout(struct uct *u, struct board *b, enum stone player_color, struct tree float sval = (float) abs(result) / u->val_points; sval = sval > 1 ? 1 : sval; if (result < 0) sval = 1 - sval; - rval = (1 - u->val_scale) * rval + u->val_scale * sval; + if (u->val_extra) + rval += u->val_scale * sval; + else + rval = (1 - u->val_scale) * rval + u->val_scale * sval; // fprintf(stderr, "score %d => sval %f, rval %f\n", result, sval, rval); } u->policy->update(u->policy, t, n, node_color, player_color, amaf, rval); @@ -626,6 +629,11 @@ uct_state_init(char *arg) /* Maximum size of win to be scaled into game * result value. */ u->val_points = atoi(optval) * 2; // result values are doubled + } else if (!strcasecmp(optname, "val_extra")) { + /* If false, the score coefficient will be simply + * added to the value, instead of scaling the result + * coefficient because of it. */ + u->val_extra = !optval || atoi(optval); } else { fprintf(stderr, "uct: Invalid engine argument %s or missing value\n", optname); exit(1); -- 2.11.4.GIT