Add final_score to known_commands
[pachi/pachi-r6144.git] / tactics / ladder.h
blob870b383cd336c23a7e5b32301da2576863a4f37c
1 #ifndef PACHI_TACTICS_LADDER_H
2 #define PACHI_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);
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);
22 static inline bool
23 is_ladder(struct board *b, coord_t coord, group_t laddered)
25 enum stone lcolor = board_at(b, group_base(laddered));
27 if (DEBUGL(6))
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);
37 return l;
40 bool l = is_middle_ladder(b, coord, lcolor);
41 if (DEBUGL(6)) fprintf(stderr, "middle ladder solution: %d\n", l);
42 return l;
45 #endif