12 #define coord_raw(c) (c)
13 #define coord_x(c, b) ((c) % board_size(b))
14 #define coord_y(c, b) ((c) / board_size(b))
15 #define coord_eq(c1, c2) ((c1) == (c2))
17 static coord_t pass
= -1;
18 static coord_t resign
= -2;
19 #define is_pass(c) (coord_eq(c, pass))
20 #define is_resign(c) (coord_eq(c, resign))
22 /* Initialize existing coord */
23 #define coord_pos(coord, pos_, board) do { (coord) = (pos_); } while (0)
24 #define coord_xy(board, x, y) ((x) + (y) * board_size(board))
25 #define coord_xy_otf(x, y, board) coord_xy(board, x, y) // obsolete
27 #define coord_is_adjecent(c1, c2, b) (abs(c1 - c2) == 1 || abs(c1 - c2) == board_size(b))
28 #define coord_is_8adjecent(c1, c2, b) (abs(c1 - c2) == 1 || abs(abs(c1 - c2) - board_size(b)) < 2)
31 static coord_t
*coord_init(int x
, int y
, int size
);
32 static coord_t
*coord_copy(coord_t c
);
33 static coord_t
*coord_pass(void);
34 static coord_t
*coord_resign(void);
35 static void coord_done(coord_t
*c
);
36 int coord_edge_distance(coord_t c
, struct board
*b
);
39 char *coord2str(coord_t c
, struct board
*b
);
40 char *coord2sstr(coord_t c
, struct board
*b
);
41 coord_t
*str2coord(char *str
, int board_size
);
51 static inline coord_t
*
52 coord_init(int x
, int y
, int size
)
54 coord_t
*c
= calloc(1, sizeof(coord_t
));
59 static inline coord_t
*
62 coord_t
*c2
= calloc(1, sizeof(coord_t
));
63 memcpy(c2
, &c
, sizeof(c
));
67 static inline coord_t
*
70 return coord_copy(pass
);
73 static inline coord_t
*
76 return coord_copy(resign
);
80 coord_done(coord_t
*c
)