14 play_random_game(struct board
*b
, enum stone starting_color
, int gamelen
,
15 struct playout_amafmap
*amafmap
,
16 struct playout_ownermap
*ownermap
,
17 struct playout_policy
*policy
)
19 gamelen
= gamelen
- b
->moves
;
23 enum stone color
= starting_color
;
26 int passes
= is_pass(b
->last_move
.coord
);
28 while (gamelen
-- && passes
< 2) {
29 urgent
= policy
->choose(policy
, b
, color
);
33 if (!is_pass(urgent
)) {
35 m
.coord
= urgent
; m
.color
= color
;
36 if (board_play(b
, &m
) < 0) {
38 fprintf(stderr
, "Urgent move %d,%d is ILLEGAL:\n", coord_x(urgent
, b
), coord_y(urgent
, b
));
39 board_print(b
, stderr
);
46 board_play_random(b
, color
, &coord
, (ppr_permit
) policy
->permit
, policy
);
50 /* For UCT, superko test here is downright harmful since
51 * in superko-likely situation we throw away literally
52 * 95% of our playouts; UCT will deal with this fine by
54 if (unlikely(b
->superko_violation
)) {
55 /* We ignore superko violations that are suicides. These
56 * are common only at the end of the game and are
57 * rather harmless. (They will not go through as a root
59 if (group_at(b
, coord
)) {
61 fprintf(stderr
, "Superko fun at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
63 board_print(b
, stderr
);
68 fprintf(stderr
, "Ignoring superko at %d,%d in\n", coord_x(coord
, b
), coord_y(coord
, b
));
69 board_print(b
, stderr
);
71 b
->superko_violation
= false;
77 fprintf(stderr
, "%s %s\n", stone2str(color
), coord2sstr(coord
, b
));
79 board_print(b
, stderr
);
82 if (unlikely(is_pass(coord
))) {
85 /* We don't care about nakade counters, since we want
86 * to avoid taking pre-nakade moves into account only
87 * if they happenned in the tree before nakade nodes;
88 * but this is always out of the tree. */
90 if (amafmap
->map
[coord
] == S_NONE
|| amafmap
->map
[coord
] == color
)
91 amafmap
->map
[coord
] = color
;
92 else if (amafmap
->record_nakade
)
93 amaf_op(amafmap
->map
[coord
], +);
94 amafmap
->game
[amafmap
->gamelen
].coord
= coord
;
95 amafmap
->game
[amafmap
->gamelen
].color
= color
;
97 assert(amafmap
->gamelen
< sizeof(amafmap
->game
) / sizeof(amafmap
->game
[0]));
103 color
= stone_other(color
);
106 float score
= board_fast_score(b
);
107 int result
= (starting_color
== S_WHITE
? score
* 2 : - (score
* 2));
110 fprintf(stderr
, "Random playout result: %d (W %f)\n", result
, score
);
112 board_print(b
, stderr
);
116 ownermap
->playouts
++;
118 ownermap
->map
[board_at(b
, c
)]++;