Montecarlo: Do domain checks for last opponent's move too
[pachi.git] / move.c
blob45963ef3eafbca2b92f394876f765b885b85559a
1 #include <ctype.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #include "move.h"
9 /* The S_OFFBOARD margin is not addressable by coordinates. */
11 static char asdf[] = "abcdefghjklmnopqrstuvwxyz";
13 char *
14 coord2str(coord_t c)
16 char b[4];
17 if (is_pass(c)) {
18 return strdup("pass");
19 } else if (is_resign(c)) {
20 return strdup("resign");
21 } else {
22 /* Some GTP servers are broken and won't grok lowercase coords */
23 snprintf(b, 4, "%c%d", toupper(asdf[coord_x(c) - 1]), coord_y(c));
24 return strdup(b);
28 /* No sanity checking */
29 coord_t *
30 str2coord(char *str, int size)
32 if (!strcasecmp(str, "pass")) {
33 return coord_pass();
34 } else if (!strcasecmp(str, "resign")) {
35 return coord_resign();
36 } else {
37 char xc = tolower(str[0]);
38 return coord_init(xc - 'a' - (xc > 'i') + 1, atoi(str + 1), size);