gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] GTP extension for passive GUI


From: Gunnar Farneback
Subject: Re: [gnugo-devel] GTP extension for passive GUI
Date: Tue, 27 Nov 2001 20:14:34 +0100
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)

Tanguy wrote:
> this patch add a new GTP command "dump <info>" to facilitate
> the implementation of a "passive" GUI in the same spirit as SDL Go.

>From the patch:
> The dump function allow to implement
> a "passive" GUI. and allow to collect many informations
> to display.
> The format is near from pattern.db format.
> It should be usefull for Gothic.

If you want much information, this format seems very limited. Also I'm
not sure I understand why a program would want to communicate with
this kind of format in the first place.

> +/* Function:  dump informations about the board
> + *            in the following format:
> + *
> + *            +----+
> + *            |$$$$|
> + *            |$$$$|
> + *            |$$$$|
> + *            +----+
> + *
> + * Where '$' are ascii symbols with different meanings.
> + * Supported formats: "board" and "dragons".
> + *
> + * Arguments: name of format used
> + * Fails:     invalid argument
> + * Returns:   dump the board.
> + *
> + *
> + * "board" format:
> + * ---------------
> + * '.' is legal move,
> + * 'X' is black
> + * 'O' is white
> + * 'x' is legal only for black
> + * 'o' is legal only for white
> + * (A move cannot be illegal for both)

"all_legal" should suffice to obtain the legal moves. Appended to this
message is a patch adding a command "list_stones" which makes it more
convenient to get all stones on the board.

> + *
> + * "dragons" format:
> + * -----------------
> + * '.' is empty
> + * '?' if gnugo don't know (or is not up to date)
> + * An alphabetic symbol for each dragon otherwise.

This is limited to 26 dragons. Granted that so many dragons are very
rare it seems unnecessary to impose the limitation. Why not use
"dragon_stones" instead?

> + *
> + * "life" format:
> + * --------------
> + * '.' for empty
> + * '?' if gnugo don't know (or is not up to date)
> + * 'a' for alive
> + * 'd' for dead.

You also want to identify critical dragons, know the safety values,
the various distinct status values and so on. Why not use "dragon_data"?

> + *
> + * "moyo" format: (not yet implemented)
> + * --------------
> + * '?' for unknown 
> + * 'X' for true black territory, black stone or white prisonier
> + * 'O' for true white territory, white stone or black prisonier
> + * 'x' for black moyo
> + * 'o' for white moyo
> + * '.' for neutral area
> + */

Besides territory and moyo there's also something called area. For
debugging purposes one would also want to know the numerical values of
the influence function. The "influence" command gives some relevant
data, but could certainly need improvement.

> +  if (!strncmp(s, "board", 5)) {
> +    dump_line();
> +    for(x=0; x != board_size; x++)
> +      {
> +       gtp_printf("|");
> +       for(y=0; y != board_size; y++)
> +         gtp_printf("%c",board_format(x,y));
> +       gtp_printf("|\n");
> +      }
> +    dump_line();
> +    return gtp_success(id, "%s", s);

This gives a malformed response. See e.g. gtp_influence() for how to
deal with complex output.

> I propose to do a major cleanup of the GTP protocol
> to set a new GTP V3.0
> Suggestions ?

I suggest not paying much attention to the drafts for version 2 at
this time. The docs and source in GNU Go are still better sources of
information.

/Gunnar

Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.50
diff -u -r1.50 play_gtp.c
--- interface/play_gtp.c        2001/11/25 11:23:40     1.50
+++ interface/play_gtp.c        2001/11/27 19:11:19
@@ -101,6 +101,7 @@
 DECLARE(gtp_increase_depths);
 DECLARE(gtp_influence);
 DECLARE(gtp_is_legal);
+DECLARE(gtp_list_stones);
 DECLARE(gtp_loadsgf);
 DECLARE(gtp_name);
 DECLARE(gtp_new_game);
@@ -185,6 +186,7 @@
   {"is_legal",                       gtp_is_legal},
   {"komi",                   gtp_set_komi},
   {"level",                  gtp_set_level},
+  {"list_stones",            gtp_list_stones},
   {"loadsgf",                        gtp_loadsgf},
   {"name",                    gtp_name},
   {"new_game",                gtp_new_game},
@@ -597,6 +599,36 @@
     return gtp_failure(id, "invalid coordinate");
   
   return gtp_success(id, color_to_string(BOARD(i, j)));
+}
+
+
+/* Function:  List vertices with either black or white stones.
+ * Arguments: color
+ * Fails:     invalid color
+ * Returns:   list of vertices
+ */
+static int
+gtp_list_stones(char *s, int id)
+{
+  int i, j;
+  int color = EMPTY;
+  int vertexi[MAX_BOARD * MAX_BOARD];
+  int vertexj[MAX_BOARD * MAX_BOARD];
+  int vertices = 0;
+  
+  if (!gtp_decode_color(s, &color))
+    return gtp_failure(id, "invalid color");
+
+  for (i = 0; i < board_size; i++)
+    for (j = 0; j < board_size; j++)
+      if (BOARD(i, j) == color) {
+       vertexi[vertices] = i;
+       vertexj[vertices++] = j;
+      }
+
+  gtp_printid(id, GTP_SUCCESS);
+  gtp_print_vertices(vertices, vertexi, vertexj);
+  return gtp_finish_response();
 }
 
 



reply via email to

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