[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] Patch: GTP:worm_origins
From: |
Heikki Levanto |
Subject: |
Re: [gnugo-devel] Patch: GTP:worm_origins |
Date: |
Sun, 27 Jan 2002 01:32:25 +0100 |
User-agent: |
Mutt/1.2.5i |
I withdraw the previous patch, I didn't like the solution. Here is an
improved version that adds a command worm_origins to the gtp. It can be
used without argument, or with black/white. It lists all the origin stones
for (non-empty) worms of the given color.
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 01:27:47 2002
@@ -151,6 +151,7 @@
DECLARE(gtp_worm_cutstone);
DECLARE(gtp_worm_data);
DECLARE(gtp_worm_stones);
+DECLARE(gtp_worm_origins);
/* List of known commands. */
static struct gtp_command commands[] = {
@@ -238,6 +239,7 @@
{"worm_cutstone", gtp_worm_cutstone},
{"worm_data", gtp_worm_data},
{"worm_stones", gtp_worm_stones},
+ {"worm_origins", gtp_worm_origins},
{NULL, NULL}
};
+/* Function: List the origins of worms
+ * Arguments: none or "BLACK" or "WHITE"
+ * Fails: never
+ * Returns: list of stones that are origins for that color (or both)
+ */
+static int
+gtp_worm_origins(char *s, int id)
+{
+ int i;
+ int j;
+ int color = EMPTY;
+
+ if (sscanf(s, "%*c") >= 0) {
+ if (!gtp_decode_color(s, &color))
+ return gtp_failure(id, "invalid color");
+ }
+
+ examine_position(EMPTY, EXAMINE_WORMS);
+ gtp_printid(id, GTP_SUCCESS);
+
+ for (i = 0; i < board_size; i++)
+ for (j = 0; j < board_size; j++)
+ if ((color==EMPTY || BOARD(i,j)==color)&&(BOARD(i,j)!=EMPTY)) {
+ struct worm_data *w = &worm[POS(i, j)];
+ if(w->origin==POS(i,j))
+ gtp_mprintf("%m ", i, j);
+ }
+ gtp_printf("\n\n");
+ return GTP_OK;
+}
/* Function: Return the cutstone field in the worm data structure.
* Arguments: non-empty vertex
--
Heikki Levanto LSD - Levanto Software Development <address@hidden>
- [gnugo-devel] Patch: GTP:worm_data:origin, Heikki Levanto, 2002/01/26
- Re: [gnugo-devel] Patch: GTP:worm_origins,
Heikki Levanto <=
- Re: [gnugo-devel] Patch: GTP:worm_origins, Gunnar Farneback, 2002/01/26
- Re: [gnugo-devel] Patch: GTP:worm_origins, Heikki Levanto, 2002/01/27
- Re: [gnugo-devel] Patch: GTP:worm_origins, Daniel Bump, 2002/01/27
- Re: [gnugo-devel] Patch: GTP:worm_origins, Gunnar Farneback, 2002/01/27
- [gnugo-devel] Re: Patch: GTP:worm_origins, Heikki Levanto, 2002/01/27
- Re: [gnugo-devel] Re: Patch: GTP:worm_origins, Gunnar Farneback, 2002/01/27
- [gnugo-devel] Patch: GTP: Getting komi and handicap, Heikki Levanto, 2002/01/27
- Re: [gnugo-devel] Patch: GTP: Getting komi and handicap, Heikki Levanto, 2002/01/27