Patternscan: Change output format, clearly identify winner and witnesses
[pachi/nmclean.git] / tactics / selfatari.h
blobca74d15c5f7ae66f7ec23dc5b1e286416e541dd6
1 #ifndef PACHI_TACTICS_SELFATARI_H
2 #define PACHI_TACTICS_SELFATARI_H
4 /* A fairly reliable elf-atari detector. */
6 #include "board.h"
7 #include "debug.h"
9 /* Check if this move is undesirable self-atari (resulting group would have
10 * only single liberty and not capture anything; ko is allowed); we mostly
11 * want to avoid these moves. The function actually does a rather elaborate
12 * tactical check, allowing self-atari moves that are nakade, eye falsification
13 * or throw-ins. */
14 static bool is_bad_selfatari(struct board *b, enum stone color, coord_t to);
16 /* Move (color, coord) is a selfatari; this means that it puts a group of
17 * ours in atari; i.e., the group has two liberties now. Return the other
18 * liberty of such a troublesome group (optionally stored at *bygroup)
19 * if that one is not a self-atari.
20 * (In case (color, coord) is a multi-selfatari, consider a randomly chosen
21 * candidate.) */
22 coord_t selfatari_cousin(struct board *b, enum stone color, coord_t coord, group_t *bygroup);
25 bool is_bad_selfatari_slow(struct board *b, enum stone color, coord_t to);
26 static inline bool
27 is_bad_selfatari(struct board *b, enum stone color, coord_t to)
29 /* Ko threats fear no self atari! */
30 if (board_playing_ko_threat(b))
31 return false;
32 /* More than one immediate liberty, thumbs up! */
33 if (immediate_liberty_count(b, to) > 1)
34 return false;
36 return is_bad_selfatari_slow(b, color, to);
39 #endif