[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] optics patch
From: |
Gunnar Farneback |
Subject: |
[gnugo-devel] optics patch |
Date: |
Thu, 13 Dec 2001 20:23:25 +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 prepares for a removal of linear_eyes().
- eye tuning, adding many patterns with occupied margins
- common debug code moved from compute_eyes() and
compute_eyes_pessimistic() to print_eyes()
- inactive support to test the impact of linear_eyes() in
compute_eyes_pessimistic()
- new and revised test cases
- MAXPATNO increased to 400 in mkeyes.c
/Gunnar
Index: engine/optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.31
diff -u -r1.31 optics.c
--- engine/optics.c 11 Dec 2001 15:30:08 -0000 1.31
+++ engine/optics.c 13 Dec 2001 19:13:10 -0000
@@ -602,6 +602,40 @@
int mini, maxi;
int minj, maxj;
int origin = eye[pos].origin;
+
+ gprintf("Eyespace at %1m: color=%C, esize=%d, msize=%d\n",
+ pos, eye[pos].color, eye[pos].esize, eye[pos].msize);
+
+ for (m = 0; m < board_size; m++)
+ for (n = 0; n < board_size; n++) {
+ int pos2 = POS(m, n);
+ if (eye[pos2].origin != pos)
+ continue;
+
+ if (eye[pos2].marginal && IS_STONE(board[pos2]))
+ gprintf("%1m (X!)\n", pos2);
+ else if (is_halfeye(heye, pos2) && IS_STONE(board[pos2])) {
+ if (heye[pos2].value == 3.0)
+ gprintf("%1m (XH)\n", pos2);
+ else
+ gprintf("%1m (XH) (topological eye value = %f\n", pos2,
+ heye[pos2].value);
+ }
+ else if (!eye[pos2].marginal && IS_STONE(board[pos2]))
+ gprintf("%1m (X)\n", pos2);
+ else if (eye[pos2].marginal && board[pos2] == EMPTY)
+ gprintf("%1m (!)\n", pos2);
+ else if (is_halfeye(heye, pos2) && board[pos2] == EMPTY) {
+ if (heye[pos2].value == 3.0)
+ gprintf("%1m (H)\n", pos2);
+ else
+ gprintf("%1m (H) (topological eye value = %f\n", pos2,
+ heye[pos2].value);
+ }
+ else
+ gprintf("%1m\n", pos2);
+ }
+ gprintf("\n");
/* Determine the size of the eye. */
mini = board_size;
@@ -669,48 +703,12 @@
struct half_eye_data heye[BOARDMAX],
int add_moves, int color)
{
- int m, n;
-
if (attack_point)
*attack_point = NO_MOVE;
if (defense_point)
*defense_point = NO_MOVE;
if (debug & DEBUG_EYES) {
- DEBUG(DEBUG_EYES, "Eyespace at %1m: color=%C, esize=%d, msize=%d\n",
- pos, eye[pos].color, eye[pos].esize,
- eye[pos].msize);
-
- for (m = 0; m < board_size; m++)
- for (n = 0; n < board_size; n++) {
- int pos2 = POS(m, n);
- if (eye[pos2].origin != pos)
- continue;
-
- if (eye[pos2].marginal && IS_STONE(board[pos2]))
- DEBUG(DEBUG_EYES, "%1m (X!)\n", pos2);
- else if (is_halfeye(heye, pos2) && IS_STONE(board[pos2])) {
- if (heye[pos2].value == 3.0)
- DEBUG(DEBUG_EYES, "%1m (XH)\n", pos2);
- else
- DEBUG(DEBUG_EYES, "%1m (XH) (topological eye value = %f\n", pos2,
- heye[pos2].value);
- }
- else if (!eye[pos2].marginal && IS_STONE(board[pos2]))
- DEBUG(DEBUG_EYES, "%1m (X)\n", pos2);
- else if (eye[pos2].marginal && board[pos2] == EMPTY)
- DEBUG(DEBUG_EYES, "%1m (!)\n", pos2);
- else if (is_halfeye(heye, pos2) && board[pos2] == EMPTY) {
- if (heye[pos2].value == 3.0)
- DEBUG(DEBUG_EYES, "%1m (H)\n", pos2);
- else
- DEBUG(DEBUG_EYES, "%1m (H) (topological eye value = %f\n", pos2,
- heye[pos2].value);
- }
- else
- DEBUG(DEBUG_EYES, "%1m\n", pos2);
- }
- DEBUG(DEBUG_EYES, "\n");
print_eye(eye, heye, pos);
DEBUG(DEBUG_EYES, "\n");
}
@@ -771,7 +769,7 @@
print_eye(eye, heye, pos);
}
}
-
+
/* If not found we examine whether we have a linear eye space. */
if (linear_eye_space(pos, attack_point, max, min, eye)) {
*defense_point = *attack_point; /* Duplicate attack point to defense
point. */
@@ -853,39 +851,6 @@
*defense_point = NO_MOVE;
if (debug & DEBUG_EYES) {
- DEBUG(DEBUG_EYES, "Eyespace at %1m: color=%C, esize=%d, msize=%d\n",
- pos, eye[pos].color, eye[pos].esize, eye[pos].msize);
-
- for (m = 0; m < board_size; m++)
- for (n = 0; n < board_size; n++) {
- int pos2 = POS(m, n);
- if (eye[pos2].origin != pos)
- continue;
-
- if (eye[pos2].marginal && IS_STONE(board[pos2]))
- DEBUG(DEBUG_EYES, "%1m (X!)\n", pos2);
- else if (is_halfeye(heye, pos2) && IS_STONE(board[pos2])) {
- if (heye[pos2].value == 3.0)
- DEBUG(DEBUG_EYES, "%1m (XH)\n", pos2);
- else
- DEBUG(DEBUG_EYES, "%1m (XH) (topological eye value = %f\n", pos2,
- heye[pos2].value);
- }
- else if (!eye[pos2].marginal && IS_STONE(board[pos2]))
- DEBUG(DEBUG_EYES, "%1m (X)\n", pos2);
- else if (eye[pos2].marginal && board[pos2] == EMPTY)
- DEBUG(DEBUG_EYES, "%1m (!)\n", pos2);
- else if (is_halfeye(heye, pos2) && board[pos2] == EMPTY) {
- if (heye[pos2].value == 3.0)
- DEBUG(DEBUG_EYES, "%1m (H)\n", pos2);
- else
- DEBUG(DEBUG_EYES, "%1m (H) (topological eye value = %f\n", pos2,
- heye[pos2].value);
- }
- else
- DEBUG(DEBUG_EYES, "%1m\n", pos2);
- }
- DEBUG(DEBUG_EYES, "\n");
print_eye(eye, heye, pos);
DEBUG(DEBUG_EYES, "\n");
}
@@ -926,9 +891,32 @@
*pessimistic_min = *min - margins;
if (*pessimistic_min == 2)
*pessimistic_min = 1;
+ if (*pessimistic_min < 0)
+ *pessimistic_min = 0;
DEBUG(DEBUG_EYES, " linear_eye - max=%d, min=%d, pessimistic_min=%d\n",
*max, *min, *pessimistic_min);
+
+ /* Change this to 1 to get notification when linear_eye() would
+ * give a different result than guess_eye_space(), for eyespaces
+ * without a matching graph.
+ */
+ if (0) {
+ int max2, min2, pessimistic_min2;
+ guess_eye_space(pos, effective_eyesize, margins, eye, &max2, &min2,
+ &pessimistic_min2);
+ if (*max != *min
+ || *max != max2
+ || *min != min2) {
+ gprintf(" linear_eye - max=%d, min=%d, pessimistic_min=%d\n",
+ *max, *min, *pessimistic_min);
+ gprintf(" guess_eye - max=%d, min=%d, pessimistic_min=%d\n",
+ max2, min2, pessimistic_min2);
+ print_eye(eye, heye, pos);
+ gprintf("Linear eye space failure.\n");
+ showboard(0);
+ }
+ }
}
/* Ideally any eye space that hasn't been matched yet should be two
Index: patterns/eyes.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/eyes.db,v
retrieving revision 1.14
diff -u -r1.14 eyes.db
--- patterns/eyes.db 26 Nov 2001 14:54:28 -0000 1.14
+++ patterns/eyes.db 13 Dec 2001 19:13:10 -0000
@@ -164,6 +164,27 @@
:2,0
+Pattern 307
+
+$*.
+
+:1,0
+
+
+Pattern 308
+
+$.X
+
+:1,1
+
+
+Pattern 309
+
+$X.
+
+:0,0
+
+
Pattern 391
!x!
@@ -260,38 +281,74 @@
Pattern 415
-!X.x
address@hidden
-:1,1
+:2,1
Pattern 416
+!X..
+
+:1,1
+
+
+Pattern 417
+
@XXx
:1,0
-Pattern 417
+Pattern 418
(.x@
:1,0
-Pattern 418
+Pattern 419
address@hidden
:1,0
-Pattern 419
+Pattern 420
!XX!
:0,0
+
+Pattern 421
+
+!.x$
+
+:0,0
+
+
+Pattern 422
+
address@hidden
+
+:1,0
+
+
+Pattern 423
+
+.XX$
+
+:1,1
+
+
+Pattern 424
+
+$xx$
+
+:0,0
+
+
#
# Do we ever get more than 2 marginal eye points with a linear 4 pattern?
#
@@ -300,8 +357,8 @@
# Topology: ...
#
-Pattern 420
-# Match before 421
+Pattern 430
+# Match before 431
X
X.X
@@ -309,7 +366,7 @@
:2,2
-Pattern 421
+Pattern 431
x
x*x
@@ -317,7 +374,7 @@
:2,1
-Pattern 422
+Pattern 432
x
xXx
@@ -325,7 +382,7 @@
:1,1
-Pattern 423
+Pattern 433
!
x*x
@@ -333,7 +390,7 @@
:2,1
-Pattern 424
+Pattern 434
x
address@hidden
@@ -341,7 +398,7 @@
:2,0
-Pattern 425
+Pattern 435
!
!*x
@@ -349,7 +406,7 @@
:1,0
-Pattern 426
+Pattern 436
x
@Xx
@@ -361,8 +418,8 @@
# Topology: ..
#
-Pattern 431
-# Must be matched before 432.
+Pattern 441
+# Must be matched before 442.
*X
X.
@@ -370,7 +427,7 @@
:2,1
-Pattern 432
+Pattern 442
xx
xx
@@ -378,7 +435,7 @@
:1,1
-Pattern 433
+Pattern 443
@x
xx
@@ -386,7 +443,7 @@
:1,0
-Pattern 434
+Pattern 444
!@
.x
@@ -710,12 +767,6 @@
# Linear, two marginal vertices.
#
-#Pattern 529
-# This actually turned up once, but it was bent...
-#!!...
-#:1,1
-
-
Pattern 528
!.x.!
@@ -759,6 +810,28 @@
:1,0
+Pattern 534
+
+xx.x$
+
+:1,1
+
+
+Pattern 535
+
+x*XX$
+
+:2,1
+
+
+Pattern 536
+# FIXME: This is of course too general. Taken from linear_eye().
+
+!xxx!
+
+:1,1
+
+
# .
# Topology: ....
#
@@ -1212,37 +1285,67 @@
Pattern 6017
+# FIXME: Can be generalized.
+
+!...X!
+
+:1,1
+
+
+Pattern 6018
(address@hidden
:2,1
+Pattern 6019
+# FIXME: This is of course too general. Taken from linear_eye().
+
+!xxxx!
+
+:1,1
+
+
# FIXME POST3.0: Do all size 6 linear patterns with 2 or more marginal eye
# points.
-Pattern 6018
+Pattern 6030
@XX>X!
:1,0
-Pattern 6019
+Pattern 6031
@XXX.!
:1,0
-Pattern 6020
+Pattern 6032
address@hidden).!
:1,0
+Pattern 6033
+
+!....$
+
+:1,1
+
+
+Pattern 6034
+
address@hidden
+
+:1,0
+
+
# .
# Topology: .....
#
@@ -1578,6 +1681,14 @@
Pattern 6421
+..
address@hidden
+
+:2,1
+
+
+Pattern 6422
+
@X
xXX.
@@ -1826,7 +1937,7 @@
Pattern 7001
# tm added (3.1.15)
-# Though pattern 7002 matches with a defense point at
+# Though pattern 7003 matches with a defense point at
# the proper place, the code doesn't seem to provide
# more than one defense point.
|(
@@ -1839,8 +1950,31 @@
Pattern 7002
+# FIXME: Can be generalized.
+
address@hidden>X.(
+
+:2,1
+
+
+Pattern 7003
@..>..@
+
+:2,1
+
+
+Pattern 7004
+# FIXME: This is of course too general. Taken from linear_eye().
+
address@hidden@
+
+:2,1
+
+
+Pattern 7005
+
+$.....@
:2,1
Index: patterns/mkeyes.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/mkeyes.c,v
retrieving revision 1.6
diff -u -r1.6 mkeyes.c
--- patterns/mkeyes.c 28 Nov 2001 21:56:01 -0000 1.6
+++ patterns/mkeyes.c 13 Dec 2001 19:13:10 -0000
@@ -29,7 +29,7 @@
#define MAXLINE 80
#define MAXDIMEN 20
#define MAXSIZE 20
-#define MAXPATNO 300
+#define MAXPATNO 400
#include <stdio.h>
#include <stdlib.h>
Index: regression/optics.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/optics.tst,v
retrieving revision 1.4
diff -u -r1.4 optics.tst
--- regression/optics.tst 28 Nov 2001 19:31:46 -0000 1.4
+++ regression/optics.tst 13 Dec 2001 19:13:10 -0000
@@ -206,17 +206,16 @@
#? [1 1]
1807 eval_eye F7
#? [1 2 F11 (F11|H8|F8)]
-1808 eval_eye N7
-#? [0 1 (L6|P8) (L6|P8)]
-1809 eval_eye K5
-#? [0 1 (L6 L6)]
+1808 eval_eye O7
+#? [0 1 (M6|Q8) (M6|Q8)]
+1809 eval_eye N12
+#? [0 1 (O11 O11)]
1810 eval_eye A1
#? [0 1 B2 B2]
1811 eval_eye H1
#? [1 2 (J1|L2) J1]*
1812 eval_eye S1
#? [0 1 R2 R2]
-
# Report number of nodes visited by the tactical reading
Index: regression/owl.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/owl.tst,v
retrieving revision 1.31
diff -u -r1.31 owl.tst
--- regression/owl.tst 12 Dec 2001 14:21:16 -0000 1.31
+++ regression/owl.tst 13 Dec 2001 19:13:11 -0000
@@ -888,10 +888,10 @@
#? [(2|3) F11]
245 owl_defend D11
#? [1 (F11|H8|F8)]*
-246 owl_attack N9
-#? [3 (L6|P8)]
-247 owl_defend N9
-#? [1 (L6|P8)]
+246 owl_attack O9
+#? [3 (M6|Q8)]
+247 owl_defend O9
+#? [1 (M6|Q8)]
248 owl_attack A6
#? [1 (J1|L2)]
249 owl_defend A6
@@ -909,6 +909,10 @@
loadsgf games/strategy26.sgf 257
254 owl_defend O13
#? [1 (M16|O14|N16|N17)]*
+
+loadsgf games/owl34.sgf 211
+255 owl_defend D13
+#? [1 (D14|E13|G16)
########### end of tests #####################
Index: regression/games/marginal_ko.sgf
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/games/marginal_ko.sgf,v
retrieving revision 1.1
diff -u -r1.1 marginal_ko.sgf
--- regression/games/marginal_ko.sgf 28 Nov 2001 19:31:46 -0000 1.1
+++ regression/games/marginal_ko.sgf 13 Dec 2001 19:13:11 -0000
@@ -5,6 +5,6 @@
GN[White (W) vs. Black (B)]
DT[2001-11-27]
SY[Cgoban 1.9.2]TM[5:00:00(5x1:00)];
-AW[ga][la][ma][oa][bb][gb][kb][mb][nb][ob][ac][cc][fc][gc][lc][nc][ad][bd][cd][dd][ed][fd][ld][md][od][be][ie][je][me][ne][af][bf][hf][if][kf][bg][cg][gg][ig][jg][kg][ah][ch][hh][jh][bi][di][ei][hi][ii][dj][ej][gj][ij][jj][ek][gk][mk][nk][el][gl][ll][ml][dm][em][hm][im][lm][nm][an][cn][en][fn][gn][in][mn][nn][on][ao][bo][co][lo][mo][oo][ap][bp][cp][dp][ep][fp][mp][np][sp][aq][cq][fq][gq][jq][kq][qq][rq][gr][hr][ir][jr][lr][pr][rr][gs][ks][qs][ss]
-AB[ba][ca][ea][ia][ja][ka][qa][ab][cb][db][eb][hb][jb][qb][hc][ic][jc][kc][oc][pc][qc][gd][hd][kd][pd][de][ee][fe][ge][le][oe][pe][df][ff][gf][lf][dg][fg][lg][dh][eh][fh][gh][kh][lh][ai][ci][gi][ji][li][mi][ni][oi][aj][bj][cj][hj][kj][lj][oj][bk][dk][hk][ik][kk][ok][pk][bl][cl][dl][il][jl][nl][pl][am][cm][km][om][pm][bn][dn][hn][jn][ln][pn][rn][sn][do][eo][fo][go][io][ko][po][ro][gp][hp][ip][jp][kp][pp][qp][rp][bq][lq][mq][oq][pq][ar][cr][dr][er][mr][nr][or][bs][cs][es][ls][ms][os][ps]
+AW[ga][la][ma][oa][bb][gb][kb][mb][nb][ob][ac][cc][fc][gc][lc][nc][ad][bd][cd][dd][ed][fd][ld][md][od][be][ie][je][me][ne][af][bf][hf][if][kf][nf][bg][cg][gg][ig][jg][kg][ng][ah][ch][hh][jh][bi][di][ei][hi][ii][dj][ej][gj][ij][jj][mj][oj][pj][ek][gk][mk][nk][ok][el][gl][ml][nl][dm][em][hm][im][mm][om][an][cn][en][fn][gn][in][nn][on][pn][ao][bo][co][mo][no][po][ap][bp][cp][dp][ep][fp][np][op][sp][aq][cq][fq][gq][jq][kq][qq][rq][gr][hr][ir][jr][lr][pr][rr][gs][ks][qs][ss]
+AB[ba][ca][ea][ia][ja][ka][qa][ab][cb][db][eb][hb][jb][qb][hc][ic][jc][kc][oc][pc][qc][gd][hd][kd][pd][de][ee][fe][ge][le][oe][pe][df][ff][gf][lf][pf][dg][fg][lg][mg][pg][dh][eh][fh][gh][kh][lh][nh][oh][ph][qh][ai][ci][gi][ji][li][mi][oi][qi][ri][aj][bj][cj][hj][kj][lj][nj][rj][bk][dk][hk][ik][kk][pk][qk][bl][cl][dl][il][jl][kl][ol][ql][am][cm][km][lm][pm][qm][bn][dn][hn][jn][kn][mn][qn][rn][sn][do][eo][fo][go][io][ko][lo][ro][gp][hp][ip][jp][kp][lp][pp][qp][rp][bq][lq][mq][oq][pq][ar][cr][dr][er][mr][nr][or][bs][cs][es][ls][ms][os][ps]
)
Index: regression/games/owl34.sgf
===================================================================
RCS file: regression/games/owl34.sgf
diff -N regression/games/owl34.sgf
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regression/games/owl34.sgf 13 Dec 2001 19:13:11 -0000
@@ -0,0 +1,43 @@
+(;GM[1]FF[4]
+SZ[19]HA[0]KM[0.5]
+PW[darKstar]WR[15k]
+PB[GnuGo (GNU Go 3.1.15)]BR[14k*]
+PC[NNGS]DT[2001-12-07]AP[gnugoclient:2.0]
+RE[W+41.5]
+;B[dp];W[qp];B[dd];W[pc];B[op];W[pn];B[qq];W[rq];B[pq];W[ro];B[kq]
+;W[qk];B[qe];W[pe];B[pf];W[qd];B[oe];W[od];B[pd];W[nd];B[mf];W[qh]
+;B[mo];W[fq];B[hq];W[dq];B[cq];W[ep];B[do];W[dr];B[jd];W[qc];B[dj]
+;W[cc];B[dc];W[cd];B[ce];W[be];B[cf];W[bf];B[cg];W[db];B[eb];W[cb]
+;B[fc];W[lc];B[cr];W[gr];B[bg];W[hg];B[em];W[jg];B[hr];W[er];B[fp]
+;W[gp];B[fo];W[gq];B[ho];W[hp];B[go];W[ip];B[ir];W[jo];B[oh];W[ok]
+;B[eh];W[mh];B[pe];W[ke];B[ne];W[ng];B[og];W[qg];B[ko];W[jn];B[ll]
+;W[lm];B[mm];W[km];B[kl];W[jl];B[jk];W[kk];B[il];W[jm];B[hk];W[jj]
+;B[ik];W[ml];B[lk];W[kj];B[mk];W[nl];B[gi];W[je];B[hb];W[ge];B[ic]
+;W[rr];B[qr];W[cl];B[bk]C[L:7];W[ck];B[kb]C[L:8];W[lb];B[fg]C[L:9]
+;W[bl];B[bj]C[L:8];W[bo];B[bp];W[co];B[cp];W[dn];B[cj]C[L:6];W[bn]
+;B[el]C[L:7];W[dm];B[ao]C[L:8];W[gm];B[en];W[im];B[kc];W[mi];B[ld]
+C[L:9];W[md];B[la]C[L:8];W[nb];B[mc]C[L:9];W[mb];B[kd];W[le];B[me]
+C[L:10];W[lp];B[kp]C[L:5];W[np];B[lq]C[L:3];W[oo];B[no];W[pp];B[oq]
+;W[mn];B[nn]C[L:4];W[nm];B[lo]C[L:5];W[hi];B[rs];W[hj];B[gj]C[L:6]
+;W[gk];B[gl]C[L:7];W[fk];B[fl]C[L:8];W[gh];B[fi]C[L:9];W[ij];B[hl]
+C[L:10];W[gf];B[hm];W[ee];B[de];W[ef];B[fh];W[dg];B[on];W[om];B[dh]
+;W[ie];B[af];W[bd];B[da];W[ca];B[ds];W[es];B[cs];W[ea];B[fa];W[ac]
+;B[gg];W[hh];B[po];W[qo];B[ln];W[gc];B[gb];W[fd];B[ff];W[ae];B[fe]
+;W[ed];B[ec];W[ag];B[ah];W[hn];B[gn];W[hs];B[jr];W[oo];B[io];W[jp]
+;B[mm];W[nj];B[po];W[bh];B[ai];W[oo];B[in];W[po];B[is];W[gs];B[ma]
+;W[na];B[ka];W[hd];B[sr];W[sq];B[mn];W[ss];B[qs];W[an];B[al];W[am]
+;B[cm];W[sr];B[af];W[id];B[ag];W[hc];B[ja];W[ib];B[nc];W[oc];B[ia]
+;W[jc];B[da];W[gd];B[ea];W[ic];B[eo];W[eq];B[jq];W[nk];B[eg];W[df]
+;B[kn];W[jb];B[ha];W[lj];B[iq];W[mj];B[]
+C[final_score: W+41.5
+Q16 removed
+P13 removed
+B12 removed
+C9 removed
+F9 removed
+A7 removed
+D7 removed
+G7 removed
+M4 removed
+O4 removed]
+)
- [gnugo-devel] optics patch,
Gunnar Farneback <=