gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] bugfixes and tuning


From: Gunnar Farneback
Subject: [gnugo-devel] bugfixes and tuning
Date: Wed, 02 Oct 2002 21:19:45 +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)

This patch fixes a couple of bugs and does a little tuning.

The first bug is in owl_substantial(). If level>=10 the depth values
are incremented for each liberty being filled. However, this only
happens after one (the most common) of the two possible trymove()
calls. When the liberty filling moves are undone afterwards the depth
values are of course decremented. If an increment was missed, this
means that the depth values will become permanently (until
reset_engine() is called) decreased. This is obviously not good.

This patch fixes the bug in owl_substantial() and adds an assertion
in do_genmove() to verify that the depth hasn't changed permanently
during the move generation.

The second bug is in estimate_territorial_value(), in the handling of
ATTACK_THREAT. No followup value is awarded if the attack threat can
be defended with a threat against our move, on the assumption that
this means that the move is gote. However, if the move isn't safe we
want to add the followup value anyway in case it's needed as a ko
threat. So far so good. The problem is that the move safety estimation
often depends on whether an e pattern has been found for the move. It
can happen that the move is considered as unsafe to begin with (and
followup awarded) but if the move valuation is rerun after searching
the endgame database an e pattern may have been found and the move is
now considered safe and no followup should have been awarded. For
technical reasons there's no way to remove the followup value.

The bugfix is to check whether the move is adjacent to some own living
stone and consider those moves too as safe.

The third bug is in estimate_strategical_value(). In the code to award
strategical value if a lunch is attacked or defended, this is disabled
if the considered dragon is tactically critical and the move does not
tactically attack or defend. The bug is that this check always test
whether the move defends, even if it should be an attack.

The bugfix is to check the color of the stones and call does_attack()
or does_defend() appropriately.

Finally the patch includes small amounts of influence tuning, a
modified shape pattern, and a corrected test case.

This patch has a regression delta of 10 unexpected passes, no failures.

trevorb:110     PASS  properly solved, but with rather small margin
trevor:180      PASS  properly solved
trevorc:1510    PASS  improved, semeai issue remains
trevord:1090    PASS  properly solved
nngs2:430       PASS  solved, maybe, not sure what's going on
nngs2:510       PASS  improved, double sente aspect not understood
nngs3:450       PASS  improved, one point territory error remains
nngs3:630       PASS  bogus, test case corrected
century2002:85  PASS  almost properly solved, O9 still undervalued
century2002:210 PASS  properly solved

/Gunnar

