gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Re: Patch: GTP:worm_origins


From: Heikki Levanto
Subject: [gnugo-devel] Re: Patch: GTP:worm_origins
Date: Sun, 27 Jan 2002 19:27:43 +0100
User-agent: Mutt/1.2.5i

On Sun, Jan 27, 2002 at 06:24:58PM +0100, Gunnar Farneback wrote:

> The output of worm stones looks like below:
[...] 
> This gives one worm per line, starting with each origin. 

I had missed the detail that the output starts with the origins. So I agree,
I will use worm_stones instead.

worm_stones has one problem: When there are no stones (as in the beginning
of the game), it does not output the final newline.  (I assume all command
outputs are to end with a blank line - correct me if that is wrong)

Here is a patch that superceeds all my earlier patches about gtp.

* GTP: Adds missing newline in worm_stones when no stones to list
* GTP: New command get_komi
* GTP: New command get_handicap


diff -ruN gnugo-ref/interface/play_gtp.c gnugo-work/interface/play_gtp.c
--- gnugo-ref/interface/play_gtp.c      Thu Dec 20 20:54:16 2001
+++ gnugo-work/interface/play_gtp.c     Sun Jan 27 19:19:10 2002
@@ -91,6 +91,7 @@
 DECLARE(gtp_findlib);
 DECLARE(gtp_finish_sgftrace);
 DECLARE(gtp_fixed_handicap);
+DECLARE(gtp_get_handicap);
 DECLARE(gtp_genmove);
 DECLARE(gtp_genmove_black);
 DECLARE(gtp_genmove_white);
@@ -136,6 +137,7 @@
 DECLARE(gtp_set_boardsize);
 DECLARE(gtp_set_orientation);
 DECLARE(gtp_set_komi);
+DECLARE(gtp_get_komi);
 DECLARE(gtp_set_level);
 DECLARE(gtp_showboard);
 DECLARE(gtp_start_sgftrace);
@@ -182,6 +185,7 @@
   {"findlib",                        gtp_findlib},
   {"finish_sgftrace",                gtp_finish_sgftrace},
   {"fixed_handicap",                 gtp_fixed_handicap},
+  {"get_handicap",           gtp_get_handicap},
   {"genmove_black",           gtp_genmove_black},
   {"genmove_white",           gtp_genmove_white},
   {"get_connection_node_counter", gtp_get_connection_node_counter},
@@ -195,6 +199,7 @@
   {"influence",               gtp_influence},
   {"is_legal",                       gtp_is_legal},
   {"komi",                   gtp_set_komi},
+  {"get_komi",               gtp_get_komi},
   {"level",                  gtp_set_level},
   {"list_stones",            gtp_list_stones},
   {"loadsgf",                        gtp_loadsgf},
@@ -423,24 +429,40 @@
 }
 
 /***************************
  * Setting komi.           *
  ***************************/
 
 /* Function:  Set the komi.
  * Arguments: float
  * Fails:     incorrect argument
  * Returns:   nothing
  */
 static int
 gtp_set_komi(char *s, int id)
 {
   if (sscanf(s, "%f", &komi) < 1)
     return gtp_failure(id, "komi not a float");
   
   return gtp_success(id, "");
 }
 
 
+/***************************
+ * Getting komi            *
+ ***************************/
+
+/* Function:  Get the komi
+ * Arguments: none
+ * Fails:     never
+ * Returns:   Komi 
+ */
+static int
+gtp_get_komi(char *s, int id)
+{
+  UNUSED(s);
+  return gtp_success(id, "%4.1f",komi);
+}
+
 /******************
  * Playing moves. *
  ******************/
@@ -548,6 +570,18 @@
 }
 
 
+/* Function:  Get the handicap
+ * Arguments: none
+ * Fails:     never
+ * Returns:   handicap
+ */
+static int
+gtp_get_handicap(char *s, int id)
+{
+  s=s; /* compiler shut up */
+  return gtp_success(id, "%d", handicap);
+}
+
 /* Function:  Load an sgf file, possibly up to a move number or the first
  *            occurence of a move.           
  * Arguments: filename + move number, vertex, or nothing
@@ -2491,7 +2530,7 @@
   int i = -1;
   int j = -1;
   int color = EMPTY;
-  int m, n;
+  int m, n=0;
   int u, v;
 
   if (sscanf(s, "%*c") >= 0) {
@@ -2523,11 +2562,42 @@
       gtp_printf("\n");
     }
   
+  if (!n) gtp_printf("\n"); /* in case no stones have been printed */ 
   gtp_printf("\n");
   return GTP_OK;
 }
 
 



-- 
Heikki Levanto  LSD - Levanto Software Development   <address@hidden>




reply via email to

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