gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] IL returns


From: Paul Pogonyshev
Subject: [gnugo-devel] IL returns
Date: Tue, 10 Sep 2002 01:24:54 +0300

this patch adds IL tags back to output via --printsgf option. i added
a new function: sgffile_loadandprint().

Paul


Index: engine/sgffile.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/sgffile.c,v
retrieving revision 1.19
diff -u -r1.19 sgffile.c
--- engine/sgffile.c    9 Sep 2002 21:20:11 -0000       1.19
+++ engine/sgffile.c    9 Sep 2002 22:15:15 -0000
@@ -139,6 +139,33 @@
 
 
 /*
+ * sgffile_loadandprint adds the current board position as well as
+ * information about who is to play and illegal moves to the tree.
+ */
+
+void
+sgffile_loadandprint(SGFTree *tree, int next)
+{
+  int m, n;
+  char pos[3];
+  
+  sgffile_printboard(tree);
+  
+  if (next == EMPTY)
+    return;
+
+  sgfAddProperty(tree->lastnode, "PL", (next == WHITE ? "W" : "B"));
+
+  for (m = 0; m < board_size; ++m)
+    for (n = 0; n < board_size; ++n)
+      if (BOARD(m, n) == EMPTY && !is_legal(POS(m, n), next)) {
+       gg_snprintf(pos, 3, "%c%c", 'a' + n, 'a' + m);
+       sgfAddProperty(tree->lastnode, "IL", pos);
+      }
+}
+
+
+/*
  * sgffile_printboard adds the current board position to the tree.
  */
 
Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.63
diff -u -r1.63 gnugo.h
--- engine/gnugo.h      9 Sep 2002 21:20:11 -0000       1.63
+++ engine/gnugo.h      9 Sep 2002 22:15:23 -0000
@@ -476,6 +476,7 @@
 void sgffile_debuginfo(SGFNode *node, int value);
 void sgffile_output(SGFNode *root);
 
+void sgffile_loadandprint(SGFTree *tree, int next);
 void sgffile_printboard(SGFTree *tree);
 void sgffile_recordboard(SGFNode *node);
 
Index: interface/main.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/main.c,v
retrieving revision 1.46
diff -u -r1.46 main.c
--- interface/main.c    9 Sep 2002 21:20:11 -0000       1.46
+++ interface/main.c    9 Sep 2002 22:16:02 -0000
@@ -956,11 +956,11 @@
     else {
       if (mandated_color != EMPTY)
         gameinfo.to_move = mandated_color;
+
       sgftree.root->child = NULL;
       sgftreeSetLastNode(&sgftree, sgftree.root);
-      sgffile_printboard(&sgftree);
-      sgfAddProperty(sgftree.lastnode, "PL",
-        (gameinfo.to_move == WHITE ? "W" : "B"));
+      sgffile_loadandprint(&sgftree, gameinfo.to_move);
+
       writesgf(sgftree.root, printsgffile);
     }
     break;





reply via email to

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