13 board_ownermap_fill(struct board_ownermap
*ownermap
, struct board
*b
)
17 enum stone color
= board_at(b
, c
);
19 color
= board_get_one_point_eye(b
, c
);
20 ownermap
->map
[c
][color
]++;
25 board_ownermap_merge(int bsize2
, struct board_ownermap
*dst
, struct board_ownermap
*src
)
27 dst
->playouts
+= src
->playouts
;
28 for (int i
= 0; i
< bsize2
; i
++)
29 for (int j
= 0; j
< S_MAX
; j
++)
30 dst
->map
[i
][j
] += src
->map
[i
][j
];
34 board_ownermap_judge_point(struct board_ownermap
*ownermap
, coord_t c
, floating_t thres
)
36 assert(ownermap
->map
);
37 int n
= ownermap
->map
[c
][S_NONE
];
38 int b
= ownermap
->map
[c
][S_BLACK
];
39 int w
= ownermap
->map
[c
][S_WHITE
];
40 int total
= ownermap
->playouts
;
41 if (n
>= total
* thres
)
43 else if (n
+ b
>= total
* thres
)
45 else if (n
+ w
>= total
* thres
)
52 board_ownermap_judge_groups(struct board
*b
, struct board_ownermap
*ownermap
, struct group_judgement
*judge
)
54 assert(ownermap
->map
);
56 memset(judge
->gs
, GS_NONE
, board_size2(b
) * sizeof(judge
->gs
[0]));
59 enum stone color
= board_at(b
, c
);
60 group_t g
= group_at(b
, c
);
63 enum point_judgement pj
= board_ownermap_judge_point(ownermap
, c
, judge
->thres
);
64 // assert(judge->gs[g] == GS_NONE || judge->gs[g] == pj);
65 if (pj
== PJ_UNKNOWN
) {
66 /* Fate is uncertain. */
67 judge
->gs
[g
] = GS_UNKNOWN
;
69 } else if (judge
->gs
[g
] != GS_UNKNOWN
) {
70 /* Update group state. */
73 // Comparing enum types, casting (int) avoids compiler warnings
74 if ((int)pj
== (int)color
) {
76 } else if ((int)pj
== (int)stone_other(color
)) {
78 } else { assert(pj
== PJ_DAME
);
83 if (judge
->gs
[g
] == GS_NONE
) {
85 } else if (judge
->gs
[g
] != new) {
86 /* Contradiction. :( */
87 judge
->gs
[g
] = GS_UNKNOWN
;
94 groups_of_status(struct board
*b
, struct group_judgement
*judge
, enum gj_state s
, struct move_queue
*mq
)
96 foreach_point(b
) { /* foreach_group, effectively */
97 group_t g
= group_at(b
, c
);
98 if (!g
|| g
!= c
) continue;
100 assert(judge
->gs
[g
] != GS_NONE
);
101 if (judge
->gs
[g
] == s
)