gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] more reading defense moves


From: Gunnar Farneback
Subject: Re: [gnugo-devel] more reading defense moves
Date: Mon, 18 Nov 2002 17:19:33 +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)

Arend wrote:
>  - reading.c: new move for defend1(): try to set up snap back
>  - reading.c: special_rescue4() generalized to hane_rescue_moves()
> 
> The snap-back case should be self-explaining.

Incidentally I have a snapback patch too, which has been lying around
for a while without time for evaluation. Feel free to merge it with
your patch as you like.

/Gunnar

Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.83
diff -u -r1.83 reading.c
--- engine/reading.c    20 Oct 2002 10:05:39 -0000      1.83
+++ engine/reading.c    18 Nov 2002 16:15:06 -0000
@@ -152,6 +152,8 @@
                                  struct reading_moves *moves);
 static void special_rescue6_moves(int str, int libs[3],
                                  struct reading_moves *moves);
+static void set_up_snapback_moves(int str, int lib,
+                                 struct reading_moves *moves);
 static void edge_clamp_moves(int str, struct reading_moves *moves);
 static int do_attack(int str, int *move, int komaster, int kom_pos);
 static int attack1(int str, int *move, int komaster, int kom_pos);
@@ -1110,7 +1112,7 @@
   SETUP_TRACE_INFO("defend1", str);
   reading_node_counter++;
   
-  gg_assert(IS_STONE(board[str]));
+  ASSERT1(IS_STONE(board[str]), str);
   ASSERT1(countlib(str) == 1, str);
   RTRACE("try to escape atari on %1m.\n", str);
 
@@ -1127,6 +1129,7 @@
   moves.num = 1;
   
   break_chain_moves(str, &moves);
+  set_up_snapback_moves(str, lib, &moves);
   order_moves(str, &moves, color, read_function_name, 0);
 
   for (k = 0; k < moves.num; k++) {
@@ -2190,6 +2193,41 @@
     }
   }
 }
+
+/*
+ * set_up_snapback_moves() is called with (str) a string having a
+ * single liberty at (lib).
+ *
+ * This adds moves which may defend a string in atari by capturing a
+ * neighbor in a snapback. One example is this position:
+ *
+ * OOOOO
+ * OXXXO
+ * OX.OX
+ * OXOXX
+ * OX*..
+ * -----
+ *
+ */
+
+static void
+set_up_snapback_moves(int str, int lib, struct reading_moves *moves)
+{
+  int color = board[str];
+  int other = OTHER_COLOR(color);
+  int libs2[2];
+
+  ASSERT1(countlib(str) == 1, str);
+  
+  /* This can only work if our string is a single stone and the
+   * opponent is short of liberties.
+   */
+  if (countstones(str) == 1
+      && approxlib(lib, other, 2, libs2) == 1
+      && !is_self_atari(libs2[0], color))
+    ADD_CANDIDATE_MOVE(libs2[0], 0, *moves);
+}
+
 
 
 /* In positions like




reply via email to

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