gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] improving bug reports


From: Gunnar Farnebäck
Subject: [gnugo-devel] improving bug reports
Date: Wed, 09 Jun 2004 03:49:37 +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)

It has occured to me that the assertion failure reports we get tend to
be less helpful than they need to be. I have in particular two things
on my mind:

1. The long sequence of boards while unwinding the trymove stack is
almost never useful. The top and bottom positions can be valuable but
the intermediate ones are just an annoyance. We already have the
dump_stack() output so if they really are needed they can be
reconstructed. Removing these reduces the amount of copy and pasting
people have to do and the risk that the start of the debug output gets
truncated.

2. Frequently people cannot save the position as sgf or forgets to
include it in the mail. This is completely unnecessary since we now
(from 3.1.28) have the move history available in the board code. The
obvious solution is to just print an sgf in the debug output.

The patch below removes all board output except at the top of the
stack and writes an sgf of the game up to the bottom of the stack.

- new static function dump_board_sgf() in printutils.c
- abortgo() revised to no longer unwind the stack and to print an sgf
  of the move history

/Gunnar

Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.110
diff -u -r1.110 gnugo.h
--- engine/gnugo.h      8 Jun 2004 05:06:12 -0000       1.110
+++ engine/gnugo.h      9 Jun 2004 01:41:49 -0000
@@ -284,7 +284,6 @@
 void draw_char(int m, int n, int c);
 void end_draw_board(void);
 void showboard(int xo);  /* ascii rep. of board to stderr */
-void simple_showboard(FILE *outfile);  /* ascii rep. of board to outfile */
 
 double gg_gettimeofday(void);
 
Index: engine/printutils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v
retrieving revision 1.46
diff -u -r1.46 printutils.c
--- engine/printutils.c 3 Jun 2004 18:49:42 -0000       1.46
+++ engine/printutils.c 9 Jun 2004 01:41:50 -0000
@@ -209,6 +209,58 @@
   va_end(ap);
 }
 
+/* This writes the move history information in sgf format to stderr.
+ * This is only attended as a stand-alone debug tool for use in
+ * abortgo(). Anywhere else you should use the normal sgf library.
+ */
+static void
+dump_board_sgf(void)
+{
+  int pos;
+  int initial_colors_found = EMPTY;
+  int color;
+  int k;
+
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++)
+    if (ON_BOARD(pos))
+      initial_colors_found |= initial_board[pos];
+  
+  fprintf(stderr, "(;GM[1]FF[4]SZ[%d]KM[%.1f]GN[GNU Go %s stepped on a bug]\n",
+         board_size, komi, gg_version());
+
+  for (color = WHITE; color <= BLACK; color++) {
+    if (initial_colors_found & color) {
+      fprintf(stderr, "A%s", color == WHITE ? "W" : "B");
+      for (k = 0, pos = BOARDMIN; pos < BOARDMAX; pos++) {
+       if (ON_BOARD(pos) && initial_board[pos] == color) {
+         fprintf(stderr, "[%c%c]", 'a' + J(pos), 'a' + I(pos));
+         k++;
+         if (k % 16 == 0)
+           fprintf(stderr, "\n");
+       }
+      }
+      if (k % 16 != 0)
+       fprintf(stderr, "\n");
+    }
+  }
+
+  if (move_history_pointer > 0) {
+    for (k = 0; k < move_history_pointer; k++) {
+      fprintf(stderr, ";%s", move_history_color[k] == WHITE ? "W" : "B");
+      if (move_history_pos[k] == PASS_MOVE)
+       fprintf(stderr, "[]");
+      else
+       fprintf(stderr, "[%c%c]", 'a' + J(move_history_pos[k]),
+               'a' + I(move_history_pos[k]));
+      
+      if (k % 12 == 11)
+       fprintf(stderr, "\n");
+    }
+    if (k % 12 != 0)
+      fprintf(stderr, "\n");
+  }
+  fprintf(stderr, ")\n");
+}
 
 /*
  * A wrapper around abort() which shows the state variables at the time
@@ -222,27 +274,18 @@
          file, line, msg, pos);
   dump_stack();
 
-  /* Dump the stack as board images. */
+  /* Print the board at the top of the stack. */
   simple_showboard(stderr);
-  while (stackp > 0) {
-    popgo();
-    simple_showboard(stderr);
-  }
+  fprintf(stderr, "\n");
 
-#if 0
-  if (sgf_root) {
-    sgf_write_header(sgf_root, 1, get_random_seed()
-                    komi, level, chinese_rules);
-    writesgf(sgf_root, "abortgo.sgf");
-  }
-#endif
+  dump_board_sgf();
 
-  fprintf(stderr, "\ngnugo %s (seed %d): You stepped on a bug.\n",
+  fprintf(stderr, "gnugo %s (seed %d): You stepped on a bug.\n",
           gg_version(), get_random_seed());
   if (board_size >= 9 && board_size <= 19) {
     fprintf(stderr, "\
-Please save this game as an sgf file and mail it to address@hidden
-If you can, please also include the debug output above this message.\n");
+Please mail this message, including the debug output above, \
+to address@hidden");
   }
   fprintf(stderr, "\n");
 




reply via email to

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