gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] GTP printsgf


From: Gunnar Farneback
Subject: [gnugo-devel] GTP printsgf
Date: Tue, 27 May 2003 00:12:28 +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)

A GTP printsgf command, essentially doing the same thing as the
--printsgf option, i.e. dumping a static sgf of the current position.

- new GTP command printsgf

/Gunnar

Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.117
diff -u -r1.117 play_gtp.c
--- interface/play_gtp.c        4 May 2003 11:20:00 -0000       1.117
+++ interface/play_gtp.c        26 May 2003 07:30:51 -0000
@@ -126,6 +126,7 @@
 DECLARE(gtp_playblack);
 DECLARE(gtp_playwhite);
 DECLARE(gtp_popgo);
+DECLARE(gtp_printsgf);
 DECLARE(gtp_captures);
 DECLARE(gtp_protocol_version);
 DECLARE(gtp_query_boardsize);
@@ -250,6 +251,7 @@
   {"owl_threaten_defense",    gtp_owl_threaten_defense},
   {"play",                   gtp_play},
   {"popgo",                          gtp_popgo},
+  {"printsgf",                       gtp_printsgf},
   {"orientation",            gtp_set_orientation},
   {"place_free_handicap",     gtp_place_free_handicap},
   {"protocol_version",        gtp_protocol_version},
@@ -3429,6 +3433,32 @@
 
   sgffile_enddump(filename);
   count_variations = 0;
+  return gtp_success("");
+}
+
+
+/* Function:  Dump the current position as a static sgf file
+ * Arguments: filename
+ * Fails:     missing filename
+ * Returns:   nothing
+ */
+static int
+gtp_printsgf(char *s)
+{
+  char filename[GTP_BUFSIZE];
+  int nread;
+  int next;
+  
+  nread = sscanf(s, "%s", filename);
+  if (nread < 1)
+    return gtp_failure("missing filename");
+
+  if (get_last_player() == EMPTY)
+    next = BLACK;
+  else
+    next = OTHER_COLOR(get_last_player());
+
+  sgffile_printsgf(next, filename);
   return gtp_success("");
 }
 




reply via email to

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