Merge pull request #48 from lemonsqueeze/tactics_undo
[pachi.git] / ownermap.h
blob88544ace08e945efdaf718d81f1c764fbd168253
1 #ifndef PACHI_OWNERMAP_H
2 #define PACHI_OWNERMAP_H
4 /* Map of board intersection owners, and devices to derive group status
5 * information from the map. */
7 #include <signal.h> // sig_atomic_t
9 /* How big proportion of ownermap counts must be of one color to consider
10 * the point sure. */
11 #define GJ_THRES 0.8
13 struct board_ownermap {
14 /* Map of final owners of all intersections on the board. */
15 /* This may be shared between multiple threads! */
16 /* XXX: We assume sig_atomic_t is thread-atomic. This may not
17 * be true in pathological cases. */
18 sig_atomic_t playouts;
19 /* At the final board position, for each coordinate increase the
20 * counter of appropriate color. */
21 sig_atomic_t (*map)[S_MAX]; // [board_size2(b)]
24 void board_print_ownermap(struct board *b, FILE *f, struct board_ownermap *ownermap);
25 void board_ownermap_fill(struct board_ownermap *ownermap, struct board *b);
26 void board_ownermap_merge(int bsize2, struct board_ownermap *dst, struct board_ownermap *src);
29 /* Estimate coord ownership based on ownermap stats. */
30 enum point_judgement {
31 PJ_DAME = S_NONE,
32 PJ_BLACK = S_BLACK,
33 PJ_WHITE = S_WHITE,
34 PJ_UNKNOWN = 3,
36 enum point_judgement board_ownermap_judge_point(struct board_ownermap *ownermap, coord_t c, floating_t thres);
37 float board_ownermap_estimate_point(struct board_ownermap *ownermap, coord_t c);
40 /* Estimate status of stones on board based on ownermap stats. */
41 struct group_judgement {
42 floating_t thres;
43 enum gj_state {
44 GS_NONE,
45 GS_DEAD,
46 GS_ALIVE,
47 GS_UNKNOWN,
48 } *gs; // [bsize2]
50 void board_ownermap_judge_groups(struct board *b, struct board_ownermap *ownermap, struct group_judgement *judge);
52 /* Add groups of given status to mq. */
53 struct move_queue;
54 void groups_of_status(struct board *b, struct group_judgement *judge, enum gj_state s, struct move_queue *mq);
56 #endif