[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] reading patch
From: |
Gunnar Farneback |
Subject: |
[gnugo-devel] reading patch |
Date: |
Sat, 05 Jan 2002 22:42:17 +0100 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode) |
This reading patch solves trevor:1030, trevord:210, trevord:510,
and possibly some more test cases.
- new function special_rescue6() in reading.c
- defend3() revised
/Gunnar
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.42
diff -u -r1.42 reading.c
--- engine/reading.c 15 Dec 2001 14:35:26 -0000 1.42
+++ engine/reading.c 5 Jan 2002 13:37:51 -0000
@@ -89,6 +89,8 @@
int komaster, int kom_pos);
static void special_rescue5(int str, int libs[3], int moves[MAX_MOVES],
int scores[MAX_MOVES], int *num_moves);
+static void special_rescue6(int str, int libs[3], int moves[MAX_MOVES],
+ int scores[MAX_MOVES], int *num_moves);
static void edge_clamp(int str, int moves[MAX_MOVES],
int scores[MAX_MOVES], int *num_moves);
static int do_attack(int str, int *move, int komaster, int kom_pos);
@@ -1786,6 +1788,7 @@
if (stackp <= backfill_depth) {
int saved_num_moves = num_moves;
special_rescue5(str, libs, moves, scores, &num_moves);
+ special_rescue6(str, libs, moves, scores, &num_moves);
/* Only order and test the new set of moves. */
order_moves(str, num_moves-saved_num_moves,
@@ -2334,6 +2337,83 @@
/* Defend against double atari in the surrounding chain early. */
double_atari_chain2(bpos, moves, scores, num_moves);
+ }
+ }
+ }
+}
+
+
+/* In situations like this
+ *
+ * |.bOX
+ * |.Xa.
+ * |.OXX
+ * |.O..
+ * |.XX.
+ *
+ * the lower O string can often be defended at a or b.
+ *
+ * This function may be called for strings with 3 or 4 liberties and
+ * returns the * moves in the configuration below:
+ *
+ * |..O |.*O
+ * |.X. |.c*
+ * |.O? |ab?
+ *
+ */
+static void
+special_rescue6(int str, int libs[3], int moves[MAX_MOVES],
+ int scores[MAX_MOVES], int *num_moves)
+{
+ int color = board[str];
+ int other = OTHER_COLOR(color);
+ int apos, bpos, cpos;
+ int right, up;
+ int k, l, r;
+ int liberties = countlib(str);
+
+ ASSERT1(liberties == 3 || liberties == 4, str);
+
+ for (r = 0; r < liberties; r++) {
+ apos = libs[r];
+
+ for (k = 0; k < 4; k++) {
+ right = delta[k];
+
+ if (ON_BOARD(apos - right))
+ continue;
+
+ bpos = apos + right;
+ if (board[bpos] != color || !same_string(str, bpos))
+ continue;
+
+ for (l = 0; l < 2; l++) {
+ up = delta[(k+1) % 4];
+ if (l == 1)
+ up = -up;
+
+ cpos = bpos + up;
+ if (board[cpos] != other)
+ continue;
+
+ if (board[apos + up] != EMPTY)
+ continue;
+
+ if (board[cpos + right] != EMPTY)
+ continue;
+
+ if (board[apos + up + up] != EMPTY)
+ continue;
+
+ if (board[cpos + up] != EMPTY)
+ continue;
+
+ if (board[cpos + up + right] != color)
+ continue;
+
+
+ ADD_CANDIDATE_MOVE(cpos + right, 0, moves, scores, *num_moves);
+ ADD_CANDIDATE_MOVE(cpos + up, 0, moves, scores, *num_moves);
}
}
}
- [gnugo-devel] reading patch,
Gunnar Farneback <=