[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] tuning patch
From: |
Gunnar Farneback |
Subject: |
[gnugo-devel] tuning patch |
Date: |
Fri, 21 Dec 2001 21:01:11 +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 patch adds a small amount of tuning. It also adds a new function
dragon_looks_inessential() to dragon.c. This gives exactly the same
functionality as before but there's also a disabled modification
proposal inside the function. This was intended to solve 13x13:72,
which it did, but it also broke buzco:5. I still think the proposed
modification is in the right direction, but it needs to be improved.
Dan might want to take a look at this.
As a bonus the doc file incremental.texi has been 1D converted.
- 1D conversion of incremental.texi
- new function dragon_looks_inessential() in dragon.c
- tuning
- test revision
I'll be out of town most of the time from early tomorrow until January
the second. Merry Christmas and a Happy New Year, all of you.
/Gunnar
Index: doc/incremental.texi
===================================================================
RCS file: /cvsroot/gnugo/gnugo/doc/incremental.texi,v
retrieving revision 1.4
diff -u -r1.4 incremental.texi
--- doc/incremental.texi 28 Nov 2001 19:40:41 -0000 1.4
+++ doc/incremental.texi 21 Dec 2001 16:15:44 -0000
@@ -5,8 +5,7 @@
@item The color of the string.
@item Number of stones in the string.
@item Origin of the string, i.e. a canonical reference point, defined
-to be the stone with smallest @samp{i} coordinate and if there is a tie with
-smallest @samp{j} coordinate.
+to be the stone with smallest 1D board coordinate.
@item A list of the stones in the string.
@item Number of liberties.
@item A list of the liberties. If there are too many liberties the list is
@@ -19,16 +18,15 @@
@example
struct string_data @{
- int color; /* Color of string, BLACK or WHITE */
- int size; /* Number of stones in string. */
- int origini; /* Coordinates of "origin", i.e. */
- int originj; /* "upper left" stone. */
- int liberties; /* Number of liberties. */
- int libi[MAX_LIBERTIES]; /* Coordinates of liberties. */
- int libj[MAX_LIBERTIES];
- int neighbors; /* Number of neighbor strings */
- int neighborlist[MAXCHAIN]; /* List of neighbor string numbers. */
- int mark; /* General purpose mark. */
+ int color; /* Color of string, BLACK or WHITE */
+ int size; /* Number of stones in string. */
+ int origin; /* Coordinates of "origin", i.e. */
+ /* "upper left" stone. */
+ int liberties; /* Number of liberties. */
+ int libs[MAX_LIBERTIES]; /* Coordinates of liberties. */
+ int neighbors; /* Number of neighbor strings */
+ int neighborlist[MAXCHAIN]; /* List of neighbor string numbers. */
+ int mark; /* General purpose mark. */
@};
struct string_data string[MAX_STRINGS];
@@ -39,24 +37,22 @@
@code{string} array we have
@example
-int string_number[MAX_BOARD][MAX_BOARD];
+static int string_number[BOARDMAX];
@end example
@noindent
which contains indices into the @code{string} array. This information is only
valid at nonempty vertices, however, so it is necessary to first
-verify that @code{p[i][j] != EMPTY}.
+verify that @code{board[pos] != EMPTY}.
The @code{string_data} structure does not include an array of the stone
-coordinates. This information is stored in a separate array (or rather
-two):
+coordinates. This information is stored in a separate array:
@example
-int next_stonei[MAX_BOARD][MAX_BOARD];
-int next_stonej[MAX_BOARD][MAX_BOARD];
+static int next_stone[BOARDMAX];
@end example
-These arrays implement cyclic linked lists of stones. Each vertex
+This array implements cyclic linked lists of stones. Each vertex
contains a pointer to another (possibly the same) vertex. Starting at
an arbitrary stone on the board, following these pointers should
traverse the entire string in an arbitrary order before coming back to
@@ -68,7 +64,7 @@
Additionally the code makes use of some work variables:
@example
-static int ml[MAX_BOARD][MAX_BOARD];
+static int ml[BOARDMAX];
static int liberty_mark;
static int string_mark;
static int next_string;
@@ -77,8 +73,8 @@
The @code{ml} array and @code{liberty_mark} are used to "mark" liberties on
the board, e.g. to avoid counting the same liberty twice. The convention is
-that if @code{ml[i][j]} has the same value as @code{liberty_mark}, then
address@hidden(i, j)} is marked. To clear all marks it suffices to increase the
value
+that if @code{ml[pos]} has the same value as @code{liberty_mark}, then
address@hidden is marked. To clear all marks it suffices to increase the value
of @code{liberty_mark}, since it is never allowed to decrease.
The same relation holds between the @code{mark} field of the @code{string_data}
@@ -88,7 +84,7 @@
@code{next_string} gives the number of the next available entry in the
@code{string} array. Then @code{strings_initialized} is set to one when
all data structures are known to be up to date. Given an arbitrary board
-position in the @samp{p} array, this is done by calling
+position in the @samp{board} array, this is done by calling
@code{incremental_board_init()}. It is not necessary to call this
function explicitly since any other function that needs the information
does this if it has not been done.
@@ -175,17 +171,17 @@
The often used construction
@example
- FIRST_STONE(s, i, j);
+ pos = FIRST_STONE(s);
do @{
...
- NEXT_STONE(i, j);
- @} while (!BACK_TO_FIRST_STONE(s, i, j));
+ pos = NEXT_STONE(pos);
+ @} while (!BACK_TO_FIRST_STONE(s, pos));
@end example
@noindent
traverses the stones of the string with number @samp{s} exactly once,
-with @code{(i, j)} holding the coordinates. In general @code{(i, j)} are
-used as board coordinates and @samp{s} as an index into the
+with @code{pos} holding the coordinates. In general @code{pos} is
+used as board coordinate and @samp{s} as an index into the
@code{string} array or sometimes a pointer to an entry in the
@code{string} array.
Index: engine/dragon.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v
retrieving revision 1.41
diff -u -r1.41 dragon.c
--- engine/dragon.c 16 Dec 2001 21:22:35 -0000 1.41
+++ engine/dragon.c 21 Dec 2001 16:15:44 -0000
@@ -34,6 +34,7 @@
static void add_adjacent_dragons(int a, int b);
static void add_adjacent_dragon(int a, int b);
static int dragon_invincible(int pos);
+static int dragon_looks_inessential(int origin);
static int compute_dragon_status(int pos);
static void dragon_eye(int pos, struct eye_data[BOARDMAX]);
static int compute_escape(int pos, int dragon_status_known);
@@ -563,13 +564,7 @@
int origin = dragon2[d].origin;
true_genus = 2 * dragon2[d].genus + dragon2[d].heyes;
- /* FIXME: Probably need a better definition of INESSENTIAL dragons.
- * There are cases where a string is owl insubstantial
- * yet allowing it to be captured greatly weakens our
- * position.
- */
- if (dragon[origin].size == worm[origin].size
- && !owl_substantial(origin))
+ if (dragon_looks_inessential(origin))
dragon2[d].safety = INESSENTIAL;
else if (dragon[origin].size == worm[origin].size
&& worm[origin].attack_codes[0] != 0
@@ -971,6 +966,50 @@
return 0;
}
+
+/* A dragon looks inessential if it satisfies all of
+ * 1. Is a single string.
+ * 2. Is not owl substantial.
+ *
+ * FIXME: Probably need a better definition of INESSENTIAL dragons.
+ * There are cases where a string is owl insubstantial
+ * yet allowing it to be captured greatly weakens our
+ * position.
+ */
+static int
+dragon_looks_inessential(int origin)
+{
+#if 0
+ int d;
+ int k;
+#endif
+
+ if (dragon[origin].size != worm[origin].size)
+ return 0;
+
+ if (owl_substantial(origin))
+ return 0;
+
+#if 0
+ /* This is a proposed modification which solves 13x13:72 but
+ * breaks buzco:5. It adds the two requirements:
+ *
+ * 3. Has no opponent neighbor with status better than DEAD.
+ * 4. Has no opponent neighbor with escape value bigger than 0.
+ *
+ * This probably needs to be revised before it's enabled.
+ */
+ for (k = 0; k < DRAGON2(origin).neighbors; k++) {
+ d = DRAGON2(origin).adjacent[k];
+ if (DRAGON(d).color != board[origin]
+ && (DRAGON(d).matcher_status != DEAD
+ || dragon2[d].escape_route > 0))
+ return 0;
+ }
+#endif
+
+ return 1;
+}
/* print status info on all dragons. (Can be invoked from gdb)
Index: patterns/barriers.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/barriers.db,v
retrieving revision 1.12
diff -u -r1.12 barriers.db
--- patterns/barriers.db 17 Dec 2001 18:54:38 -0000 1.12
+++ patterns/barriers.db 21 Dec 2001 16:15:44 -0000
@@ -761,6 +761,23 @@
;!oplay_attack(a,b)
+Pattern Barrier56b
+
+XXOo
+XO.,
+.X.,
+----
+
+:8,Ds
+
+xXOo
+XOa,
+.X.,
+----
+
+;safe_omove(a)
+
+
Pattern Barrier57
X,
Index: patterns/komoku.sgf
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/komoku.sgf,v
retrieving revision 1.3
diff -u -r1.3 komoku.sgf
--- patterns/komoku.sgf 6 Sep 2001 21:34:20 -0000 1.3
+++ patterns/komoku.sgf 21 Dec 2001 16:15:44 -0000
@@ -7,7 +7,7 @@
GN[White (W) vs. Black (B)]
DT[1999-05-27]
SY[Cgoban 1.9.2]TM[5:00:00(5x1:00)];B[qd]
-(;W[od]PL[1]
+(;W[od]PL[B]
(;B[oc]MA[mg]
(;W[nc]MA[lg]C[U
];B[pc]MA[mf]C[U
@@ -78,17 +78,12 @@
)
)
-(;B[ld]MA[ki]C[S]
-;W[of]MA[ki]C[U]
-;B[qf]MA[ki]C[S]
-;W[oh]MA[ki]C[S]
-;B[qh]MA[ki]C[S]
-;W[id]MA[ii]C[S]
-)
+(;B[ld]MA[ki]C[S];W[of]MA[ki]C[U];B[qf]MA[ki]C[S];W[oh]MA[ki]C[S];
+B[qh]MA[ki]C[S];W[id]MA[ii]C[S])
)
(;W[oc]
-(;B[pe]MA[mi]PL[1]
+(;B[pe]MA[mi]PL[B]
(;W[md]C[
]MA[kg];B[pc]MA[jh]C[U
];W[od]MA[kh]C[:-,shape(5)
@@ -150,8 +145,9 @@
(;B[kc]MA[ig]C[:-,shape(8)
])
-(;B[mc]MA[lf];W[oe]MA[lg];B[pf]MA[lh];W[md]MA[kh];B[ld];W[me]MA[kh];
-B[nc];W[od]MA[kg])
+(;B[mc]MA[kf]LB[kc:A]C[;!xarea(A)
+];W[oe]MA[lg];B[pf]MA[lh];W[md]
+MA[kh];B[ld];W[me]MA[kh];B[nc];W[od]MA[kg])
)
)
Index: patterns/owl_attackpats.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/owl_attackpats.db,v
retrieving revision 1.40
diff -u -r1.40 owl_attackpats.db
--- patterns/owl_attackpats.db 15 Dec 2001 14:35:27 -0000 1.40
+++ patterns/owl_attackpats.db 21 Dec 2001 16:15:45 -0000
@@ -3492,6 +3492,7 @@
Pattern A1304
+# gf Revised constraint. (3.1.18)
|.XO throw in threatening to destroy two corner eye vertices
|.*X
@@ -3499,11 +3500,11 @@
:8,s,value(60)
-|.XO
+|bXO
|.*A
+---
-;lib(A)==2
+;lib(A)==2 && !obvious_false_xeye(b)
Pattern A1305
Index: patterns/patterns.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.db,v
retrieving revision 1.39
diff -u -r1.39 patterns.db
--- patterns/patterns.db 21 Dec 2001 16:04:05 -0000 1.39
+++ patterns/patterns.db 21 Dec 2001 16:15:45 -0000
@@ -2155,6 +2155,7 @@
Pattern EC60
# tm added constraint (3.1.18)
+# gf Changed B classification to C. (3.1.18)
?O.. protect cut
XO*X
@@ -2162,7 +2163,7 @@
....
----
-:8,BO
+:8,CO
?O..
XO*X
@@ -2175,6 +2176,7 @@
Pattern EC60a
# tm New Pattern (3.1.18)
+# gf Changed B classification to C. (3.1.18)
?O.. indirectly protect cut
XO.X
@@ -2182,7 +2184,7 @@
....
----
-:8,BO
+:8,CO
?b..
XOaX
Index: patterns/patterns2.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns2.db,v
retrieving revision 1.21
diff -u -r1.21 patterns2.db
--- patterns/patterns2.db 15 Dec 2001 14:35:27 -0000 1.21
+++ patterns/patterns2.db 21 Dec 2001 16:15:45 -0000
@@ -2358,7 +2358,7 @@
;(x_somewhere(D) || oplay_attack(*,?,D,D)) && !oplay_defend(*,a,b,c,*)
-Pattern Shape 76
+Pattern Shape76
# tm New Pattern. (3.1.16) (see trevor:220)
----
@@ -2376,6 +2376,28 @@
; xlib(A) > 2
; && oplay_attack(*,A,b,C,D)
; && oplay_attack(*,A,b,E,C,*)
+
+
+Pattern Shape77
+# gf New pattern. (3.1.18) (see trevor:382)
+
+oOO
+O..
+XO*
+---
+
+:8,-,shape(-3)
+
+
+Pattern Shape78
+# gf New pattern. (3.1.18) (see trevor:382)
+
+oOO
+O.*
+XO.
+---
+
+:8,-,shape(1)
###########################
Index: regression/13x13.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/13x13.tst,v
retrieving revision 1.4
diff -u -r1.4 13x13.tst
--- regression/13x13.tst 18 Dec 2001 19:31:00 -0000 1.4
+++ regression/13x13.tst 21 Dec 2001 16:15:45 -0000
@@ -263,7 +263,9 @@
#? [L7]*
# Here N11 is generated as an "additional attack/defense move", although
-# the black dragon is still dead after black connects at N11
+# the black dragon is still dead after black connects at N11.
+#
+# The correct answer lists M10 which is occupied. Needs revision. /gf
loadsgf games/mertin13x13/gnugo-goliath2.W+38.sgf 27
50 gg_genmove black
#? [!N11|M10]