1 #ifndef ZZGO_TACTICS_LADDER_H
2 #define ZZGO_TACTICS_LADDER_H
9 /* Check if escaping on this liberty by given group in atari would play out
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
);
19 is_ladder(struct board
*b
, coord_t coord
, group_t laddered
)
21 enum stone lcolor
= board_at(b
, group_base(laddered
));
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
);
36 bool l
= is_middle_ladder(b
, coord
, lcolor
);
37 if (DEBUGL(6)) fprintf(stderr
, "middle ladder solution: %d\n", l
);