From 9fd58a24a02e03d5806977843f199170df802e9d Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 2 Oct 2009 15:54:57 +0200 Subject: [PATCH] Prior map: Add bool[] consider array to denote uninteresting map locations --- uct/prior.c | 2 +- uct/prior.h | 3 +++ uct/tree.c | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/uct/prior.c b/uct/prior.c index 01537dc..2518651 100644 --- a/uct/prior.c +++ b/uct/prior.c @@ -93,7 +93,7 @@ void uct_prior(struct uct *u, struct tree_node *node, struct prior_map *map) { foreach_point(map->b) { - if (board_at(map->b, c) != S_NONE) + if (!map->consider[c]) continue; uct_prior_one(u, node, map, c); } foreach_point_end; diff --git a/uct/prior.h b/uct/prior.h index bcf93d5..53b1232 100644 --- a/uct/prior.h +++ b/uct/prior.h @@ -17,6 +17,9 @@ struct prior_map { * values to be assigned to individual moves; * move_stats.value is not updated. */ struct move_stats *prior; + /* [board_size2(b)] array, whether to compute + * prior for the given value. */ + bool *consider; }; void uct_prior(struct uct *u, struct tree_node *node, struct prior_map *map); diff --git a/uct/tree.c b/uct/tree.c index 03e86c2..a1eeb63 100644 --- a/uct/tree.c +++ b/uct/tree.c @@ -362,9 +362,18 @@ tree_expand_node(struct tree *t, struct tree_node *node, struct board *b, enum s .to_play = color, .parity = tree_parity(t, parity), }; - /* Include pass in the prior map. */ - map.prior = calloc(board_size2(b) + 1, sizeof(*map.prior)); - map.prior++; + // Include pass in the prior map. + map.prior = calloc(board_size2(b) + 1, sizeof(*map.prior)); map.prior++; + map.consider = calloc(board_size2(b) + 1, sizeof(*map.consider)); map.consider++; + struct move pm = { .color = color }; + foreach_point(b) { + if (board_at(b, c) != S_NONE) + continue; + pm.coord = c; + if (!board_is_valid_move(b, &pm)) + continue; + map.consider[c] = true; + } foreach_point_end; uct_prior(u, node, &map); /* Now, create the nodes. */ -- 2.11.4.GIT