gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Readconnect


From: Gunnar Farneback
Subject: Re: [gnugo-devel] Readconnect
Date: Mon, 10 Dec 2001 18:55:36 +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)

Tristan wrote:
> that's detecting common second order liberties, so it is exactly what
> is needed.
> by changing one line, we get even two more passes :)
> 
>  static int moves_to_prevent_connection_in_three_moves (int *moves,
>                                                        int str1, int
> str2) {
> -  if (moves_to_prevent_connection_in_two_moves(moves, str1, str2))
> +  if (moves_to_connect_in_three_moves(moves, str1, str2))
>      return 1;
>    return 0;

I've included this in the patch below. Additionally there's some more
code in moves_to_connect_in_three_moves(), a bugfix in
prevent_capture_one_move(), further revisions of connect.tst
(including a bugfix for my earlier revision), and 14 new test cases in
connection.tst. The latter feature the monkey jump with relatives.

/Gunnar

Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.13
diff -u -r1.13 readconnect.c
--- engine/readconnect.c        2001/12/09 20:25:11     1.13
+++ engine/readconnect.c        2001/12/10 17:47:20
@@ -473,8 +473,11 @@
  */
 
 static int moves_to_connect_in_three_moves (int *moves, int str1, int str2) {
-  int r;
+  int r, s;
   int liberties, libs[MAXLIBS];
+  int adj, adjs[MAXCHAIN];
+  int adjadj, adjadjs[MAXCHAIN];
+  int move;
   int k;
   int mx[BOARDMAX];
   
@@ -497,9 +500,40 @@
       if (ON_BOARD(libs[r] + delta[k]) && mx[libs[r] + delta[k]])
        add_array(moves, libs[r] + delta[k]);
 
+  /* Capture a neighbor of str1 which is in atari. The captured string
+   * must in turn have a neighbor which can connect to str2 easily.
+   */
+  adj = chainlinks2(str1, adjs, 1);
+  for (r = 0; r < adj; r++) {
+    adjadj = chainlinks(adjs[r], adjadjs);
+    for (s = 0; s < adjadj; s++) {
+      if (!same_string(adjadjs[s], str1)
+         && quiescence_connect(adjadjs[s], str2, &move)) {
+       findlib(adjs[r], 1, libs);
+       add_array(moves, libs[0]);
+       add_array(moves, move);
+      }
+    }
+  }
+
+  /* And vice versa. */
+  adj = chainlinks2(str2, adjs, 1);
+  for (r = 0; r < adj; r++) {
+    adjadj = chainlinks(adjs[r], adjadjs);
+    for (s = 0; s < adjadj; s++) {
+      if (!same_string(adjadjs[s], str2)
+         && quiescence_connect(adjadjs[s], str1, &move)) {
+       findlib(adjs[r], 1, libs);
+       add_array(moves, libs[0]);
+       add_array(moves, move);
+      }
+    }
+  }
+  
   return 0;
 }
 
+
 /* Not yet written.
  *
  * Find the complete set of possible moves that can prevent
@@ -508,7 +542,7 @@
 
 static int moves_to_prevent_connection_in_three_moves (int *moves,
                                                       int str1, int str2) {
-  if (moves_to_prevent_connection_in_two_moves(moves, str1, str2))
+  if (moves_to_connect_in_three_moves(moves, str1, str2))
     return 1;
   return 0;
 }
@@ -888,11 +922,13 @@
   
   liberties = findlib(str1, MAXLIBS, libs);
   if (liberties==1) {
+    add_array(moves, libs[0]);
     res = WIN;
     adj = chainlinks2(str1, adjs, 1);
-    for (r = 0; r < adj; r++)
-      add_array(moves, adjs[r]);
-    add_array(moves, libs[0]);
+    for (r = 0; r < adj; r++) {
+      findlib(adjs[r], 1, libs);
+      add_array(moves, libs[0]);
+    }
   }
   return res;
 }
Index: regression/connect.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/connect.tst,v
retrieving revision 1.6
diff -u -r1.6 connect.tst
--- regression/connect.tst      2001/12/09 17:38:52     1.6
+++ regression/connect.tst      2001/12/10 17:47:20
@@ -34,9 +34,10 @@
 9 disconnect G6 E5
 #? [0]
 
+# Added A7, A5, B7, and C6. /gf
 loadsgf golois/Connecter990428-1.sgf
 10 disconnect B5 B8
-#? [1 A6]*
+#? [1 (A6|A7|A5|B7|C6)]*
 
 loadsgf golois/Connecter990428-1.sgf
 11 connect B5 B8
@@ -96,14 +97,14 @@
 24 disconnect G15 F17
 #? [0]
 
-# Added F3. /gf
 loadsgf golois/Connecter990628-2.sgf
 25 connect E2 J3
-#? [1 (G1|F3)]*
+#? [1 G1]*
 
+# Added D3. /gf
 loadsgf golois/Connecter990630-1.sgf
 26 connect F2 D2
-#? [1 F1]*
+#? [1 (F1|D3)]*
 
 loadsgf golois/Goemate990902-11.sgf
 27 disconnect L13 K15
@@ -206,9 +207,10 @@
 50 disconnect J5 H4
 #? [1 H5]
 
+# Added O14 and P14. /gf
 loadsgf golois/Handtalk980820-1.sgf
 51 disconnect P16 Q15
-#? [1 O15]*
+#? [1 (O15|O14|P14)]*
 
 # Added B15. /gf
 loadsgf golois/Handtalk980820-2.sgf
@@ -322,7 +324,7 @@
 # Added J3 and J4. /gf
 loadsgf golois/Neurogo97-1.sgf
 77 disconnect H2 H4
-#? [1 J2]*
+#? [1 (J2|J3|J4)]*
 
 loadsgf golois/Neurogo97-3.sgf
 78 disconnect E3 C3
Index: regression/connection.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/connection.tst,v
retrieving revision 1.12
diff -u -r1.12 connection.tst
--- regression/connection.tst   2001/11/28 19:31:46     1.12
+++ regression/connection.tst   2001/12/10 17:47:20
@@ -119,6 +119,41 @@
 33 disconnect B4 C6
 #? [B5]*
 
+# Monkey jumps and relatives.
+loadsgf games/connection3.sgf
+34 disconnect B11 A9
+#? [0]
+35 disconnect L12 H13
+#? [0]
+36 connect M3 N7
+#? [1 (N4|M4|N5|N6)]
+37 disconnect M3 N7
+#? [1 (N4|M4|N5|M5|M6)]
+38 connect B2 G1
+#? [1 E1]
+39 disconnect B2 G1
+#? [1 (F2|F1|E2|E1|D2|D1|C2|C1|G2|H1|B1)]
+
+# More monkey jumps and relatives.
+loadsgf games/connection4.sgf
+40 connect B11 A8
+#? [1 B9]
+41 disconnect B11 A8
+#? [1 (B9|A10|B10|B8|A7)]
+42 connect L12 H13
+#? [1 K12]
+43 disconnect L12 H13
+#? [1 (K12|J12|J13|H12|G13)]
+44 connect M3 N7
+#? [3 M6]
+45 disconnect M3 N7
+#? [1 (N4|M4|N5|M5|M6|M7|N8|M8)]
+46 connect B2 G1
+#? [1 (B1|C1|C2|D2|E1|F1)]
+47 disconnect B2 G1
+#? [1 (C1|E1)]
+
+
 # Report number of nodes visited by the tactical reading
 10000 get_reading_node_counter
 #? [0]&
Index: regression/games/connection3.sgf
===================================================================
RCS file: connection3.sgf
diff -N connection3.sgf
--- /dev/null   Sat Apr 14 20:46:23 2001
+++ connection3.sgf     Mon Dec 10 12:47:20 2001
@@ -0,0 +1,10 @@
+(;GM[1]FF[3]
+RU[Japanese]SZ[13]HA[0]KM[5.5]
+PW[White]
+PB[Black]
+GN[White (W) vs. Black (B)]
+DT[2001-11-20]
+SY[Cgoban 1.9.2]TM[5:00:00(5x1:00)];;
+AW[ba][da][ha][la][ab][bb][cb][db][kb][lb][mb][bc][lc][ld][md][ae][mg][ah][bh][bi][aj][bj][bk][lk][al][bl][jl][kl][ll][ml][gm][jm][lm]
+AB[ea][eb][cc][dc][ec][fc][gc][hc][ic][jc][kc][cd][kd][ce][ke][le][me][cf][kf][ag][bg][cg][kg][ch][kh][ci][ki][cj][kj][ck][dk][ek][fk][gk][hk][ik][jk][kk][il][im]
+)
Index: regression/games/connection4.sgf
===================================================================
RCS file: connection4.sgf
diff -N connection4.sgf
--- /dev/null   Sat Apr 14 20:46:23 2001
+++ connection4.sgf     Mon Dec 10 12:47:20 2001
@@ -0,0 +1,10 @@
+(;GM[1]FF[3]
+RU[Japanese]SZ[13]HA[0]KM[5.5]
+PW[White]
+PB[Black]
+GN[White (W) vs. Black (B)]
+DT[2001-11-20]
+SY[Cgoban 1.9.2]TM[5:00:00(5x1:00)];;
+AW[ba][da][ha][la][ab][bb][cb][db][kb][lb][mb][bc][lc][ld][md][af][mg][dh][eh][ci][ei][aj][bj][cj][dj][ej][bk][lk][al][bl][jl][kl][ll][ml][dm][gm][jm][lm]
+AB[ea][ja][eb][cc][dc][ec][fc][gc][hc][ic][jc][kc][cd][kd][ae][ce][ke][le][me][cf][kf][cg][dg][eg][fg][kg][bh][ch][fh][kh][mh][ai][bi][fi][ki][fj][kj][ck][dk][ek][fk][gk][hk][ik][jk][kk][il][im]
+)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]