gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] debugboard reparation


From: Gunnar Farneback
Subject: [gnugo-devel] debugboard reparation
Date: Mon, 26 May 2003 23:56:15 +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)

This patch repairs debugboard so that it once more compiles and can be
used to some extent. Apparently it hasn't been missed all that much
during the more than a year (since before 3.2 was released) that it
hasn't worked at all, but I thought it should be fixed anyway.

This patch does not update the information shown to match the current
contents of the data structures. I'll leave that to someone who
actually plans to use debugboard (and feels familiar with curses).

- debugboard repaired

/Gunnar

Index: interface/debugboard/gui.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/debugboard/gui.c,v
retrieving revision 1.21
diff -u -r1.21 gui.c
--- interface/debugboard/gui.c  26 Sep 2002 20:28:09 -0000      1.21
+++ interface/debugboard/gui.c  26 May 2003 21:46:37 -0000
@@ -223,8 +223,18 @@
 void
 display_dragon(int pos)
 {
-  struct dragon_data *d = &dragon[pos];
-  struct dragon_data2 *d2 = &(dragon2[d->id]);
+  struct dragon_data *d;
+  struct dragon_data2 *d2;
+
+  /* FIXME: We should clear the old entries here rather than just
+   * returning when called on an empty vertex. We can't continue now,
+   * however, since we may crash on bad field values.
+   */
+  if (board[pos] == EMPTY)
+    return;
+    
+  d = &dragon[pos];
+  d2 = &(dragon2[d->id]);
   wmove(info_window, 1, 2);
   gg_wprintw(info_window, "%3s: %5s dragon ",
             location_to_string(pos), color_to_string(d->color));
@@ -264,38 +274,38 @@
 
   /* owl status */
   wmove(info_window, 4, 55);
-  gg_wprintw(info_window, "%-12s", status_to_string(d->owl_status));
-  if (d->owl_attack_point == NO_MOVE)
+  gg_wprintw(info_window, "%-12s", status_to_string(d2->owl_status));
+  if (d2->owl_attack_point == NO_MOVE)
     gg_wprintw(info_window, "[---] ");
   else
     gg_wprintw(info_window, "[%3s] ",
-              location_to_string(d->owl_attack_point));
-  if (d->owl_defense_point == NO_MOVE)
+              location_to_string(d2->owl_attack_point));
+  if (d2->owl_defense_point == NO_MOVE)
     gg_wprintw(info_window, "[---] ");
   else
     gg_wprintw(info_window, "[%3s] ",
-              location_to_string(d->owl_defense_point));
+              location_to_string(d2->owl_defense_point));
 
   wmove(info_window, 5, 55);
-  switch (d->owl_threat_status) {
+  switch (d2->owl_threat_status) {
   case DEAD:
   case ALIVE:
     gg_wprintw(info_window, "%-12s[---] [---]", 
-              status_to_string(d->owl_threat_status));
+              status_to_string(d2->owl_threat_status));
     break;
   case UNCHECKED:
     gg_wprintw(info_window, "unchecked   [---] [---]");
     break;
   case CAN_THREATEN_ATTACK:
     gg_wprintw(info_window, "att. threat [%3s] [---]",
-              location_to_string(d->owl_second_attack_point));
+              location_to_string(d2->owl_second_attack_point));
     break;
   case CAN_THREATEN_DEFENSE:
     gg_wprintw(info_window, "def. threat [---] [%3s]",
-              location_to_string(d->owl_second_defense_point));
+              location_to_string(d2->owl_second_defense_point));
     break;
   default:
-    gg_wprintw(info_window, "Error: %3d  [---] [---]", d->owl_threat_status);
+    gg_wprintw(info_window, "Error: %3d  [---] [---]", d2->owl_threat_status);
     break;
   }
 
Index: interface/debugboard/main.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/debugboard/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- interface/debugboard/main.c 20 Oct 2002 10:58:22 -0000      1.11
+++ interface/debugboard/main.c 26 May 2003 21:46:37 -0000
@@ -54,7 +54,6 @@
 #include "gnugo.h"
 #include "sgftree.h"
 #include "interface.h"
-#include "random.h"
 
 #include "display.h"
 #include "gui.h"
@@ -116,17 +115,17 @@
   fusekidb = 1;
   josekidb = 1;
   
-  gameinfo_clear(&gameinfo, 19, 5.5);
-  next = gameinfo_play_sgftree(&gameinfo, &sgftree, until);
-
-
   /* Check if there is enough screen space. */
   if (!display_init(MINWIDTH, MINHEIGHT, board_size))
     exit(1);
 
   /* Initialize the GNU Go engine. */
-  gg_srand(time(0));
-  init_gnugo(8);
+  init_gnugo(8, time(0));
+
+  gameinfo_clear(&gameinfo, 19, 5.5);
+  next = gameinfo_play_sgftree(&gameinfo, &sgftree, until);
+
+
   reset_engine();
 
   display_message("Hit 'h' for help!");




reply via email to

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