TESTS: Explain about confidence interval vs stderr
[pachi.git] / playout.h
blob47141744abdca9a0c885fbdf421b9d789e45e470
1 #ifndef ZZGO_PLAYOUT_H
2 #define ZZGO_PLAYOUT_H
4 #define MAX_GAMELEN 600
6 struct board;
7 struct move;
8 enum stone;
9 struct prior_map;
12 struct playout_policy;
13 typedef coord_t (*playoutp_choose)(struct playout_policy *playout_policy, struct board *b, enum stone to_play);
14 /* Set number of won (>0) or lost (<0) games for each considerable
15 * move (usually a proportion of @games); can leave some untouched
16 * if policy has no opinion. The number must have proper parity;
17 * just use uct/prior.h:add_prior_value(). */
18 typedef void (*playoutp_assess)(struct playout_policy *playout_policy, struct prior_map *map, int games);
19 typedef bool (*playoutp_permit)(struct playout_policy *playout_policy, struct board *b, struct move *m);
21 struct playout_policy {
22 int debug_level;
23 /* We call choose when we ask policy about next move.
24 * We call assess when we ask policy about how good given move is.
25 * We call permit when we ask policy if we can make a randomly chosen move. */
26 playoutp_choose choose;
27 playoutp_assess assess;
28 playoutp_permit permit;
29 void *data;
32 struct playout_ownermap {
33 int playouts;
34 /* At the final board position, for each coordinate increase the
35 * counter of appropriate color. */
36 int *map[S_MAX]; // [board_size2(b)]
40 struct playout_amafmap {
41 /* Record of the random playout - for each intersection:
42 * S_NONE: This move was never played
43 * S_BLACK: This move was played by black first
44 * S_WHITE: This move was played by white first
46 enum stone *map; // [board_size2(b)]
48 /* the lowest &0xf is the enum stone, upper bits are nakade
49 * counter - in case of nakade, we record only color of the
50 * first stone played inside, but count further throwins
51 * and ignore AMAF value after these. */
52 #define amaf_nakade(item_) (item_ >> 8)
53 #define amaf_op(item_, op_) do { \
54 int mi_ = item_; \
55 item_ = (mi_ & 0xf) | ((amaf_nakade(mi_) op_ 1) << 8); \
56 } while (0)
58 /* Additionally, we keep record of the game so that we can
59 * examine nakade moves; really going out of our way to
60 * implement nakade AMAF properly turns out to be crucial
61 * when reading some tactical positions in depth (even if
62 * they are just one-stone-snapback). */
63 struct move game[MAX_GAMELEN + 1];
64 int gamelen;
65 /* Our current position in the game sequence; in AMAF, we search
66 * the range [game_baselen, gamelen]. */
67 int game_baselen;
69 /* Whether to record the nakade moves (true) or just completely
70 * ignore them (false; just the first color on the intersection
71 * is stored in the map, nakade counter is not incremented; game
72 * record is still kept). */
73 bool record_nakade;
77 /* >0: starting_color wins, <0: starting_color loses; the actual
78 * number is a DOUBLE of the score difference
79 * 0: superko inside the game tree (XXX: jigo not handled) */
80 int play_random_game(struct board *b, enum stone starting_color, int gamelen,
81 struct playout_amafmap *amafmap,
82 struct playout_ownermap *ownermap,
83 struct playout_policy *policy);
85 #endif