[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] atari_atari patch
From: |
Evan Berggren Daniel |
Subject: |
[gnugo-devel] atari_atari patch |
Date: |
Sat, 29 Mar 2003 01:55:33 -0500 (EST) |
The following patch solves atari_atari:20.
The problem in the position is that white has an atari on an enclosing
string available as a delaying move. After white plays the atari, black
needs to connect in order to continue the attack, but the current code
does not find the move.
To fix this I added code to look for intermediate defensive moves for
tactically critical neighbor strings before continuing the attack.
I have not run complete regressions; however, the speed penalty on
atari_atari.tst is relatively high, at around 12%.
Does the patch look ok in its current form, or should I work more on it?
Thanks
Evan Daniel
Index: engine/combination.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/combination.c,v
retrieving revision 1.45
diff -u -d -r1.45 combination.c
--- engine/combination.c 15 Mar 2003 21:36:23 -0000 1.45
+++ engine/combination.c 29 Mar 2003 06:42:53 -0000
@@ -224,6 +224,9 @@
static void atari_atari_find_attack_moves(int color, int minsize,
struct aa_move attacks[AA_MAX_MOVES],
char goal[BOARDMAX]);
+static void atari_atari_intermediate_moves(int color,
+ struct aa_move attacks[AA_MAX_MOVES],
+ char goal[BOARDMAX]);
static void atari_atari_attack_patterns(int color, int minsize,
struct aa_move attacks[AA_MAX_MOVES],
char goal[BOARDMAX]);
@@ -865,6 +868,7 @@
aa_init_moves(attacks);
atari_atari_attack_patterns(color, minsize, attacks, goal);
+ atari_atari_intermediate_moves(color, attacks, goal);
/* Sort the attack moves. */
aa_sort_moves(attacks);
@@ -1023,6 +1027,46 @@
}
}
+
+/* Sometimes in defending against an atari_atari combination,
+ * the defense function finds attacks on enclosing strings.
+ * atari_atari_intermediate_moves() attempts to find intermediate
+ * moves to defend such groups.
+ */
+static void
+atari_atari_intermediate_moves(int color, struct aa_move attacks[AA_MAX_MOVES],
+ char goal[BOARDMAX])
+{
+ int j, k;
+ int adj, adjs[MAXCHAIN];
+ int apos, dpos;
+ int acode, dcode;
+ int other = OTHER_COLOR(color);
+
+ for (k = BOARDMIN; k < BOARDMAX; k++) {
+ if (!ON_BOARD1(k))
+ continue;
+ if (board[k] != other)
+ continue;
+ if (goal)
+ if (!goal[k])
+ continue;
+ if (k != find_origin(k))
+ continue;
+ if (countlib(k) > 4)
+ continue;
+
+ adj = chainlinks(k, adjs);
+ gg_assert(board[k] == other);
+
+ for (j = 0; j < adj; j++) {
+ gg_assert(board[adjs[j]] == color);
+ if (attack_and_defend(adjs[j], &acode, &apos, &dcode, &dpos)) {
+ aa_add_move(attacks, dpos, k);
+ }
+ }
+ }
+}
static int
atari_atari_find_defense_moves(int targets[AA_MAX_TARGETS_PER_MOVE],
- [gnugo-devel] atari_atari patch,
Evan Berggren Daniel <=