[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] Re: snapbacks
From: |
Gunnar Farnebäck |
Subject: |
Re: [gnugo-devel] Re: snapbacks |
Date: |
Tue, 31 Jan 2006 20:50:27 +0100 |
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) |
Dan wrote:
> However I admit that the best method of filtering them is a little
> unclear due to this type of example. One way would be not to
> accept a snapback move unless it is the only owl attack
> move for some dragon. Or maybe your method of giving a
> negative shape value is simpler and better.
I'm suddenly getting deja-vu feelings. Ah, from this discussion:
http://lists.gnu.org/archive/html/gnugo-devel/2004-11/msg00062.html
The patch in that message filters out send-two-return-one moves from
consideration in do_find_more_owl_attack_and_defense_moves(), which
should be equally effective for moves playing into snapback. Indeed,
the attached patch changes the original example to
Q7: 2.33 (followup) - threatens to capture Q6
Q7: 5.25 (followup) - threatens to capture R8
Q7: not a safe move
[...]
Top moves:
1. T6 28.90
2. R5 25.80
3. P2 9.24
4. R4 6.93
which is as effective as we could hope for.
However, before this patch can be used it's necessary to do some
preparations so that playing_into_snapback() isn't sometimes called
with the first move already trymoved. See
http://trac.gnugo.org/gnugo/ticket/74 for a patch and further
explanations.
/Gunnar
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.252
diff -u -r1.252 liberty.h
--- engine/liberty.h 25 Jan 2006 17:14:04 -0000 1.252
+++ engine/liberty.h 31 Jan 2006 17:24:01 -0000
@@ -530,6 +530,7 @@
int double_atari(int move, int color, float *value,
signed char safe_stones[BOARDMAX]);
int send_two_return_one(int move, int color);
+int playing_into_snapback(int move, int color);
int play_attack_defend_n(int color, int do_attack, int num_moves, ...);
int play_attack_defend2_n(int color, int do_attack, int num_moves, ...);
int play_break_through_n(int color, int num_moves, ...);
Index: engine/utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.112
diff -u -r1.112 utils.c
--- engine/utils.c 29 Jan 2006 18:36:59 -0000 1.112
+++ engine/utils.c 31 Jan 2006 17:24:01 -0000
@@ -1396,6 +1396,26 @@
}
+/* Returns true if a move by (color) plays into a snapback. */
+int
+playing_into_snapback(int move, int color)
+{
+ int libs[2];
+ int k;
+
+ if (approxlib(move, color, 1, NULL) != 0
+ || accuratelib(move, color, 2, libs) != 1)
+ return 0;
+
+ for (k = 0; k < 4; k++)
+ if (board[move + delta[k]] == color
+ && adjacent_strings(libs[0], move + delta[k]))
+ return 1;
+
+ return 0;
+}
+
+
/* Score the game and determine the winner */
void
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.161
diff -u -r1.161 value_moves.c
--- engine/value_moves.c 25 Jan 2006 17:14:04 -0000 1.161
+++ engine/value_moves.c 31 Jan 2006 17:24:03 -0000
@@ -297,6 +297,10 @@
if (send_two_return_one(pos, color))
return;
+ /* Never consider moves playing into snapback here. */
+ if (playing_into_snapback(pos, color))
+ return;
+
save_verbose = verbose;
if (verbose > 0)
verbose --;