gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] arend_1_30.5: platform dependency in persistent reading ca


From: Arend Bayer
Subject: [gnugo-devel] arend_1_30.5: platform dependency in persistent reading cache
Date: Sat, 30 Mar 2002 19:13:46 +0100 (CET)

 - platform dependency resolved in store_persistent_reading_cache
 
Both Gunnar and the gcc-manual say that 'char' behaves compiler dependent,
either as signed char or as unsigned char.
The piece of code in store_persistent_reading_cache that is changed below
was not safe against this. In fact, when I compiled with -funsigned-char
(which makes gcc treat 'char' as 'unsigned char', which is opposite to the
default), I got an increase of reading nodes in owl.tst by 7%. After the
patch, I get an identical number of reading nodes when compiled with or
without -funsigned-char.

Arend


Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.54
diff -u -r1.54 reading.c
--- engine/reading.c    28 Mar 2002 19:42:52 -0000      1.54
+++ engine/reading.c    30 Mar 2002 17:45:27 -0000
@@ -6311,25 +6311,22 @@
       active[k] = 3;
   }
   
-  /* Add neighbors of active area so far. 
-   * By using -1 as mark in this step, the test for old marks is
-   * simplified.
-   */
+  /* Add neighbors of active area so far. */
   for (k = BOARDMIN; k < BOARDMAX; k++) {
     if (!ON_BOARD(k))
       continue;
     if (active[k] != 0) 
       continue;
-    if ((ON_BOARD(SOUTH(k)) && active[SOUTH(k)] > 0)
-       || (ON_BOARD(WEST(k)) && active[WEST(k)] > 0)
-       || (ON_BOARD(NORTH(k)) && active[NORTH(k)] > 0)
-       || (ON_BOARD(EAST(k)) && active[EAST(k)] > 0))
-      active[k] = -1;
+    if ((ON_BOARD(SOUTH(k)) && active[SOUTH(k)] > 0 && active[SOUTH(k)] < 4)
+       || (ON_BOARD(WEST(k)) && active[WEST(k)] > 0 && active[WEST(k)] < 4)
+       || (ON_BOARD(NORTH(k)) && active[NORTH(k)] > 0 && active[NORTH(k)] < 4)
+       || (ON_BOARD(EAST(k)) && active[EAST(k)] > 1 && active[EAST(k)] < 4))
+      active[k] = 4;
   }
 
   /* Also add the previously played stones to the active area. */
   for (r = 0; r < stackp; r++)
-    active[entry->stack[r]] = 4;
+    active[entry->stack[r]] = 5;
 
   for (k = BOARDMIN; k < BOARDMAX; k++) {
     if (!ON_BOARD(k))




reply via email to

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