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
, float 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_group(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 if (pj
== PJ_UNKNOWN
) {
65 /* Fate is uncertain. */
66 judge
->gs
[g
] = GS_UNKNOWN
;
68 } else if (judge
->gs
[g
] != GS_UNKNOWN
) {
69 /* Update group state. */
73 } else if (pj
== stone_other(color
)) {
75 } else { assert(pj
== PJ_DAME
);
80 if (judge
->gs
[g
] == GS_NONE
) {
82 } else if (judge
->gs
[g
] != new) {
83 /* Contradiction. :( */
84 judge
->gs
[g
] = GS_UNKNOWN
;
91 groups_of_status(struct board
*b
, struct group_judgement
*judge
, enum gj_state s
, struct move_queue
*mq
)
93 foreach_point(b
) { /* foreach_group, effectively */
94 group_t g
= group_at(b
, c
);
95 if (!g
|| g
!= c
) continue;
97 assert(judge
->gs
[g
] != GS_NONE
);
98 if (judge
->gs
[g
] == s
)