12 play_random_game(struct board
*b
, enum stone starting_color
, int gamelen
,
13 playout_policeman policeman
, void *policy
)
15 gamelen
= gamelen
- b
->moves
;
19 enum stone color
= starting_color
;
20 enum stone policy_color
= stone_other(starting_color
);
23 int passes
= is_pass(b
->last_move
.coord
);
25 while (gamelen
-- && passes
< 2) {
26 urgent
= policeman(policy
, b
, policy_color
);
30 if (!is_pass(urgent
)) {
32 m
.coord
= urgent
; m
.color
= color
;
33 if (board_play(b
, &m
) < 0) {
35 fprintf(stderr
, "Urgent move %d,%d is ILLEGAL:\n", coord_x(urgent
, b
), coord_y(urgent
, b
));
36 board_print(b
, stderr
);
43 board_play_random(b
, color
, &coord
);
47 /* For UCT, superko test here is downright harmful since
48 * in superko-likely situation we throw away literarily
49 * 95% of our playouts; UCT will deal with this fine by
51 if (unlikely(b
->superko_violation
)) {
52 /* We ignore superko violations that are suicides. These
53 * are common only at the end of the game and are
54 * rather harmless. (They will not go through as a root
56 if (group_at(b
, coord
)) {
58 fprintf(stderr
, "Superko fun at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
60 board_print(b
, stderr
);
65 fprintf(stderr
, "Ignoring superko at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
66 board_print(b
, stderr
);
68 b
->superko_violation
= false;
74 char *cs
= coord2str(coord
, b
);
75 fprintf(stderr
, "%s %s\n", stone2str(color
), cs
);
79 if (unlikely(is_pass(coord
))) {
85 color
= stone_other(color
);
88 float score
= board_fast_score(b
);
89 bool result
= (starting_color
== S_WHITE
? (score
> 0) : (score
< 0));
92 fprintf(stderr
, "Random playout result: %d (W %f)\n", result
, score
);
94 board_print(b
, stderr
);