12 play_random_game(struct board
*b
, struct move
*m
, int gamelen
,
13 playout_policeman policeman
, void *policy
)
15 if (b
->superko_violation
) {
17 fprintf(stderr
, "\tILLEGAL: superko violation at root!\n");
18 board_print(b
, stderr
);
26 board_play_random(&b2
, m
->color
, &m
->coord
);
27 if (!is_pass(m
->coord
) && !group_at(&b2
, m
->coord
)) {
29 fprintf(stderr
, "SUICIDE DETECTED at %d,%d:\n", coord_x(m
->coord
, b
), coord_y(m
->coord
, b
));
30 board_print(&b2
, stderr
);
32 board_done_noalloc(&b2
);
37 fprintf(stderr
, "[%d,%d] playing random game of color %d\n", coord_x(m
->coord
, b
), coord_y(m
->coord
, b
), m
->color
);
39 gamelen
= gamelen
- b2
.moves
;
43 enum stone color
= stone_other(m
->color
);
46 int passes
= is_pass(m
->coord
);
48 /* Special check: We probably tenukied the last opponent's move. But
49 * check if the opponent has lucrative local continuation for her last
51 /* This check is ultra-important BTW. Without it domain checking does
52 * not bring that much of an advantage. It might even warrant it to by
53 * default do only this domain check. */
54 urgent
= policeman(policy
, b
, m
->color
);
58 while (gamelen
-- && passes
< 2) {
59 urgent
= policeman(policy
, &b2
, m
->color
);
63 if (!is_pass(urgent
)) {
66 m
.coord
= urgent
; m
.color
= color
;
67 if (board_play(&b2
, &m
) < 0) {
69 fprintf(stderr
, "Urgent move %d,%d is ILLEGAL:\n", coord_x(urgent
, b
), coord_y(urgent
, b
));
70 board_print(&b2
, stderr
);
77 board_play_random(&b2
, color
, &coord
);
80 if (unlikely(b2
.superko_violation
)) {
81 /* We ignore superko violations that are suicides. These
82 * are common only at the end of the game and are
83 * rather harmless. (They will not go through as a root
85 if (group_at(&b2
, coord
)) {
87 fprintf(stderr
, "Superko fun at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
89 board_print(&b2
, stderr
);
91 board_done_noalloc(&b2
);
95 fprintf(stderr
, "Ignoring superko at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
96 board_print(&b2
, stderr
);
98 b2
.superko_violation
= false;
103 char *cs
= coord2str(coord
, b
);
104 fprintf(stderr
, "%s %s\n", stone2str(color
), cs
);
108 if (unlikely(is_pass(coord
))) {
114 color
= stone_other(color
);
117 float score
= board_fast_score(&b2
);
118 bool result
= (m
->color
== S_WHITE
? (score
> 0) : (score
< 0));
121 fprintf(stderr
, "Random playout result: %d (W %f)\n", result
, score
);
123 board_print(&b2
, stderr
);
126 board_done_noalloc(&b2
);