gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] snapback, connect.tst 23, 39


From: Teun Burgers
Subject: [gnugo-devel] snapback, connect.tst 23, 39
Date: Wed, 14 Nov 2001 20:06:14 +0100

It looks to me it is more logical
to put the snapback function from readconnect.c
in board.c since it is potentially useful elsewhere too.

connect.tst tests 23 and 39 have more than one correct answer.
It depends on the orientation of the tests which answer
is found.

Teun

- move snapback from readconnect.c to board.c
- revise answers of connect.tst 23 and 39.
Index: engine/board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.19
diff -u -r1.19 board.c
--- engine/board.c      2001/11/10 14:07:10     1.19
+++ engine/board.c      2001/11/14 18:41:55
@@ -1669,6 +1669,34 @@
   return liberties <= 1;
 }
 
+/* verifies that capturing the stone at str is not a snapback */
+
+int snapback (int str) {
+  int stones, liberties, lib;
+
+  /* if more than one stone captured, not a snapback */
+  stones = countstones(str);
+  if (stones > 1)
+    return 0;
+
+  /* if more than one liberty, not a snapback */
+  liberties = findlib(str, 1, &lib);
+  if (liberties > 1)
+    return 0;
+
+  /* if only one liberty after capture */
+  if (trymove(lib, OTHER_COLOR(board[str]),
+             "snapback", str, EMPTY, 0)) {
+    liberties=0;
+    if (IS_STONE(board[lib]))
+      liberties = countlib(lib);
+    popgo();
+    if (liberties > 1)
+      return 0;
+    return WIN;
+  }
+  return 0;
+}
 
 /*
  * Returns true if pos is a liberty of the string at str.
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.44
diff -u -r1.44 liberty.h
--- engine/liberty.h    2001/11/11 15:18:10     1.44
+++ engine/liberty.h    2001/11/14 18:41:58
@@ -136,6 +136,9 @@
 /* Check for self atari. */
 int is_self_atari(int pos, int color);
 
+/* verifies that capturing the stone at str is not a snapback */
+int snapback(int str);
+
 /* Count the number of stones in a string. */
 int countstones(int str);
 int findstones(int str, int maxstones, int *stones);
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.11
diff -u -r1.11 readconnect.c
--- engine/readconnect.c        2001/11/02 22:22:18     1.11
+++ engine/readconnect.c        2001/11/14 18:42:02
@@ -35,7 +35,6 @@
 static int add_array(int *array, int elt);
 static int element_array (int *array,int elt);
 static void intersection_array(int *array1, int *array2);
-static int snapback(int str);
 static int connection_one_move(int str1, int str2);
 static int prevent_connection_one_move(int *moves, int str1, int str2);
 static int connected_one_move(int str1, int str2);
@@ -100,35 +99,6 @@
       array1[0]--;
       r--;
     }
-}
-
-/* verifies that capturing the stone at str is not a snapback */
-
-static int snapback (int str) {
-  int stones, liberties, lib;
-
-  /* if more than one stone captured, not a snapback */
-  stones = countstones(str);
-  if (stones > 1)
-    return 0;
-
-  /* if more than one liberty, not a snapback */
-  liberties = findlib(str, 1, &lib);
-  if (liberties > 1)
-    return 0;
-
-  /* if only one liberty after capture */
-  if (trymove(lib, OTHER_COLOR(board[str]),
-             "snapback", str, EMPTY, 0)) {
-    liberties=0;
-    if (IS_STONE(board[lib]))
-      liberties = countlib(lib);
-    popgo();
-    if (liberties > 1)
-      return 0;
-    return WIN;
-  }
-  return 0;
 }
 
 /* Verifies that the strings str1 and str2 can be connected
Index: regression/connect.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/connect.tst,v
retrieving revision 1.3
diff -u -r1.3 connect.tst
--- regression/connect.tst      2001/11/07 05:41:30     1.3
+++ regression/connect.tst      2001/11/14 18:42:04
@@ -88,7 +88,7 @@
 
 loadsgf golois/Connecter990628-1.sgf
 23 connect L6 N6
-#? [1 M7]
+#? [1 (M7|N5)]
 
 loadsgf golois/Connecter990628-2.sgf
 24 disconnect G15 F17
@@ -152,7 +152,7 @@
 
 loadsgf golois/Goemate991106-2.sgf
 39 connect F15 H13
-#? [1 G15]*
+#? [1 (F14|G15|H14)]
 
 loadsgf golois/Goemate991106-2.sgf
 40 disconnect G14 D16

reply via email to

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