From 5da570f9d3edb49909583f41483215be1c46fbf7 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 11 Jan 2012 03:47:29 +0100 Subject: [PATCH] UCT patterns parameter: Introduce; allows e.g. pdict customization for priors --- uct/internal.h | 4 ++++ uct/prior.c | 5 ++--- uct/uct.c | 13 +++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 043a438..135b916 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -96,7 +96,11 @@ struct uct { struct uct_prior *prior; struct uct_pluginset *plugins; struct joseki_dict *jdict; + struct pattern_setup pat; + /* Various modules (prior, policy, ...) set this if they want pattern + * database to be loaded. */ + bool want_pat; /* Used within frame of single genmove. */ struct board_ownermap ownermap; diff --git a/uct/prior.c b/uct/prior.c index 25a9551..8a97db2 100644 --- a/uct/prior.c +++ b/uct/prior.c @@ -289,9 +289,8 @@ uct_prior_init(char *arg, struct board *b, struct uct *u) exit(1); } - if (p->pattern_eqex) { - patterns_init(&u->pat, NULL, false, true); - } + if (p->pattern_eqex) + u->want_pat = true; return p; } diff --git a/uct/uct.c b/uct/uct.c index c927b95..f26fb0d 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -539,6 +539,7 @@ struct uct * uct_state_init(char *arg, struct board *b) { struct uct *u = calloc2(1, sizeof(struct uct)); + bool pat_setup = false; u->debug_level = debug_level; u->gamelen = MC_GAMELEN; @@ -950,6 +951,15 @@ uct_state_init(char *arg, struct board *b) u->local_tree_rootchoose = !optval || atoi(optval); /** Other heuristics */ + } else if (!strcasecmp(optname, "patterns")) { + /* Load pattern database. Various modules + * (priors, policies etc.) may make use + * of this database. They will request + * it automatically in that case, but you + * can use this option to tweak the pattern + * parameters. */ + patterns_init(&u->pat, optval, false, true); + u->want_pat = pat_setup = true; } else if (!strcasecmp(optname, "significant_threshold") && optval) { /* Some heuristics (XXX: none in mainline) rely * on the knowledge of the last "significant" @@ -1029,6 +1039,9 @@ uct_state_init(char *arg, struct board *b) if (!u->playout->debug_level) u->playout->debug_level = u->debug_level; + if (u->want_pat && !pat_setup) + patterns_init(&u->pat, NULL, false, true); + u->ownermap.map = malloc2(board_size2(b) * sizeof(u->ownermap.map[0])); if (u->slave) { -- 2.11.4.GIT