14 play_random_game(struct board
*b
, enum stone starting_color
, int gamelen
,
15 struct playout_amafmap
*amafmap
,
16 struct playout_policy
*policy
)
18 gamelen
= gamelen
- b
->moves
;
22 enum stone color
= starting_color
;
25 int passes
= is_pass(b
->last_move
.coord
);
27 while (gamelen
-- && passes
< 2) {
28 urgent
= policy
->choose(policy
, b
, color
);
32 if (!is_pass(urgent
)) {
34 m
.coord
= urgent
; m
.color
= color
;
35 if (board_play(b
, &m
) < 0) {
37 fprintf(stderr
, "Urgent move %d,%d is ILLEGAL:\n", coord_x(urgent
, b
), coord_y(urgent
, b
));
38 board_print(b
, stderr
);
45 board_play_random(b
, color
, &coord
, (ppr_permit
) policy
->permit
, policy
);
49 /* For UCT, superko test here is downright harmful since
50 * in superko-likely situation we throw away literally
51 * 95% of our playouts; UCT will deal with this fine by
53 if (unlikely(b
->superko_violation
)) {
54 /* We ignore superko violations that are suicides. These
55 * are common only at the end of the game and are
56 * rather harmless. (They will not go through as a root
58 if (group_at(b
, coord
)) {
60 fprintf(stderr
, "Superko fun at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
62 board_print(b
, stderr
);
67 fprintf(stderr
, "Ignoring superko at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
68 board_print(b
, stderr
);
70 b
->superko_violation
= false;
76 fprintf(stderr
, "%s %s\n", stone2str(color
), coord2sstr(coord
, b
));
78 board_print(b
, stderr
);
81 if (unlikely(is_pass(coord
))) {
84 /* We don't care about nakade counters, since we want
85 * to avoid taking pre-nakade moves into account only
86 * if they happenned in the tree before nakade nodes;
87 * but this is always out of the tree. */
89 if (amafmap
->map
[coord
] == S_NONE
|| amafmap
->map
[coord
] == color
)
90 amafmap
->map
[coord
] = color
;
91 else if (amafmap
->record_nakade
)
92 amaf_op(amafmap
->map
[coord
], +);
93 amafmap
->game
[amafmap
->gamelen
].coord
= coord
;
94 amafmap
->game
[amafmap
->gamelen
].color
= color
;
96 assert(amafmap
->gamelen
< sizeof(amafmap
->game
) / sizeof(amafmap
->game
[0]));
102 color
= stone_other(color
);
105 float score
= board_fast_score(b
);
106 bool result
= (starting_color
== S_WHITE
? (score
> 0) : (score
< 0));
109 fprintf(stderr
, "Random playout result: %d (W %f)\n", result
, score
);
111 board_print(b
, stderr
);