[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] GTP command : last_move
From: |
Gunnar Farneback |
Subject: |
Re: [gnugo-devel] GTP command : last_move |
Date: |
Sat, 23 Aug 2003 15:45:51 +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) |
Avis wrote:
> I was writing a front end to gnugo, and wanted to highlight the last
> move made. If the game started from scratch, I guess the burden could
> be on my program. However, for loaded games, I think that information
> is best decoded by gnugo.
>
> Attached is the diff that implements it. Also implemented are gtp
> commands that returns the number of captured stones.
The latter are redundant since there already is a captures <color>
command. The former is included in the revised patch below.
/Gunnar
Index: doc/gtp-commands.texi
===================================================================
RCS file: /cvsroot/gnugo/gnugo/doc/gtp-commands.texi,v
retrieving revision 1.17
diff -u -r1.17 gtp-commands.texi
--- doc/gtp-commands.texi 15 Aug 2003 06:46:53 -0000 1.17
+++ doc/gtp-commands.texi 23 Aug 2003 13:16:18 -0000
@@ -368,6 +368,18 @@
@end example
address@hidden last_move
address@hidden last_move
+
address@hidden
+
+ Function: Return the last move.
+ Arguments: none
+ Fails: no previous move known
+ Returns: Color and vertex of last move.
+
address@hidden example
+
@cindex trymove
@item trymove
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.129
diff -u -r1.129 play_gtp.c
--- interface/play_gtp.c 12 Aug 2003 21:26:48 -0000 1.129
+++ interface/play_gtp.c 23 Aug 2003 13:16:24 -0000
@@ -119,6 +119,7 @@
DECLARE(gtp_is_legal);
DECLARE(gtp_known_command);
DECLARE(gtp_ladder_attack);
+DECLARE(gtp_last_move);
DECLARE(gtp_set_search_diamond);
DECLARE(gtp_reset_search_mask);
DECLARE(gtp_limit_search);
@@ -250,6 +251,7 @@
{"komi", gtp_set_komi},
{"get_komi", gtp_get_komi},
{"ladder_attack", gtp_ladder_attack},
+ {"last_move", gtp_last_move},
{"level", gtp_set_level},
{"set_search_diamond", gtp_set_search_diamond},
{"reset_search_mask", gtp_reset_search_mask},
@@ -1066,6 +1068,30 @@
return gtp_success("%d", white_captured);
else
return gtp_success("%d", black_captured);
+}
+
+
+/* Function: Return the last move.
+ * Arguments: none
+ * Fails: no previous move known
+ * Returns: Color and vertex of last move.
+ */
+static int
+gtp_last_move(char *s)
+{
+ int pos;
+ int color;
+ UNUSED(s);
+
+ if (move_history_pointer <= 0)
+ return gtp_failure("no previous move known");
+
+ pos = move_history_pos[move_history_pointer - 1];
+ color = move_history_color[move_history_pointer - 1];
+
+ gtp_start_response(GTP_SUCCESS);
+ gtp_mprintf("%C %m", color, I(pos), J(pos));
+ return gtp_finish_response();
}