gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] yet another tactical reading patch


From: Gunnar Farnebäck
Subject: [gnugo-devel] yet another tactical reading patch
Date: Mon, 07 Jun 2004 03:08:50 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI)

I also have a tactical reading patch, solving reading:198 and (in the
same position) connection:113. No other regression effects and node
counter increases of less than 0.01%. It does not solve blunder:24
(same position as the solved tests) but is an important step on the
way.

- new static function special_rescue4() called from defend2() in reading.c

/Gunnar

Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.145
diff -u -r1.145 reading.c
--- engine/reading.c    2 Jun 2004 20:28:45 -0000       1.145
+++ engine/reading.c    5 Jun 2004 13:50:30 -0000
@@ -254,6 +254,8 @@
                                  struct reading_moves *moves);
 static void special_rescue3_moves(int str, int libs[3],
                                  struct reading_moves *moves);
+static void special_rescue4_moves(int str, int libs[2],
+                                 struct reading_moves *moves);
 static void hane_rescue_moves(int str, int libs[4],
                              struct reading_moves *moves);
 static void special_rescue5_moves(int str, int libs[3],
@@ -1456,6 +1458,8 @@
     }
   }
 
+  special_rescue4_moves(str, libs, &moves);
+  
   /* Only order and test the new set of moves. */
   order_moves(str, &moves, other, read_function_name, *move);
   DEFEND_TRY_MOVES(0, &suggest_move);
@@ -1973,6 +1977,62 @@
   }
 }
 
+
+/* This code can find moves to counter attack moves generated by
+ * special_attack3_moves(). In case such an attack move has only two
+ * liberties, this function finds the liberty which is not common with
+ * the attacked string.
+ *
+ * For a typical example, see reading:198 where black L7 is generated
+ * by special_attack3_moves() and the response at L8 is generated by
+ * this function.
+ */
+
+static void
+special_rescue4_moves(int str, int libs[2], struct reading_moves *moves)
+{
+  int color = board[str];
+  int other = OTHER_COLOR(color);
+  int xpos;
+  int apos;
+  int bpos;
+  int libs2[2];
+  int k;
+  int r;
+
+  ASSERT1(countlib(str) == 2, str);
+
+  for (k = 0; k < 2; k++) {
+    apos = libs[k];
+    bpos = libs[1-k];
+    
+    if (apos == SOUTH(bpos) || apos == NORTH(bpos)) {
+      if (board[WEST(apos)] == other)
+       xpos = WEST(apos);
+      else if (board[EAST(apos)] == other)
+       xpos = EAST(apos);
+      else
+       continue;
+    }
+    else if (apos == WEST(bpos) || apos == EAST(bpos)) {
+      if (board[SOUTH(apos)] == other)
+       xpos = SOUTH(apos);
+      else if (board[NORTH(apos)] == other)
+       xpos = NORTH(apos);
+      else
+       continue;
+    }
+    else
+      return; /* Incorrect configuration, give up. */
+
+    if (findlib(xpos, 2, libs2) == 2) {
+      for (r = 0; r < 2; r++)
+       if (libs2[r] != apos && libs2[r] != bpos
+           && !is_self_atari(libs2[r], color))
+         ADD_CANDIDATE_MOVE(libs2[r], 0, *moves, "special_rescue4");
+    }
+  }
+}
 
 /* In a situation like this:
  *




reply via email to

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