7 #include "random/random.h"
10 random_genmove(struct engine
*e
, struct board
*b
, struct time_info
*ti
, enum stone color
, bool pass_all_alive
)
12 /* Play a random coordinate. However, we must also guard
13 * against suicide moves; repeat playing while it's a suicide
14 * unless we keep suiciding; in that case, we probably don't
15 * have any other moves available and we pass. */
17 int i
= 0; bool suicide
= false;
20 /* board_play_random() actually plays the move too;
21 * this is desirable for MC simulations but not within
22 * the genmove. Make a scratch new board for it. */
26 board_play_random(&b2
, color
, &coord
, NULL
, NULL
);
28 suicide
= (coord
!= pass
&& !group_at(&b2
, coord
));
29 board_done_noalloc(&b2
);
30 } while (suicide
&& i
++ < 100);
32 return coord_copy(suicide
? pass
: coord
);
36 engine_random_init(char *arg
, struct board
*b
)
38 struct engine
*e
= calloc2(1, sizeof(struct engine
));
39 e
->name
= "RandomMove Engine";
40 e
->comment
= "I just make random moves. I won't pass as long as there is a place on the board where I can play. When we both pass, I will consider all the stones on the board alive.";
41 e
->genmove
= random_genmove
;
44 fprintf(stderr
, "Random: I support no engine arguments\n");