[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] liberty counting - bonus
From: |
Paul Pogonyshev |
Subject: |
[gnugo-devel] liberty counting - bonus |
Date: |
Mon, 14 Oct 2002 02:26:01 +0300 |
this patch adds a new gtp command - exactlib. it's just a "feel free
to ignore" patch. used it myself.
Paul
Index: gnugo/interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.94
diff -u -r1.94 play_gtp.c
--- gnugo/interface/play_gtp.c 9 Oct 2002 18:36:23 -0000 1.94
+++ gnugo/interface/play_gtp.c 13 Oct 2002 23:19:07 -0000
@@ -67,6 +67,7 @@
DECLARE(gtp_echo);
DECLARE(gtp_echo_err);
DECLARE(gtp_eval_eye);
+DECLARE(gtp_exactlib);
DECLARE(gtp_final_score);
DECLARE(gtp_final_status);
DECLARE(gtp_final_status_list);
@@ -165,6 +166,7 @@
{"echo" , gtp_echo},
{"echo_err" , gtp_echo_err},
{"estimate_score", gtp_estimate_score},
+ {"exactlib", gtp_exactlib},
{"experimental_score", gtp_experimental_score},
{"eval_eye", gtp_eval_eye},
{"final_score", gtp_final_score},
@@ -740,6 +742,34 @@
return gtp_failure("vertex must not be empty");
liberties = findlib(POS(i, j), MAXLIBS, libs);
+ gtp_start_response(GTP_SUCCESS);
+ gtp_print_vertices2(liberties, libs);
+ return gtp_finish_response();
+}
+
+
+/* Function: Determine which liberties a stone of given color
+ * will get if played at given vertex.
+ * Arguments: move (color + vertex)
+ * Fails: invalid color, invalid vertex, occupied vertex
+ * Returns: Sorted space separated list of liberties
+ */
+static int
+gtp_exactlib(char *s)
+{
+ int i, j;
+ int color;
+ int libs[MAXLIBS];
+ int liberties;
+
+ if (!gtp_decode_move(s, &color, &i, &j))
+ return gtp_failure("invalid color or coordinate");
+
+ if (BOARD(i, j) != EMPTY)
+ return gtp_failure("vertex must be empty");
+
+ liberties = exactlib(POS(i, j), color, MAXLIBS, libs);
+
gtp_start_response(GTP_SUCCESS);
gtp_print_vertices2(liberties, libs);
return gtp_finish_response();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] liberty counting - bonus,
Paul Pogonyshev <=