gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] unsigned char bug in optics.c


From: Arend Bayer
Subject: [gnugo-devel] unsigned char bug in optics.c
Date: Thu, 23 Jan 2003 19:46:30 +0100 (CET)


These lines in optics.c are buggy on platforms where char is unsigned
(easily tested by using gcc -funsigned-char):

  /* Look up the eye space in the graphs database. */
  if (read_eye(pos, attack_point, defense_point, value,
               eye, heye, 0, EMPTY)) {
    *pessimistic_min = min_eyes(value) - margins;

(pessimistic_min is a char).

Clearly there is no need to space-optimize at this level, so the patch
below just converts pessimistic_min to an int everywhere. (min_eyes() returns
an int anyway, btw.)

Arend



Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.150.2.5
diff -u -p -r1.150.2.5 liberty.h
--- engine/liberty.h    22 Jan 2003 07:19:46 -0000      1.150.2.5
+++ engine/liberty.h    23 Jan 2003 18:44:10 -0000
@@ -987,7 +987,7 @@ void compute_eyes(int pos, struct eyeval
                   struct half_eye_data heye[BOARDMAX],
                   int add_moves, int color);
 void compute_eyes_pessimistic(int pos, struct eyevalue *value,
-                              char *pessimistic_min,
+                              int *pessimistic_min,
                               int *attack_point, int *defense_point,
                               struct eye_data eye[BOARDMAX],
                               struct half_eye_data heye[BOARDMAX]);
Index: engine/optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.63.2.1
diff -u -p -r1.63.2.1 optics.c
--- engine/optics.c     4 Jan 2003 19:59:39 -0000       1.63.2.1
+++ engine/optics.c     23 Jan 2003 18:44:12 -0000
@@ -67,7 +67,7 @@ static int recognize_eye(int pos, int *a
                         struct vital_points *vp);
 static void guess_eye_space(int pos, int effective_eyesize, int margins,
                            struct eye_data eye[BOARDMAX],
-                           struct eyevalue *value, char *pessimistic_min);
+                           struct eyevalue *value, int *pessimistic_min);
 static void reset_map(int size);
 static void first_map(int* map_value);
 static int next_map(int *q, int map[MAXEYE]);
@@ -804,7 +804,7 @@ compute_eyes(int pos, struct eyevalue *v
  */
 void
 compute_eyes_pessimistic(int pos, struct eyevalue *value,
-                        char *pessimistic_min,
+                        int *pessimistic_min,
                         int *attack_point, int *defense_point,
                         struct eye_data eye[BOARDMAX],
                         struct half_eye_data heye[BOARDMAX])
@@ -961,7 +961,7 @@ compute_eyes_pessimistic(int pos, struct
 static void
 guess_eye_space(int pos, int effective_eyesize, int margins,
                struct eye_data eye[BOARDMAX],
-               struct eyevalue *value, char *pessimistic_min)
+               struct eyevalue *value, int *pessimistic_min)
 {
   if (effective_eyesize > 3) {
     set_eyevalue(value, 2, 2, 2, 2);
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.135.2.4
diff -u -p -r1.135.2.4 owl.c
--- engine/owl.c        22 Jan 2003 05:20:15 -0000      1.135.2.4
+++ engine/owl.c        23 Jan 2003 18:44:17 -0000
@@ -2362,7 +2362,7 @@ owl_determine_life(struct local_owl_data
   /* FIXME: use MAX_EYES from move_reasons.h ? */
   struct eyevalue eyevalue_list[BOARDMAX/2];
   int eyes_attack_points[BOARDMAX/2];
-  char pessimistic_min;
+  int pessimistic_min;
   int attack_point;
   int defense_point;
   int m, n;





reply via email to

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