Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.152
diff -u -r1.152 reading.c
--- engine/reading.c	8 Sep 2004 17:03:42 -0000	1.152
+++ engine/reading.c	22 Sep 2004 15:40:26 -0000
@@ -309,6 +309,7 @@
 			int color, const char *funcname, int killer);
 static int simple_ladder_defend(int str, int *move);
 static int in_list(int move, int num_moves, int *moves);
+static int is_single(int pos, int color);
 
 
 /* Statistics. */
@@ -4614,6 +4615,14 @@
     moves->score[k] = -2;
 }
 
+static int
+is_single(int pos, int color)
+{
+  if ((board[SOUTH(pos)] != color) && (board[EAST(pos)] != color) &&
+      (board[WEST(pos)] != color) && (board[NORTH(pos)] != color))
+    return(1);
+  return(0);
+}
 
 /*
  * (str) points to a group.
@@ -4654,34 +4663,61 @@
 
     /* If the 3 liberty chain easily can run away through one of the
      * liberties, we don't play on any of the other liberties.
+     * The heuristic for "easily run away" is defined as:
+     * 1. Playing on any of the 3 liberties of the chain and the resulting
+     *    number of liberty of the chain will be less than 4. Or
+     * 2. Playing on the 3 liberties in turn will resulting in:
+     *    4 or more liberties, 4 or less liberties and less than
+     *    4 liberties. In this case we only try one breaking chain move
+     *    on the position with escape potential of 4 or more liberties.
      */
     lib1 = approxlib(libs[0], other, 4, NULL);
     lib2 = approxlib(libs[1], other, 4, NULL);
-    if (lib1 >= 4 && lib2 >= 4)
-      continue;
     lib3 = approxlib(libs[2], other, 4, NULL);
 
-    if ((lib1 >= 4 || lib2 >= 4) && lib3 >= 4)
-      continue;
-
     if (lib1 >= 4 && !mw[libs[0]]) {
-      mw[libs[0]] = 1;
-      possible_moves[u++] = libs[0];
+      if ((lib2 <= 4 && lib3 < 4) || (lib3 <= 4 && lib2 <4))
+      {
+       /* For the safety of the breaking chain move,
+        * the move must be either a single stone, or a resulting
+        * string of 4 or more liberties
+        */
+        if (is_single(libs[0], color) || approxlib(libs[0], color, 4, NULL) > 3)
+        {
+          mw[libs[0]] = 1;
+          possible_moves[u++] = libs[0];
+        }
+      }
       continue;
     }
     
     if (lib2 >= 4 && !mw[libs[1]]) {
-      mw[libs[1]] = 1;
-      possible_moves[u++] = libs[1];
+      if ((lib1 <= 4 && lib3 < 4) || (lib3 <= 4 && lib1 <4))
+      {
+        if (is_single(libs[1], color) || approxlib(libs[1], color, 4, NULL) > 3)
+        {
+          mw[libs[1]] = 1;
+          possible_moves[u++] = libs[1];
+        }
+      }
       continue;
     }
     
     if (lib3 >= 4 && !mw[libs[2]]) {
-      mw[libs[2]] = 1;
-      possible_moves[u++] = libs[2];
+      if ((lib2 <= 4 && lib1 < 4) || (lib1 <= 4 && lib2 <4))
+      {
+        if (is_single(libs[2], color) || approxlib(libs[2], color, 4, NULL) > 3)
+        {
+          mw[libs[2]] = 1;
+          possible_moves[u++] = libs[2];
+        }
+      }
       continue;
     }
 
+    if (lib1 >= 4 || lib2 >= 4 || lib3 >= 4)
+      continue;
+
     /* No easy escape, try all liberties. */
     for (k = 0; k < 3; k++) {
       if (!mw[libs[k]]) {
