pat_90rot(): Fix atari info rotation
[pachi/t.git] / tactics / ladder.h
blobd97a628bf89d36600dbeaba17adf1f85b098f56e
1 #ifndef ZZGO_TACTICS_LADDER_H
2 #define ZZGO_TACTICS_LADDER_H
4 /* Reading ladders. */
6 #include "board.h"
7 #include "debug.h"
9 /* Check if escaping on this liberty by given group in atari would play out
10 * a simple ladder. */
11 /* Two ways of ladder reading can be enabled separately; simple first-line
12 * ladders and trivial middle-board ladders. */
13 static bool is_ladder(struct board *b, coord_t coord, group_t laddered);
16 bool is_border_ladder(struct board *b, coord_t coord, enum stone lcolor);
17 bool is_middle_ladder(struct board *b, coord_t coord, enum stone lcolor);
18 static inline bool
19 is_ladder(struct board *b, coord_t coord, group_t laddered)
21 enum stone lcolor = board_at(b, group_base(laddered));
23 if (DEBUGL(6))
24 fprintf(stderr, "ladder check - does %s play out %s's laddered group %s?\n",
25 coord2sstr(coord, b), stone2str(lcolor), coord2sstr(laddered, b));
27 /* First, special-case first-line "ladders". This is a huge chunk
28 * of ladders we actually meet and want to play. */
29 if (neighbor_count_at(b, coord, S_OFFBOARD) == 1
30 && neighbor_count_at(b, coord, lcolor) == 1) {
31 bool l = is_border_ladder(b, coord, lcolor);
32 if (DEBUGL(6)) fprintf(stderr, "border ladder solution: %d\n", l);
33 return l;
36 bool l = is_middle_ladder(b, coord, lcolor);
37 if (DEBUGL(6)) fprintf(stderr, "middle ladder solution: %d\n", l);
38 return l;
41 #endif