10 /* The S_OFFBOARD margin is not addressable by coordinates. */
12 static char asdf
[] = "abcdefghjklmnopqrstuvwxyz";
15 coord2bstr(char *buf
, coord_t c
, struct board
*board
)
19 } else if (is_resign(c
)) {
22 /* Some GTP servers are broken and won't grok lowercase coords */
23 snprintf(buf
, 4, "%c%d", toupper(asdf
[coord_x(c
, board
) - 1]), coord_y(c
, board
));
28 /* Return coordinate in dynamically allocated buffer. */
30 coord2str(coord_t c
, struct board
*board
)
33 return strdup(coord2bstr(buf
, c
, board
));
36 /* Return coordinate in statically allocated buffer, with some backlog for
37 * multiple independent invocations. Useful for debugging. */
39 coord2sstr(coord_t c
, struct board
*board
)
42 static char bl
[10][4];
44 b
= bl
[bi
]; bi
= (bi
+ 1) % 10;
45 return coord2bstr(b
, c
, board
);
48 /* No sanity checking */
50 str2coord(char *str
, int size
)
52 if (!strcasecmp(str
, "pass")) {
54 } else if (!strcasecmp(str
, "resign")) {
55 return coord_resign();
57 char xc
= tolower(str
[0]);
58 return coord_init(xc
- 'a' - (xc
> 'i') + 1, atoi(str
+ 1), size
);