[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] connection tuning
From: |
nando |
Subject: |
Re: [gnugo-devel] connection tuning |
Date: |
Sun, 16 May 2004 17:20:40 +0200 |
Hi,
I've noticed that my patch was not good enough (see new testcase
connection:112). So I revised it a bit. Breakage unchanged besides the PASS
in the new testcase and performance impact even more negligible.
nando
- connection tuning
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.77
diff -u -r1.77 readconnect.c
--- engine/readconnect.c 29 Apr 2004 23:59:21 -0000 1.77
+++ engine/readconnect.c 16 May 2004 15:07:11 -0000
@@ -2525,6 +2525,7 @@
for (r = 0; r < num_moves; r++) {
int move = moves[r];
int adjacent_to_attacker = 0;
+ int bonus_given = 0;
for (k = 0; k < 4; k++) {
int pos = move + delta[k];
@@ -2537,12 +2538,14 @@
distances[r] -= 0.2;
if (verbose > 0)
gprintf("%o%1M -0.2, adjacent to attacker string with at most two
liberties\n", move);
- if ((conn1->distances[move] - conn1->deltas[move] <= 0.5
- || conn1->distances[pos] - conn1->deltas[pos] <= 0.5)
+ if ((connect_move || !bonus_given)
+ && (conn1->distances[move] - conn1->deltas[move] <= 0.5
+ || conn1->distances[pos] - conn1->deltas[pos] <= 0.5)
&& (conn2->distances[move] - conn2->deltas[move] <= 0.5
|| conn2->distances[pos] - conn2->deltas[pos] <= 0.5)
&& conn1->distances[pos] < total_distance
&& conn2->distances[pos] < total_distance) {
+ bonus_given = 1;
distances[r] -= 0.7;
if (verbose > 0)
gprintf("%o%1M -0.7, capture or atari of immediately connecting
string\n", move);
@@ -2555,10 +2558,29 @@
if (verbose > 0)
gprintf("%o%1M -0.2, adjacent to defender string with at most two
liberties\n", move);
}
+ /* The code above (in the 'board[pos] == other' branch) makes
+ * perfect sense for the defender, but has a tendency to
+ * overestimate solid connection defenses when the attacker's
+ * stones happen to be in atari, specially when capturing some
+ * defender stones instead would help just as well, if not better.
+ * The following code compensates in such kind of situations.
+ * See connection:111 and gunnar:53 for example.
+ */
+ if (!connect_move && countlib(pos) == 1
+ /* let's avoid ko and snapbacks */
+ && accuratelib(move, other, 2, NULL) > 1) {
+ int adjs[MAXCHAIN];
+ float bonus;
+ bonus = 0.1 * chainlinks2(pos, adjs, 2);
+ bonus += 0.5 * chainlinks2(pos, adjs, 1);
+ distances[r] -= bonus;
+ if (verbose > 0)
+ gprintf("%o%1M -%f, capture of defender string\n", move, bonus);
+ }
}
}
if (adjacent_to_attacker
- && color != color_to_move
+ && !connect_move
&& is_edge_vertex(move)) {
distances[r] -= 0.1;
if (verbose > 0)
Index: regression/connection.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/connection.tst,v
retrieving revision 1.73
diff -u -r1.73 connection.tst
--- regression/connection.tst 23 Apr 2004 16:11:57 -0000 1.73
+++ regression/connection.tst 16 May 2004 15:07:23 -0000
@@ -391,6 +391,13 @@
popgo
popgo
+# See also nngs1:11
+loadsgf games/nngs/camel-gnugo-3.1.26-200203022335.sgf 104
+trymove B S6
+112 connect S3 S6
+#? [0]*
+popgo
+
# Report number of nodes visited by the tactical reading
10000 get_reading_node_counter
#? [0]&