10 typedef coord_t (*playoutp_choose
)(struct playout_policy
*playout_policy
, struct board
*b
, enum stone to_play
);
11 /* number of won (>0) or lost (<0) games to seed the node with (usually a proportion of @games);
12 * can return 0 if policy has no opinion */
13 typedef int (*playoutp_assess
)(struct playout_policy
*playout_policy
, struct board
*b
, struct move
*m
, int games
);
14 typedef bool (*playoutp_permit
)(struct playout_policy
*playout_policy
, struct board
*b
, struct move
*m
);
16 struct playout_policy
{
18 /* We call choose when we ask policy about next move.
19 * We call assess when we ask policy about how good given move is.
20 * We call permit when we ask policy if we can make a randomly chosen move. */
21 playoutp_choose choose
;
22 playoutp_assess assess
;
23 playoutp_permit permit
;
28 struct playout_amafmap
{
29 /* Record of the random playout - for each intersection:
30 * S_NONE: This move was never played
31 * S_BLACK: This move was played by black first
32 * S_WHITE: This move was played by white first
34 enum stone
*map
; // [board_size2(b)]
36 /* the lowest &0xf is the enum stone, upper bits are nakade
37 * counter - in case of nakade, we record only color of the
38 * first stone played inside, but count further throwins
39 * and ignore AMAF value after these. */
40 #define amaf_nakade(item_) (item_ >> 8)
41 #define amaf_op(item_, op_) do { \
43 item_ = (mi_ & 0xf) | ((amaf_nakade(mi_) op_ 1) << 8); \
46 /* Additionally, we keep record of the game so that we can
47 * examine nakade moves; really going out of our way to
48 * implement nakade AMAF properly turns out to be crucial
49 * when reading some tactical positions in depth (even if
50 * they are just one-stone-snapback). */
51 struct move game
[512];
53 /* Our current position in the game sequence; in AMAF, we search
54 * the range [game_baselen, gamelen]. */
57 /* Whether to record the nakade moves (true) or just completely
58 * ignore them (false; just the first color on the intersection
59 * is stored in the map, nakade counter is not incremented; game
60 * record is still kept). */
65 /* 1: starting_color wins, 0: starting_color loses
66 * -1: superko inside the game tree */
67 int play_random_game(struct board
*b
, enum stone starting_color
, int gamelen
, struct playout_amafmap
*amafmap
, struct playout_policy
*policy
);