From 13e41caf325a8860f5fd40cf9200bfb8f5a80a71 Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Mon, 15 Feb 2010 00:31:37 +0100 Subject: [PATCH] Add option territory_scoring to support Japanese rules. --- uct/internal.h | 1 + uct/uct.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 6d14bc6..1311265 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -24,6 +24,7 @@ struct uct { float loss_threshold; double best2_ratio, bestr_ratio; bool pass_all_alive; + bool territory_scoring; int expand_p; bool playout_amaf, playout_amaf_nakade; bool amaf_prior; diff --git a/uct/uct.c b/uct/uct.c index 3dc5949..dda7241 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -709,12 +709,8 @@ uct_genmove(struct engine *e, struct board *b, struct time_info *ti, enum stone * is odd so we adjust the komi only if it is even (for a board of * odd size). We are not trying to get an exact evaluation for rare * cases of seki. For details see http://home.snafu.de/jasiek/parity.html - - * Further complication: kgs does not yet tell which rules are used. - * So until the kgs-rules command is available, we assume that we - * are playing with Japanese rules if not in tournament conditions. - * TODO: remove this assumption once kgs-rules is available. */ - if (!u->pass_all_alive && (((int)floor(b->komi) + b->size) & 1)) { + * TODO: Support the kgs-rules command once available. */ + if (u->territory_scoring && (((int)floor(b->komi) + b->size) & 1)) { b->komi += (color == S_BLACK ? 1.0 : -1.0); if (UDEBUGL(0)) fprintf(stderr, "Setting komi to %.1f assuming Japanese rules\n", @@ -1025,6 +1021,10 @@ uct_state_init(char *arg, struct board *b) /* Whether to consider all stones alive at the game * end instead of marking dead groupd. */ u->pass_all_alive = !optval || atoi(optval); + } else if (!strcasecmp(optname, "territory_scoring")) { + /* Use territory scoring (default is area scoring). + * An explicit kgs-rules command overrides this. */ + u->territory_scoring = !optval || atoi(optval); } else if (!strcasecmp(optname, "random_policy_chance") && optval) { /* If specified (N), with probability 1/N, random_policy policy * descend is used instead of main policy descend; useful -- 2.11.4.GIT