[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] optics patch
From: |
Paul Pogonyshev |
Subject: |
[gnugo-devel] optics patch |
Date: |
Thu, 2 Jan 2003 00:24:09 +0200 |
this patch fixes ninestones:290 (one of the tests i've submitted
recently). it has no other impact on regressions.
- evaluate_diagonal_intersection() tries additional moves to
defend a diagonal
- does_secure() made global and moved to reading.c
Paul
Index: optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.62
diff -u -p -r1.62 optics.c
--- optics.c 30 Dec 2002 20:11:09 -0000 1.62
+++ optics.c 1 Jan 2003 20:28:57 -0000
@@ -1681,6 +1681,11 @@ evaluate_diagonal_intersection(int m, in
return 0.0;
if (board[pos] == EMPTY) {
+ int your_safety = safe_move(pos, other);
+
+ apos = pos;
+ dpos = pos;
+
/* We should normally have a safe move, but occasionally it may
* happen that it's not safe. There are complications, however,
* with a position like this:
@@ -1694,9 +1699,6 @@ evaluate_diagonal_intersection(int m, in
* Therefore we ignore our own safety if opponent's safety depends
* on ko.
*/
-
- int your_safety = safe_move(pos, other);
-
if (your_safety == 0)
value = 0.0;
else if (your_safety != WIN)
@@ -1704,16 +1706,43 @@ evaluate_diagonal_intersection(int m, in
else { /* So your_safety == WIN. */
int our_safety = safe_move(pos, color);
- if (our_safety == 0)
- value = 2.0;
+ if (our_safety == 0) {
+ int k;
+
+ value = 2.0;
+
+ /* This check is intended to fix a certain special case, but might
+ * be helpful in other situations as well. Consider this position,
+ * happened in owl reading deep enough:
+ *
+ * |XXXXX
+ * |XOOXX
+ * |O.OOX
+ * |.OXX.
+ * +-----
+ *
+ * Without this check, the corner eye is considered false, not half-
+ * eye. Thus, owl thinks that the capture gains at most one eye and
+ * gives up.
+ */
+ for (k = 4; k < 8; k++) {
+ int diagonal = pos + delta[k];
+ int lib;
+
+ if (board[diagonal] == other && findlib(diagonal, 1, &lib) == 1) {
+ if (does_secure(color, lib, pos)) {
+ value = 1.0;
+ apos = lib;
+ break;
+ }
+ }
+ }
+ }
else if (our_safety == WIN)
value = 1.0;
else /* our_safety depends on ko. */
value = b;
}
-
- apos = pos;
- dpos = pos;
}
else if (board[pos] == color) {
/* This stone had better be safe, otherwise we wouldn't have an
Index: reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.94
diff -u -p -r1.94 reading.c
--- reading.c 22 Dec 2002 20:17:43 -0000 1.94
+++ reading.c 1 Jan 2003 20:33:53 -0000
@@ -5483,6 +5483,22 @@ safe_move(int move, int color)
}
+/* Checks if a move by color makes an opponent move at pos a self atari.
+ */
+int
+does_secure(int color, int move, int pos)
+{
+ int result = 0;
+ if (trymove(move, color, NULL, NO_MOVE, EMPTY, NO_MOVE)) {
+ if (is_self_atari(pos, OTHER_COLOR(color)))
+ result = 1;
+ popgo();
+ }
+
+ return result;
+}
+
+
/* ===================== Statistics ============================= */
Index: readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.40
diff -u -p -r1.40 readconnect.c
--- readconnect.c 14 Nov 2002 07:40:53 -0000 1.40
+++ readconnect.c 1 Jan 2003 20:47:19 -0000
@@ -1782,7 +1782,6 @@ static void compute_connection_distances
struct connection_data *conn);
static void print_connection_distances(struct connection_data *conn);
static int trivial_connection(int str1, int str2, int *move);
-static int does_secure(int color, int move, int pos);
static int does_secure_through_ladder(int color, int move, int pos);
static int ladder_capture(int str, int *move);
static int ladder_capturable(int pos, int color);
@@ -3073,22 +3072,6 @@ trivial_connection(int str1, int str2, i
/* Turn the sgf traces back on. */
sgf_dumptree = save_sgf_dumptree;
count_variations = save_count_variations;
-
- return result;
-}
-
-
-/* True if a move by color makes an opponent move at pos a self atari.
- */
-static int
-does_secure(int color, int move, int pos)
-{
- int result = 0;
- if (trymove(move, color, NULL, NO_MOVE, EMPTY, NO_MOVE)) {
- if (is_self_atari(pos, OTHER_COLOR(color)))
- result = 1;
- popgo();
- }
return result;
}
Index: liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.145
diff -u -p -r1.145 liberty.h
--- liberty.h 25 Dec 2002 20:26:44 -0000 1.145
+++ liberty.h 1 Jan 2003 22:09:44 -0000
@@ -173,7 +173,7 @@ int is_edge_vertex(int pos);
/* Count and/or find liberties at (pos). */
int countlib(int str);
int findlib(int str, int maxlib, int *libs);
-int fastlib(int pos, int color, int ignore_capture);
+int fastlib(int pos, int color, int ignore_captures);
int approxlib(int pos, int color, int maxlib, int *libs);
int accuratelib(int pos, int color, int maxlib, int *libs);
int count_common_libs(int str1, int str2);
@@ -374,6 +374,7 @@ void set_temporary_depth_values(int d, i
void restore_depth_values(void);
int safe_move(int move, int color);
+int does_secure(int color, int move, int pos);
void join_dragons(int d1, int d2);
int dragon_escape(char goal[BOARDMAX], int color, char escape_value[BOARDMAX]);
- [gnugo-devel] optics patch,
Paul Pogonyshev <=