Moggy: Fix CUT1 on the edge or in ponnuki shape
[pachi.git] / random / random.c
blobd98b7f64ab8d2d23f70013c4f38a755c92927416
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);
14 if (group_at(b, coord) == 0) {
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;