Moggy: Never permit self-atari even in random play
[pachi.git] / playout.h
blob0e487a97b221e7c97cfc7e71437917a771e13a7f
1 #ifndef ZZGO_PLAYOUT_H
2 #define ZZGO_PLAYOUT_H
4 struct board;
5 struct move;
6 enum stone;
9 struct playout_policy;
10 typedef coord_t (*playoutp_choose)(struct playout_policy *playout_policy, struct board *b, enum stone to_play);
11 /* 0.0 - 1.0; can return NAN is policy has no opinion */
12 typedef float (*playoutp_assess)(struct playout_policy *playout_policy, struct board *b, struct move *m);
13 typedef bool (*playoutp_permit)(struct playout_policy *playout_policy, struct board *b, struct move *m);
15 struct playout_policy {
16 int debug_level;
17 /* We call choose when we ask policy about next move.
18 * We call assess when we ask policy about how good given move is.
19 * We call permit when we ask policy if we can make a randomly chosen move. */
20 playoutp_choose choose;
21 playoutp_assess assess;
22 playoutp_permit permit;
23 void *data;
27 /* Record of the random playout - for each intersection:
28 * S_NONE: This move was never played
29 * S_BLACK: This move was played by black first
30 * S_WHITE: This move was played by white first
32 struct playout_amafmap {
33 enum stone *map; // [board_size2(b)]
34 /* the lowest &0xf is the enum stone, upper bits are nakade
35 * counter - in case of nakade, we record only color of the
36 * first stone played inside, but count further throwins
37 * and ignore AMAF value after these. */
38 #define amaf_nakade(item_) (item_ >> 8)
39 #define amaf_op(item_, op_) do { \
40 int mi_ = item_; \
41 item_ = (mi_ & 0xf) | ((amaf_nakade(mi_) op_ 1) << 8); \
42 } while (0)
46 /* 1: starting_color wins, 0: starting_color loses
47 * -1: superko inside the game tree */
48 int play_random_game(struct board *b, enum stone starting_color, int gamelen, struct playout_amafmap *amafmap, struct playout_policy *policy);
50 #endif