gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Patch: GTP:worm_data:origin


From: Heikki Levanto
Subject: [gnugo-devel] Patch: GTP:worm_data:origin
Date: Sun, 27 Jan 2002 00:55:29 +0100
User-agent: Mutt/1.2.5i

Hi,

I am slowly starting my NN experiments, and found that I can get pretty far
with gtp, not touching the engine at all. Keeps things nice and clean. 

I would like to add a detail in the GTP: Currently worm_data returns either
the data for any given intersection, or all of them. I would add an option
to return all worm origins, excluding empty cavities. The following patch
does this. 

I may come up with more things I need through the gtp. Any objections to
adding commands or options like this? I suppose someone else may want to use
these too, although I can not say for what.

- Heikki


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 00:46:03 2002
@@ -2440,17 +2440,24 @@
   int j = -1;
   int m, n;
 
-  if (sscanf(s, "%*c") >= 0 && !gtp_decode_coord(s, &i, &j))
-    return gtp_failure(id, "invalid color or coordinate");
+
+  if (strstr(s,"origin"))
+    i=-2;
+  else
+    if (sscanf(s, "%*c") >= 0 && !gtp_decode_coord(s, &i, &j))
+      return gtp_failure(id, "invalid color or coordinate");
 
   examine_position(EMPTY, EXAMINE_WORMS);
 
   gtp_printid(id, GTP_SUCCESS);
   
   for (m = 0; m < board_size; m++)
-    for (n = 0; n < board_size; n++)
-      if (i == -1 || (m == i && n == j)) {
-       struct worm_data *w = &worm[POS(m, n)];
+    for (n = 0; n < board_size; n++) {
+      struct worm_data *w = &worm[POS(m, n)];
+      if (i == -1 || 
+         (m == i && n == j) ||
+         (i == -2 && w->origin == POS(m,n) && BOARD(m,n)!=EMPTY ) ) {
        gtp_print_vertex(m, n);
        gtp_printf(":\n");
        gtp_mprintf("color           %C\n",  w->color);
@@ -2475,7 +2482,7 @@
        gtp_printf("genus           %d\n",   w->genus);
        gtp_printf("inessential     %d\n",   w->inessential);
       }
-  
+    }
   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]