gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] test_gray_border


From: Teun Burgers
Subject: [gnugo-devel] test_gray_border
Date: Wed, 02 Jan 2002 18:49:13 +0100

Since the boardhandling depends critically on
the GRAY border being intact, I think it is important
to test for this. The patch adds a new function test_gray_border
to board.c and invokes it in genmove and examine_position.

Teun

Index: engine/board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.26
diff -u -r1.26 board.c
--- engine/board.c      16 Dec 2001 02:10:58 -0000      1.26
+++ engine/board.c      2 Jan 2002 17:42:39 -0000
@@ -335,6 +335,22 @@
   movenum = 0;
 }
 
+/* test the integrity of the gray border */
+int
+test_gray_border(void)
+{
+  int k;
+
+  gg_assert(board_size > 0 && board_size <= MAX_BOARD);
+  
+  for (k = 0; k < BOARDSIZE; k++)
+    if (I(k) < 0 || I(k) >= board_size || J(k) < 0 || J(k) >=
board_size) {
+      if(board[k] != GRAY)
+       return k;
+    }
+  return -1;
+}
+
 
 /* ================================================================ */
 /*                 Pushing and popping of boards                    */
Index: engine/genmove.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v
retrieving revision 1.22
diff -u -r1.22 genmove.c
--- engine/genmove.c    1 Jan 2002 17:46:44 -0000       1.22
+++ engine/genmove.c    2 Jan 2002 17:42:41 -0000
@@ -110,6 +110,7 @@
   }
   if (how_much == EXAMINE_WORMS) {
     verbose = save_verbose;
+    gg_assert(test_gray_border() < 0);
     return;
   }
 
@@ -118,6 +119,7 @@
       compute_initial_influence(color, 0);
     if (how_much == EXAMINE_INITIAL_INFLUENCE) {
       verbose = save_verbose;
+      gg_assert(test_gray_border() < 0);
       return;
     }
 
@@ -125,6 +127,7 @@
       if (NEEDS_UPDATE(dragons_examined_without_owl))
        make_dragons(color, 1);
       verbose = save_verbose;
+      gg_assert(test_gray_border() < 0);
       return;
     }
     
@@ -135,6 +138,7 @@
     }
     if (how_much == EXAMINE_DRAGONS) {
       verbose = save_verbose;
+      gg_assert(test_gray_border() < 0);
       return;
     }
 
@@ -142,6 +146,7 @@
   else if (how_much == EXAMINE_INITIAL_INFLUENCE
           || how_much == EXAMINE_DRAGONS) {
     verbose = save_verbose;
+    gg_assert(test_gray_border() < 0);
     return;
   }
   
@@ -152,8 +157,10 @@
 
   if (NEEDS_UPDATE(initial_influence2_examined))
     compute_initial_influence(color, 1);
-  if (how_much == EXAMINE_INITIAL_INFLUENCE2)
+  if (how_much == EXAMINE_INITIAL_INFLUENCE2) {
+    gg_assert(test_gray_border() < 0);
     return;
+  }
 }
 
 
@@ -233,6 +240,7 @@
 
   *lower_bound = lower + komi;
   *upper_bound = upper + komi;
+  gg_assert(test_gray_border() < 0);
 }
 
 
@@ -504,6 +512,7 @@
     }
   }
   
+  gg_assert(test_gray_border() < 0);
   return val;
 }
 
Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.32
diff -u -r1.32 gnugo.h
--- engine/gnugo.h      16 Dec 2001 02:10:58 -0000      1.32
+++ engine/gnugo.h      2 Jan 2002 17:42:42 -0000
@@ -397,6 +397,7 @@
 /* board.c */
 /* General board handling. */
 void clear_board(void);
+int test_gray_border(void);
 void setup_board(Intersection new_board[MAX_BOARD][MAX_BOARD], int
ko_pos,
                 int *last, float new_komi, int w_captured, int b_captured);



reply via email to

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