gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] libboard and board.h


From: Gunnar Farneback
Subject: Re: [gnugo-devel] libboard and board.h
Date: Sat, 23 Aug 2003 17:02:04 +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)

Arend wrote:
> After discussing the patch with Gunnar on NNGS, I made one more
> version. Posted as arend_5_1.2c.
> 
> Changes this time:
> - WHITE_BORDER etc. got retired (we can just use WHITE/BLACK/...).
> [...]

There were two accidental color reversals in optics.c, causing seven
failures in ld_owl.tst (and a pass for nando:12). Fixed by the
appended patch.

Also the use of *_BORDER for unconditional status could in fact not
just be replaced by WHITE/BLACK. I have changed these to
WHITE_TERRITORY/BLACK_TERRITORY and included those in enum
dragon_status. Since those values are also used for final status by
the aftermath code I have changed it to use the enum and also included
the DAME value.

(Strictly speaking those values are intended for empty vertices and
not for dragons, but it works best to include them in enum
dragon_status.)

- bugfixes in optics.c
- unconditional_status in struct worm_data changed to enum dragon_status
- final_status in the aftermath code changed to use enum dragon_status
- enum dragon_status extended with BLACK_TERRITORY, WHITE_TERRITORY,
  and DAME

/Gunnar

Index: engine/aftermath.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/aftermath.c,v
retrieving revision 1.43
diff -u -r1.43 aftermath.c
--- engine/aftermath.c  18 Jul 2003 18:59:21 -0000      1.43
+++ engine/aftermath.c  23 Aug 2003 14:56:57 -0000
@@ -1035,7 +1035,7 @@
  * Possible results are ALIVE, DEAD, ALIVE_IN_SEKI, WHITE_TERRITORY,
  * BLACK_TERRITORY, and DAME.
  */
-int
+enum dragon_status
 aftermath_final_status(int color, int pos)
 {
   ASSERT_ON_BOARD1(pos);
Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.101
diff -u -r1.101 gnugo.h
--- engine/gnugo.h      10 Aug 2003 17:56:50 -0000      1.101
+++ engine/gnugo.h      23 Aug 2003 14:56:57 -0000
@@ -78,11 +78,6 @@
 #define SURROUNDED 1
 #define WEAKLY_SURROUNDED 2
 
-/* Final statuses for empty vertices. */
-#define BLACK_TERRITORY 13
-#define WHITE_TERRITORY 14
-#define DAME            15
-
 /* ================================================================ */
 /*                        Board manipulation                        */
 /* ================================================================ */
@@ -360,7 +355,7 @@
 
 /* Play through the aftermath. */
 float aftermath_compute_score(int color, float komi, SGFTree *tree);
-int aftermath_final_status(int color, int pos);
+enum dragon_status aftermath_final_status(int color, int pos);
 
 /* Basic information gathering. */
 /* worm.c */
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.199
diff -u -r1.199 liberty.h
--- engine/liberty.h    15 Aug 2003 07:21:22 -0000      1.199
+++ engine/liberty.h    23 Aug 2003 14:56:58 -0000
@@ -103,6 +103,51 @@
 const char *routine_id_to_string(enum routine_id routine);
 
 
+/* This is used for both the dragon status and safety fields.
+ * Also used for unconditional status in struct worm_data and for the
+ * final status computed by the aftermath code.
+ */
+enum dragon_status {
+  DEAD,
+  ALIVE,
+  CRITICAL,
+  UNKNOWN,
+  UNCHECKED,
+  CAN_THREATEN_ATTACK,
+  CAN_THREATEN_DEFENSE, 
+  INESSENTIAL,
+  TACTICALLY_DEAD,
+  ALIVE_IN_SEKI,
+  STRONGLY_ALIVE,
+  INVINCIBLE,
+  INSUBSTANTIAL,
+  WHITE_TERRITORY,
+  BLACK_TERRITORY,
+  DAME,
+  NUM_DRAGON_STATUS
+};
+
+#define DRAGON_STATUS_NAMES \
+  "dead", \
+  "alive", \
+  "critical", \
+  "unknown", \
+  "unchecked", \
+  "can threaten attack", \
+  "can threaten defense", \
+  "inessential", \
+  "tactically dead", \
+  "alive in seki", \
+  "strongly alive", \
+  "invincible", \
+  "insubstantial", \
+  "white_territory", \
+  "black_territory", \
+  "dame"
+
+const char *status_to_string(enum dragon_status status);
+
+
 /* Forward struct declarations. */
 struct pattern;
 struct pattern_db;
@@ -738,7 +783,8 @@
   int genus;         /* number of connected components of the complement, less 
one */
   int inessential;   /* 1=inessential worm */
   int invincible;    /* 1=strongly unconditionally non-capturable */
-  int unconditional_status; /* ALIVE, DEAD, WHITE_BORDER, BLACK_BORDER, 
UNKNOWN */
+  enum dragon_status unconditional_status; /* ALIVE, DEAD, WHITE_TERRITORY,
+                                             BLACK_TERRITORY, UNKNOWN */
 
   /* The following arrays keeps track of up to MAX_TACTICAL_POINTS
    * different attack, defense, attack threat, and defense threat
@@ -775,41 +821,6 @@
  * data concerning a dragon. A copy is kept at each stone of the string.
  */
 
-/* This is used for both the dragon status and safety fields. */
-enum dragon_status {
-  DEAD,
-  ALIVE,
-  CRITICAL,
-  UNKNOWN,
-  UNCHECKED,
-  CAN_THREATEN_ATTACK,
-  CAN_THREATEN_DEFENSE, 
-  INESSENTIAL,
-  TACTICALLY_DEAD,
-  ALIVE_IN_SEKI,
-  STRONGLY_ALIVE,
-  INVINCIBLE,
-  INSUBSTANTIAL,
-  NUM_DRAGON_STATUS
-};
-
-#define DRAGON_STATUS_NAMES \
-  "dead", \
-  "alive", \
-  "critical", \
-  "unknown", \
-  "unchecked", \
-  "can threaten attack", \
-  "can threaten defense", \
-  "inessential", \
-  "tactically dead", \
-  "alive in seki", \
-  "strongly alive", \
-  "invincible", \
-  "insubstantial"
-
-const char *status_to_string(enum dragon_status status);
-
 struct dragon_data {
   int color;    /* its color                                                 */
   int id;       /* the index into the dragon2 array                          */
@@ -908,7 +919,7 @@
   int black_area;
   int white_control[BOARDMAX];
   int black_control[BOARDMAX];
-  int final_status[BOARDMAX];
+  enum dragon_status final_status[BOARDMAX];
 };
 
 struct eye_data {
Index: engine/optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.81
diff -u -r1.81 optics.c
--- engine/optics.c     10 Aug 2003 17:56:50 -0000      1.81
+++ engine/optics.c     23 Aug 2003 14:57:00 -0000
@@ -859,7 +859,7 @@
 
     /* A single point eye which is part of a ko can't be trusted. */
     if (eye[pos].esize == 1
-       && is_ko(pos, eye[pos].color, NULL))
+       && is_ko(pos, OTHER_COLOR(eye[pos].color), NULL))
       *pessimistic_min = 0;
 
     DEBUG(DEBUG_EYES, "  graph matching - %s, pessimistic_min=%d\n",
@@ -915,7 +915,7 @@
          this_attack_point = pos2;
          this_defense_point = pos2;
 
-         if (is_self_atari(pos2, eye[pos].color))
+         if (is_self_atari(pos2, OTHER_COLOR(eye[pos].color)))
            this_score -= 0.5;
          
          if (is_edge_vertex(pos2))
Index: engine/worm.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/worm.c,v
retrieving revision 1.57
diff -u -r1.57 worm.c
--- engine/worm.c       10 Aug 2003 17:56:51 -0000      1.57
+++ engine/worm.c       23 Aug 2003 14:57:01 -0000
@@ -703,8 +703,12 @@
        if (unconditional_territory[pos] == 1)
          worm[pos].invincible = 1;
       }
-      else if (board[pos] == EMPTY)
-       worm[pos].unconditional_status = WHITE;
+      else if (board[pos] == EMPTY) {
+       if (color == WHITE)
+         worm[pos].unconditional_status = WHITE_TERRITORY;
+       else
+         worm[pos].unconditional_status = BLACK_TERRITORY;
+      }
       else
        worm[pos].unconditional_status = DEAD;
     }
