gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] Bug in combinaison attacks


From: Gunnar Farneback
Subject: Re: [gnugo-devel] Bug in combinaison attacks
Date: Mon, 28 Jul 2003 13:18:23 +0200
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)

Stephane wrote:
> There is probably a problem in the combinaison attack module.

Definitely.

> In the following 2 stones game at move 127, gnugo correctly
> sees that Black threatens a combinaison attack in the left
> territory begining with ataris at J12, G10, E8, B9, C9, but
> gives 33 defense points, some of them irrelevant.

16 of the defense points are bogus. I have not investigated what goes
wrong but this patch adds the position to the regressions. This
includes implementing a new GTP command combination_defend to list the
defense points.

- new GTP command combination_defend
- new test and game record

This patch is for 3.5.1.

/Gunnar

Index: doc/gtp-commands.texi
===================================================================
RCS file: /cvsroot/gnugo/gnugo/doc/gtp-commands.texi,v
retrieving revision 1.13
diff -u -r1.13 gtp-commands.texi
--- doc/gtp-commands.texi       7 Jul 2003 21:45:11 -0000       1.13
+++ doc/gtp-commands.texi       28 Jul 2003 10:42:07 -0000
@@ -752,6 +752,21 @@
 @end example
 
 
address@hidden combination_defend
address@hidden combination_defend
+
address@hidden
+
+ Function:  If color can capture something through a
+            combination attack, list moves by the opponent of color
+            to defend against this attack.
+ Arguments: color
+ Fails:     invalid color
+ Returns:   Recommended moves, PASS if no combination attack found.
+
address@hidden example
+
+
 @cindex aa_confirm_safety
 @item aa_confirm_safety
 
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.122
diff -u -r1.122 play_gtp.c
--- interface/play_gtp.c        7 Jul 2003 21:45:11 -0000       1.122
+++ interface/play_gtp.c        28 Jul 2003 10:42:25 -0000
@@ -77,6 +77,7 @@
 DECLARE(gtp_clear_board);
 DECLARE(gtp_clear_cache);
 DECLARE(gtp_combination_attack);
+DECLARE(gtp_combination_defend);
 DECLARE(gtp_connect);
 DECLARE(gtp_countlib);
 DECLARE(gtp_cputime);
@@ -202,6 +203,7 @@
   {"clear_cache",            gtp_clear_cache},
   {"color",                          gtp_what_color},
   {"combination_attack",      gtp_combination_attack},
+  {"combination_defend",      gtp_combination_defend},
   {"connect",                gtp_connect},
   {"countlib",                       gtp_countlib},
   {"cputime",                gtp_cputime},
@@ -2176,6 +2180,46 @@
   return gtp_finish_response();
 }
 
+/* Function:  If color can capture something through a
+ *            combination attack, list moves by the opponent of color
+ *            to defend against this attack.
+ * Arguments: color
+ * Fails:     invalid color
+ * Returns:   Recommended moves, PASS if no combination attack found.
+ */
+
+static int
+gtp_combination_defend(char *s)
+{
+  int color;
+  char defense_points[BOARDMAX];
+  int pos;
+  int first = 1;
+  int n;
+
+  n = gtp_decode_color(s, &color);
+  if (!n)
+    return gtp_failure("invalid color");
+
+  silent_examine_position(BLACK, EXAMINE_ALL);
+
+  memset(defense_points, 0, sizeof(defense_points));
+  if (!atari_atari(color, NULL, defense_points, verbose))
+    return gtp_success("PASS");
+  
+  gtp_start_response(GTP_SUCCESS);
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++)
+    if (ON_BOARD(pos) && defense_points[pos]) {
+      if (!first)
+       gtp_printf(" ");
+      else
+       first = 0;
+      gtp_print_vertex(I(pos), J(pos));
+    }
+  
+  return gtp_finish_response();
+}
+
 /* Function:  Run atari_atari_confirm_safety().
  * Arguments: move, optional int
  * Fails:     invalid move
Index: regression/atari_atari.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/atari_atari.tst,v
retrieving revision 1.38
diff -u -r1.38 atari_atari.tst
--- regression/atari_atari.tst  7 May 2003 15:04:26 -0000       1.38
+++ regression/atari_atari.tst  28 Jul 2003 10:42:30 -0000
@@ -100,3 +100,8 @@
 loadsgf games/atari_atari07.sgf
 23 combination_attack black
 #? [C8]
+
+loadsgf games/atari_atari08.sgf 227
+24 combination_defend black
+#? [!.*(K16|A12|R12|S12|T12|A11|B11|C11|R11|S11|T11|A10|C10|Q10|S10|D9).*]
+
Index: regression/games/atari_atari08.sgf
===================================================================
RCS file: regression/games/atari_atari08.sgf
diff -N regression/games/atari_atari08.sgf
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regression/games/atari_atari08.sgf  28 Jul 2003 10:42:31 -0000
@@ -0,0 +1,273 @@
+(;GM[1]FF[4]RU[Japanese]SZ[19]HA[2]KM[5.5]RE[B+18.5]
+PW[GNU Go 3.3.23 (random seed 236242294)]PB[GNU Go 3.2 (random seed 0)]
+AB[pd][dp]PL[W]
+;W[ed]
+;B[pp]
+;W[nc]
+;B[cd]
+;W[jp]
+;B[df]
+;W[ch]
+;B[lc]
+;W[qn]
+;B[nd]
+;W[mc]
+;B[pn]
+;W[pm]
+;B[on]
+;W[qo]
+;B[qp]
+;W[qj]
+;B[np]
+;W[qf]
+;B[hq]
+;W[cn]
+;B[dn]
+;W[dm]
+;B[en]
+;W[co]
+;B[cp]
+;W[cl]
+;B[fp]
+;W[gc]
+;B[cg]
+;W[dh]
+;B[ic]
+;W[fl]
+;B[ff]
+;W[gh]
+;B[of]
+;W[ph]
+;B[dc]
+;W[hd]
+;B[om]
+;W[pl]
+;B[nk]
+;W[lp]
+;B[io]
+;W[mq]
+;B[nq]
+;W[lb]
+;B[ld]
+;W[pb]
+;B[jr]
+;W[kr]
+;B[kq]
+;W[lr]
+;B[jq]
+;W[nr]
+;B[or]
+;W[kp]
+;B[ns]
+;W[mr]
+;B[ip]
+;W[kn]
+;B[jm]
+;W[qd]
+;B[il]
+;W[qc]
+;B[bo]
+;W[bn]
+;B[bp]
+;W[hj]
+;B[kb]
+;W[jj]
+;B[mb]
+;W[rp]
+;B[rq]
+;W[lk]
+;B[md]
+;W[km]
+;B[oc]
+;W[bg]
+;B[bf]
+;W[bh]
+;B[ro]
+;W[rn]
+;B[sp]
+;W[jg]
+;B[ec]
+;W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