add_prior_value(): Introduce instead of manually incrementing stuff; accounts for...
[pachi.git] / uct / prior.h
blob8e4a60465ad5709f0cd1b7f5894bca83360a9218
1 #ifndef ZZGO_UCT_PRIOR_H
2 #define ZZGO_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;
25 /* Wins can be negative to give losses; passing 0 wins is undefined. */
26 static void add_prior_value(struct prior_map *map, coord_t c, int wins, int playouts);
28 void uct_prior(struct uct *u, struct tree_node *node, struct prior_map *map);
31 static inline void
32 add_prior_value(struct prior_map *map, coord_t c, int wins, int playouts)
34 map->prior[c].playouts += playouts;
36 assert(wins != 0);
37 int w = wins * map->parity;
38 if (w < 0) w = playouts + wins;
39 map->prior[c].wins += wins;
42 #endif