@@ -1851,12 +1855,8 @@
   else
     gprintf("invincible: NO, \n");
 
-  if (worm[pos].unconditional_status == ALIVE)
-    gprintf("unconditional status ALIVE\n");
-  else if (worm[pos].unconditional_status == DEAD)
-    gprintf("unconditional status DEAD\n");
-  else if (worm[pos].unconditional_status == UNKNOWN)
-    gprintf("unconditional status UNKNOWN\n");
+  gprintf("unconditional status %s\n",
+         status_to_string(worm[pos].unconditional_status));
 }
 
 
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.129
diff -u -r1.129 play_gtp.c
--- interface/play_gtp.c        12 Aug 2003 21:26:48 -0000      1.129
+++ interface/play_gtp.c        23 Aug 2003 14:57:03 -0000
@@ -2821,9 +2847,10 @@
  ***********/
 
 static float final_score;
-static int final_status[MAX_BOARD][MAX_BOARD];
-static int status_numbers[6] = {ALIVE, DEAD, ALIVE_IN_SEKI, WHITE_TERRITORY,
-                               BLACK_TERRITORY, DAME};
+static enum dragon_status final_status[MAX_BOARD][MAX_BOARD];
+static enum dragon_status status_numbers[6] = {ALIVE, DEAD, ALIVE_IN_SEKI,
+                                              WHITE_TERRITORY,
+                                              BLACK_TERRITORY, DAME};
 static const char *status_names[6] = {"alive", "dead", "seki",
                                      "white_territory", "black_territory",
                                      "dame"};
@@ -3038,7 +3065,7 @@
   int seed;
   int n;
   int i, j;
-  int status = UNKNOWN;
+  enum dragon_status status = UNKNOWN;
   int k;
   char status_string[GTP_BUFSIZE];
   int first;




reply via email to

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