UCT pondering: Enable by default
[pachi/nmclean.git] / uct / prior.h
blob212c0276cf57e4af32b3056a7264336f469d7c2a
1 #ifndef PACHI_UCT_PRIOR_H
2 #define PACHI_UCT_PRIOR_H
4 #include "move.h"
5 #include "uct/tree.h"
7 struct tree;
8 struct tree_node;
9 struct uct;
10 struct board;
12 struct prior_map {
13 struct board *b;
14 enum stone to_play;
15 int parity;
16 /* [board_size2(b)] array, move_stats are the prior
17 * values to be assigned to individual moves;
18 * move_stats.value is not updated. */
19 struct move_stats *prior;
20 /* [board_size2(b)] array, whether to compute
21 * prior for the given value. */
22 bool *consider;
23 /* [board_size2(b)] array from cfg_distances() */
24 int *distances;
27 /* @value is the value, @playouts is its weight. */
28 static void add_prior_value(struct prior_map *map, coord_t c, floating_t value, int playouts);
30 void uct_prior(struct uct *u, struct tree_node *node, struct prior_map *map);
32 struct uct_prior;
33 struct uct_prior *uct_prior_init(char *arg, struct board *b, struct uct *u);
34 void uct_prior_done(struct uct_prior *p);
37 static inline void
38 add_prior_value(struct prior_map *map, coord_t c, floating_t value, int playouts)
40 floating_t v = map->parity > 0 ? value : 1 - value;
41 /* We don't need atomicity: */
42 struct move_stats s = { .playouts = playouts, .value = v };
43 stats_merge(&map->prior[c], &s);
46 #endif