Previous: The Owl Code, Up: Pattern Based Reading
It may happen that no single one of a set of worms can be killed, yet there is a move that guarantees that at least one can be captured. The simplest example is a double atari. The purpose of the code in combination.c is to find such moves.
For example, consider the following situation:
+--------- |....OOOOX |....OOXXX |..O.OXX.. |.OXO.OX.. |.OX..OO.. |.XXOOOXO. |..*XXOX.. |....XOX.. |.XX..X... |X........
Every `X' stone in this position is alive. However the move at `*' produces a position in which at least one of four strings will get captured. This is a combination.
The driving function is called atari_atari
because typically
a combination involves a sequence of ataris culminating in a capture,
though sometimes the moves involved are not ataris. For example in
the above example, the first move at `*' is not an
atari, though after `O' defends the four stones above, a
sequence of ataris ensues resulting in the capture of some
string.
Like the owl functions atari_atari
does pattern-based
reading. The database generating the attacking moves is
aa_attackpats.db. One danger with this function is
that the first atari tried might be irrelevant to the actual
combination. To detect this possibility, once we've found a
combination, we mark that first move as forbidden, then try
again. If no combination of the same size or larger turns
up, then the first move was indeed essential.
void combinations(int color)
Generate move reasons for combination attacks and defenses against them. This is one of the move generators called from genmove().
int atari_atari(int color, int *attack_move, char defense_moves[BOARDMAX], int save_verbose)
Look for a combination for color
. For the purpose of
the move generation, returns the size of the smallest of the
worms under attack.
int atari_atari_confirm_safety(int color, int move, int *defense, int minsize, const char saved_dragons[BOARDMAX], const char saved_worms[BOARDMAX])
Tries to determine whether a move is a blunder. Wrapper around atari_atari_blunder_size. Check whether a combination attack of size at leastminsize
appears after move atmove
has been made. The arrayssaved_dragons[]
andsaved_worms[]
should be one for stones belonging to dragons or worms respectively, which are supposedly saved bymove
.
int atari_atari_blunder_size(int color, int move, int *defense, const char safe_stones[BOARDMAX])
This function checks whether any new combination attack appears after
move at (move) has been made, and returns its size (in points).
safe_stones
marks which of our stones are supposedly safe
after this move.