gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] platform dependency fix


From: Gunnar Farnebäck
Subject: [gnugo-devel] platform dependency fix
Date: Fri, 10 Sep 2004 02:33:45 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI)

In C the type "char" may be either signed or unsigned, at the compiler
implementor's discretion. With gcc char is by default signed but it's
possible to change it to use unsigned with the flag -funsigned-char.
This turns up a difference in reading node consumption, which
shouldn't be there.

The problem turned out to be in the code to mark relevant eyespaces in
owl_determine_life(). Changing some (occasionally overflowing) char
arrays into int arrays solves it.

After this patch the node counts for the full regressions are
identical with signed and unsigned chars. There is one failed test
case, trevor:410, but I don't know whether that's already in CVS (3.6
branch).

- use int arrays instead of char arrays to mark eyes in
  owl_determine_life() and dependent functions

/Gunnar

Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.221.2.1
diff -u -r1.221.2.1 liberty.h
--- engine/liberty.h    29 Aug 2004 02:31:38 -0000      1.221.2.1
+++ engine/liberty.h    9 Sep 2004 15:07:56 -0000
@@ -1022,7 +1022,7 @@
 void partition_eyespaces(struct eye_data eye[BOARDMAX], int color);
 void find_half_and_false_eyes(int color, struct eye_data eye[BOARDMAX],
                              struct half_eye_data heye[BOARDMAX],
-                             char find_mask[BOARDMAX]);
+                             int find_mask[BOARDMAX]);
 
 void set_eyevalue(struct eyevalue *e, int a, int b, int c, int d);
 int min_eye_threat(struct eyevalue *e);
Index: engine/optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.93
diff -u -r1.93 optics.c
--- engine/optics.c     8 Jul 2004 15:59:24 -0000       1.93
+++ engine/optics.c     9 Sep 2004 15:07:56 -0000
@@ -1703,7 +1703,7 @@
 void
 find_half_and_false_eyes(int color, struct eye_data eye[BOARDMAX],
                         struct half_eye_data heye[BOARDMAX],
-                        char find_mask[BOARDMAX])
+                        int find_mask[BOARDMAX])
 {
   int eye_color = color;
   int pos;
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.217
diff -u -r1.217 owl.c
--- engine/owl.c        20 Aug 2004 15:16:05 -0000      1.217
+++ engine/owl.c        9 Sep 2004 15:07:57 -0000
@@ -189,7 +189,7 @@
                               struct eyevalue *probable_eyes,
                               int *eyemin, int *eyemax);
 static void owl_find_relevant_eyespaces(struct local_owl_data *owl,
-                                       char mw[BOARDMAX], char mz[BOARDMAX]);
+                                       int mw[BOARDMAX], int mz[BOARDMAX]);
 static int owl_estimate_life(struct local_owl_data *owl,
                             struct local_owl_data *second_owl,
                             struct owl_move_data vital_moves[MAX_MOVES],
@@ -1365,8 +1365,8 @@
 {
   int color = OTHER_COLOR(owlb->color);
   int pos;
-  char mw[BOARDMAX];
-  char mz[BOARDMAX];
+  int mw[BOARDMAX];
+  int mz[BOARDMAX];
 
   owl_find_relevant_eyespaces(owlb, mw, mz);
 
@@ -2883,8 +2883,8 @@
 {
   int color = owl->color;
   struct eye_data *eye = owl->my_eye;
-  char mw[BOARDMAX];  /* mark relevant eye origins */
-  char mz[BOARDMAX];  /* mark potentially irrelevant eye origins */
+  int mw[BOARDMAX];  /* mark relevant eye origins */
+  int mz[BOARDMAX];  /* mark potentially irrelevant eye origins */
   int vital_values[BOARDMAX];
   int dummy_eyemin = 0;
   int dummy_eyemax = 0;
@@ -3238,7 +3238,7 @@
 
 static void
 owl_find_relevant_eyespaces(struct local_owl_data *owl,
-                           char mw[BOARDMAX], char mz[BOARDMAX])
+                           int mw[BOARDMAX], int mz[BOARDMAX])
 {
   int pos;
   int eye_color;




reply via email to

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