is_selfatari(): Allow multiple captures contribute liberties
[pachi.git] / random / random.c
blob1637f6e9a6e03958bb7ce24dba5bfa71e8267d95
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "board.h"
5 #include "engine.h"
6 #include "move.h"
7 #include "random/random.h"
9 static coord_t *
10 random_genmove(struct engine *e, struct board *b, enum stone color)
12 coord_t coord;
13 board_play_random(b, color, &coord, NULL, NULL);
14 if (!group_at(b, coord)) {
15 /* This was suicide. Just pass. */
16 /* XXX: We should check for non-suicide alternatives. */
17 return coord_pass();
20 return coord_copy(coord);
23 struct engine *
24 engine_random_init(char *arg)
26 struct engine *e = calloc(1, sizeof(struct engine));
27 e->name = "RandomMove Engine";
28 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.";
29 e->genmove = random_genmove;
31 if (arg)
32 fprintf(stderr, "Random: I support no engine arguments\n");
34 return e;