1 #ifndef PACHI_TACTICS_LADDER_H
2 #define PACHI_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
);
15 /* Check if a 2-lib group of color @lcolor escaping at @escapelib would be
16 * caught in a ladder given opponent stone at @chaselib. */
17 bool wouldbe_ladder(struct board
*b
, coord_t escapelib
, coord_t chaselib
, enum stone lcolor
);
20 bool is_border_ladder(struct board
*b
, coord_t coord
, enum stone lcolor
);
21 bool is_middle_ladder(struct board
*b
, coord_t coord
, enum stone lcolor
);
23 is_ladder(struct board
*b
, coord_t coord
, group_t laddered
)
25 enum stone lcolor
= board_at(b
, group_base(laddered
));
28 fprintf(stderr
, "ladder check - does %s play out %s's laddered group %s?\n",
29 coord2sstr(coord
, b
), stone2str(lcolor
), coord2sstr(laddered
, b
));
31 /* First, special-case first-line "ladders". This is a huge chunk
32 * of ladders we actually meet and want to play. */
33 if (neighbor_count_at(b
, coord
, S_OFFBOARD
) == 1
34 && neighbor_count_at(b
, coord
, lcolor
) == 1) {
35 bool l
= is_border_ladder(b
, coord
, lcolor
);
36 if (DEBUGL(6)) fprintf(stderr
, "border ladder solution: %d\n", l
);
40 bool l
= is_middle_ladder(b
, coord
, lcolor
);
41 if (DEBUGL(6)) fprintf(stderr
, "middle ladder solution: %d\n", l
);