gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Another serious bugfix


From: Gunnar Farneback
Subject: [gnugo-devel] Another serious bugfix
Date: Mon, 01 Apr 2002 14:22:52 +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 an indexing out of bounds bug. Usually this is
harmless in practice, but at least on some architectures (in this case
Alpha) it can cause a crash. The patch also adds a relevant assertion.

- bugfix in strategic_penalty()

/Gunnar

Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.47
diff -u -r1.47 influence.c
--- engine/influence.c  31 Mar 2002 20:46:47 -0000      1.47
+++ engine/influence.c  1 Apr 2002 12:19:24 -0000
@@ -1086,6 +1086,8 @@
   float bi = q->black_influence[m][n];
   float wi = q->white_influence[m][n];
 
+  ASSERT_ON_BOARD2(m, n);
+  
   if (bi > 0.0 && wi == 0.0)
     return BLACK;
 
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.22
diff -u -r1.22 value_moves.c
--- engine/value_moves.c        26 Mar 2002 21:32:59 -0000      1.22
+++ engine/value_moves.c        1 Apr 2002 12:19:25 -0000
@@ -1065,7 +1065,8 @@
    * whether all neighboring intersections belong to the opponent's moyo.
    */
   for (k = 0; k < 4; k++)
-    if (board[pos + delta[k]] != OTHER_COLOR(color)
+    if (ON_BOARD(pos + delta[k])
+       && board[pos + delta[k]] != OTHER_COLOR(color)
         && influence_moyo_color(pos + delta[k]) != OTHER_COLOR(color))
       return 0.0;
 
@@ -1110,11 +1111,15 @@
          return 0.0;
        /* Third line moves (or lower) are ok -- they try to live, not run
          * away.
+        *
+        * FIXME: Add an "edge_distance()" function in board.c which can
+        *        be used here.
          */
         if (gg_min(gg_min(I(pos), board_size-1 - I(pos)),
                    gg_min(J(pos), board_size-1 - J(pos)))
             < 3)
          return 0.0;
+       
        for (i = 0; i < 4; i++)
          if (board[target + delta[i]] == OTHER_COLOR(color)) {
            if (dragon[target + delta[i]].size == 1) {



reply via email to

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