Index: engine/genmove.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v
retrieving revision 1.50
diff -u -r1.50 genmove.c
--- engine/genmove.c    22 Sep 2002 10:21:54 -0000      1.50
+++ engine/genmove.c    2 Oct 2002 10:24:54 -0000
@@ -322,6 +322,7 @@
 {
   float val;
   int save_verbose;
+  int save_depth;
 
   start_timer(0);
   
@@ -348,6 +349,11 @@
   /* Prepare pattern matcher and reading code. */
   reset_engine();
 
+  /* Store the depth value so we can check that it hasn't changed when
+   * we leave this function.
+   */
+  save_depth = depth;
+
   /* If in mirror mode, try to find a mirror move. */
   if (play_mirror_go
       && (mirror_stones_limit < 0
@@ -558,7 +564,7 @@
     gprintf("Hash collisions:      %d\n", stats.hash_collisions);
   }
  
- if (showtime) {
+  if (showtime) {
     double spent = time_report(0, "TIME to generate move at ", *move, 1.0);
     total_time += spent;
     if (spent > slowest_time) {
@@ -576,8 +582,14 @@
 
     }
   }
-  
+
+  /* Some consistency checks to verify that things are properly
+   * restored and/or have not been corrupted.
+   */
+  gg_assert(stackp == 0);
   gg_assert(test_gray_border() < 0);
+  gg_assert(depth == save_depth);
+
   return val;
 }
 
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.107
diff -u -r1.107 owl.c
--- engine/owl.c        26 Sep 2002 20:04:36 -0000      1.107
+++ engine/owl.c        2 Oct 2002 10:24:58 -0000
@@ -4255,6 +4255,8 @@
       /* if we can't fill, try swapping with the next liberty */
       if (k < liberties-1
          && trymove(libs[k+1], owl->color, NULL, 0, EMPTY, 0)) {
+       if (level >= 10)
+         increase_depth_values();
        owl->goal[libs[k]] = 1;
        libs[k+1] = libs[k];
       }
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.58
diff -u -r1.58 value_moves.c
--- engine/value_moves.c        28 Sep 2002 00:05:09 -0000      1.58
+++ engine/value_moves.c        2 Oct 2002 10:25:01 -0000
@@ -1184,6 +1184,27 @@
 }
 
 
+/* True if pos is adjacent to a nondead stone of the given color. This
+ * function can be called when stackp>0 but the result is given for the
+ * position when stackp==0.
+ *
+ * FIXME: Move this somewhere more generally accessible, probably
+ *        utils.c
+ */
+static int
+adjacent_to_nondead_stone(int pos, int color)
+{
+  int k;
+  for (k = 0; k < 4; k++)
+    if (ON_BOARD(pos + delta[k])
+       && worm[pos + delta[k]].color == color
+       && dragon[pos + delta[k]].status != DEAD)
+      return 1;
+  
+  return 0;
+}
+
+
 /*
  * Estimate the direct territorial value of a move at (pos).
  */
@@ -1394,7 +1415,8 @@
         * move is tested.
         */
        if (board[aa] != EMPTY
-           && move[pos].move_safety == 1
+           && (move[pos].move_safety == 1
+               || adjacent_to_nondead_stone(pos, color))
            && find_defense(aa, &defense_move) == WIN
            && defense_move != NO_MOVE) {
          if (trymove(defense_move, other,
@@ -1880,9 +1902,12 @@
              this_value = 0.0;
 
            /* If this dragon can be tactically attacked and the move
-             * does not defend, no points.
+             * does not defend or attack, no points.
             */
-           if (worm[bb].attack_codes[0] != 0 && !does_defend(pos, bb))
+           if (worm[bb].attack_codes[0] != 0
+               && ((color == board[bb] && !does_defend(pos, bb))
+                   || (color == OTHER_COLOR(board[bb])
+                       && !does_attack(pos, bb))))
              this_value = 0.0;
 
            /* If we are doing scoring, are alive, and the move loses
Index: patterns/barriers.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/barriers.db,v
retrieving revision 1.39
diff -u -r1.39 barriers.db
--- patterns/barriers.db        30 Sep 2002 20:09:57 -0000      1.39
+++ patterns/barriers.db        2 Oct 2002 10:25:03 -0000
@@ -123,6 +123,23 @@
 ;oplay_attack_either(a,b,c,a,c) || !oplay_attack_either(a,b,b,d)
 
 
+Pattern Barrier6b
+# gf New pattern. (3.3.10)
+# See century2002:85.
+
+OX
+,.
+--
+
+:8,A
+
+aX
+,.
+--
+
+;!defend(a)
+
+
 Pattern Barrier7
 
 XX
@@ -878,6 +895,38 @@
 :8,OXD
 
 
+Pattern Barrier63
+# gf New pattern. (3.3.10)
+
+oX..
+O,..
+.,,.
+....
+----
+
+:8,D
+
+
+Pattern Barrier64
+# gf New pattern. (3.3.10)
+
+oX..
+O,,.
+..,,
+....
+----
+
+:8,D
+
+oXc.
+Oab.
+..,,
+....
+----
+
+;!oplay_attack(a,b,c,c)
+
+
 Pattern Intrusion1
 
 xxxx
@@ -2714,6 +2763,29 @@
 ;!oplay_defend_both(a,?,b,C,D)
 
 >non_xterritory(b);
+
+
+Pattern Nonterritory40
+# gf New pattern. (3.3.10)
+
+oX.
+OX.
+...
+...
+---
+
+:8,t
+
+oX.
+OXc
+dab
+.e.
+---
+
+;!oplay_defend(a,b,c,d,a)
+
+>non_oterritory(d);
+>non_oterritory(e);
 
 
 # END OF FILE
Index: patterns/patterns2.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns2.db,v
retrieving revision 1.46
diff -u -r1.46 patterns2.db
--- patterns/patterns2.db       30 Sep 2002 20:09:57 -0000      1.46
+++ patterns/patterns2.db       2 Oct 2002 10:25:08 -0000
@@ -1610,12 +1610,20 @@
 
 
 Pattern Shape16
+# gf Added constraint. (3.3.10)
+# Usually better to capture if either stone in atari.
 
 ?XO     clean cut
 *Oo
 ?X?
 
 :8,-,shape(1)
+
+?BO
+*Oo
+?A?
+
+;lib(A)>1 && lib(B)>2
 
 
 Pattern Shape17
Index: regression/nngs3.tst
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/nngs3.tst,v
retrieving revision 1.5
diff -u -r1.5 nngs3.tst
--- regression/nngs3.tst        29 Sep 2002 14:51:06 -0000      1.5
+++ regression/nngs3.tst        2 Oct 2002 10:25:09 -0000
@@ -266,7 +266,7 @@
 
 
 
-loadsgf games/nngs/Lazarus-gnugo-3.1.34-200204271842.sgf 183
+loadsgf games/nngs/Lazarus-gnugo-3.1.34-200204271842.sgf 182
 630 gg_genmove black
 #? [A17]*
 




reply via email to

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