[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] auto generated regression tests
From: |
Gunnar Farneback |
Subject: |
Re: [gnugo-devel] auto generated regression tests |
Date: |
Thu, 08 Aug 2002 00:19:06 +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) |
I wrote:
> Dan wrote:
> > In this case it seems that the gtp function matcher_status should
> > replace dragon_status. (Of course it would be renamed.) After the
> > patch matcher_status_3_6.2 allowing it to take a parameter its
> > functionality includes that of dragon_status.
>
> Not quite. If a dragon is critical, dragon_status also returns an
> attack point and a defense point (if such are known, which they always
> are today). A more serious merge is needed.
This patch performs this merge and updates the matcher_check script to
use dragon_status instead of matcher_status. Actually the name
matcher_check doesn't make much sense any longer but I haven't done
anything about it.
/Gunnar
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.82
diff -u -r1.82 play_gtp.c
--- interface/play_gtp.c 6 Aug 2002 19:04:11 -0000 1.82
+++ interface/play_gtp.c 7 Aug 2002 22:06:44 -0000
@@ -91,7 +91,6 @@
DECLARE(gtp_ladder_attack);
DECLARE(gtp_list_stones);
DECLARE(gtp_loadsgf);
-DECLARE(gtp_matcher_status);
DECLARE(gtp_name);
DECLARE(gtp_new_game);
DECLARE(gtp_estimate_score);
@@ -194,7 +193,6 @@
{"level", gtp_set_level},
{"list_stones", gtp_list_stones},
{"loadsgf", gtp_loadsgf},
- {"matcher_status", gtp_matcher_status},
{"name", gtp_name},
{"new_game", gtp_new_game},
{"new_score", gtp_estimate_score},
@@ -1500,67 +1498,67 @@
*****************/
/* Function: Determine status of a dragon.
- * Arguments: vertex
+ * Arguments: optional vertex
* Fails: invalid vertex, empty vertex
* Returns: status ("alive", "critical", "dead", or "unknown"),
* attack point, defense point. Points of attack and
- * defense are only given if the status is critical and the
- * owl code is enabled.
+ * defense are only given if the status is critical.
+ * If no vertex is given, the status is listed for all
+ * dragons, one per row in the format "A4: alive".
*
* FIXME: Should be able to distinguish between life in seki
- * and life with territory. Should also be able to identify ko.
+ * and independent life. Should also be able to identify ko.
*/
static int
gtp_dragon_status(char *s, int id)
{
int i, j;
+ int str = NO_MOVE;
+ int pos;
- if (!gtp_decode_coord(s, &i, &j))
+ if (gtp_decode_coord(s, &i, &j)) {
+ str = POS(i, j);
+ if (board[str] == EMPTY)
+ return gtp_failure(id, "vertex must not be empty");
+ }
+ else if (sscanf(s, "%*s") != EOF)
return gtp_failure(id, "invalid coordinate");
- if (BOARD(i, j) == EMPTY)
- return gtp_failure(id, "vertex must not be empty");
-
silent_examine_position(BLACK, EXAMINE_DRAGONS);
- /* FIXME: We should also call the semeai module. */
-
- if (dragon[POS(i, j)].owl_status == UNCHECKED) {
- if (dragon[POS(i, j)].crude_status == ALIVE)
- return gtp_success(id, "alive");
-
- if (dragon[POS(i, j)].crude_status == DEAD)
- return gtp_success(id, "dead");
-
- if (dragon[POS(i, j)].crude_status == UNKNOWN)
- return gtp_success(id, "unknown");
+ gtp_printid(id, GTP_SUCCESS);
- /* Only remaining possibility. */
- assert(dragon[POS(i, j)].crude_status == CRITICAL);
- return gtp_success(id, "critical");
+ for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
+ if (ON_BOARD(pos)
+ && (pos == str
+ || (str == NO_MOVE
+ && board[pos] != EMPTY
+ && dragon[pos].origin == pos))) {
+ if (str == NO_MOVE)
+ gtp_mprintf("%m: ", I(pos), J(pos));
+
+ if (dragon[pos].status == ALIVE)
+ gtp_printf("alive\n");
+ else if (dragon[pos].status == DEAD)
+ gtp_printf("dead\n");
+ else if (dragon[pos].status == UNKNOWN)
+ gtp_printf("unknown\n");
+ else {
+ /* Only remaining possibility. */
+ assert(dragon[pos].status == CRITICAL);
+ /* Status critical, need to return attack and defense point as well. */
+ gtp_mprintf("critical %m %m\n",
+ I(dragon[pos].owl_attack_point),
+ J(dragon[pos].owl_attack_point),
+ I(dragon[pos].owl_defense_point),
+ J(dragon[pos].owl_defense_point));
+ }
+ }
}
- /* Owl code active. */
- if (dragon[POS(i, j)].owl_status == ALIVE)
- return gtp_success(id, "alive");
-
- if (dragon[POS(i, j)].owl_status == DEAD)
- return gtp_success(id, "dead");
-
- if (dragon[POS(i, j)].owl_status == UNKNOWN)
- return gtp_success(id, "unknown");
-
- assert(dragon[POS(i, j)].owl_status == CRITICAL);
- /* Status critical, need to return attack and defense point as well. */
- gtp_printid(id, GTP_SUCCESS);
- gtp_printf("critical ");
- gtp_print_vertex(I(dragon[POS(i, j)].owl_attack_point),
- J(dragon[POS(i, j)].owl_attack_point));
- gtp_printf(" ");
- gtp_print_vertex(I(dragon[POS(i, j)].owl_defense_point),
- J(dragon[POS(i, j)].owl_defense_point));
- return gtp_finish_response();
+ gtp_printf("\n");
+ return GTP_OK;
}
@@ -2692,54 +2690,6 @@
}
gtp_printf("\n");
return GTP_OK;
-}
-
-/* Function: List the matcher status of all dragons
- * Arguments: optional vertex
- * Fails: never
- * Returns: With no parameter, matcher statuses for all dragons in format:
- * D4: ALIVE
- * With one vertex as parameter, prints matcher statuses, format:
- * ALIVE
- */
-static int
-gtp_matcher_status(char *s, int id)
-{
- int pos, i, j;
-
- if (sscanf(s, "%*c") >= 0) {
- if (!gtp_decode_coord(s, &i, &j))
- return gtp_failure(id, "invalid coordinate");
- if (i != -1)
- pos = POS(i, j);
- if (board[pos] == EMPTY)
- return gtp_failure(id, "empty vertex");
- }
- else
- pos = PASS_MOVE;
-
- examine_position(EMPTY, EXAMINE_DRAGONS);
-
- gtp_printid(id, GTP_SUCCESS);
-
- if (pos == PASS_MOVE) {
- for (pos = BOARDMIN; pos < BOARDMAX; pos++)
- if (ON_BOARD(pos)
- && board[pos] != EMPTY
- && dragon[pos].origin == pos) {
- struct dragon_data *d = &dragon[pos];
- gtp_print_vertex(I(pos), J(pos));
- gtp_printf(": ");
- gtp_printf("%s\n", status_to_string(d->status));
- }
- gtp_printf("\n");
- return GTP_OK;
- }
- else {
- gtp_printf("%s\n", status_to_string(dragon[pos].status));
- gtp_printf("\n");
- return GTP_OK;
- }
}
/* Function: List the stones of a dragon
Index: interface/gtp_examples/matcher_check
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/gtp_examples/matcher_check,v
retrieving revision 1.3
diff -u -r1.3 matcher_check
--- interface/gtp_examples/matcher_check 6 Aug 2002 14:20:48 -0000
1.3
+++ interface/gtp_examples/matcher_check 7 Aug 2002 22:06:44 -0000
@@ -24,10 +24,10 @@
# Boston, MA 02111, USA. #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
-# matcher_status info:
+# matcher_check info:
#
# plays one gtp program against itself, and watches for bad
-# matcher_status transitions.
+# status transitions.
#
# FIXME: allow analysis of sgf files
# FIXME: if the vertex by which a dragon is named ever changes,
@@ -357,7 +357,7 @@
my $legality = "illegal";
#send command
- print $in "matcher_status\n";
+ print $in "dragon_status\n";
#ignore empty lines
#while ($line eq "")
@@ -396,12 +396,12 @@
#ok, so it's old
$legality = "illegal";
- if ($old_status eq "CRITICAL") {$legality = "legal"};
- if ($new_status eq "CRITICAL") {$legality = "legal"};
- if ($new_status eq "UNKNOWN") {$legality = "legal"};
- if ($old_status eq "UNKNOWN") {
- if ($new_status eq "ALIVE") {$legality = "legal";}
- if ($new_status eq "CRITICAL") {$legality = "legal";}
+ if ($old_status eq "critical") {$legality = "legal"};
+ if ($new_status eq "critical") {$legality = "legal"};
+ if ($new_status eq "unknown") {$legality = "legal"};
+ if ($old_status eq "unknown") {
+ if ($new_status eq "alive") {$legality = "legal";}
+ if ($new_status eq "critical") {$legality = "legal";}
}
if ($match_hist{$vertex} eq $new_status)
@@ -426,7 +426,7 @@
}
} else
{
- #illegal state change -- ALIVE to DEAD or vice versa
+ #illegal state change -- alive to dead or vice versa
print "Illegal state change:\n";
print "Games remaining: $games\n";
print "Move: $movenum\n";
- Re: [gnugo-devel] auto generated regression tests, (continued)
- Re: [gnugo-devel] auto generated regression tests, Gunnar Farneback, 2002/08/04
- Re: [gnugo-devel] auto generated regression tests, bump, 2002/08/05
- Re: [gnugo-devel] auto generated regression tests, Gunnar Farneback, 2002/08/05
- Re: [gnugo-devel] auto generated regression tests, bump, 2002/08/05
- Re: [gnugo-devel] auto generated regression tests, bump, 2002/08/05
- Re: [gnugo-devel] auto generated regression tests, bump, 2002/08/05
- Re: [gnugo-devel] auto generated regression tests, Gunnar Farneback, 2002/08/05
- Re: [gnugo-devel] auto generated regression tests, bump, 2002/08/06
- Re: [gnugo-devel] auto generated regression tests, Gunnar Farneback, 2002/08/07
- Re: [gnugo-devel] auto generated regression tests,
Gunnar Farneback <=
- Re: [gnugo-devel] auto generated regression tests, Gunnar Farneback, 2002/08/05
Re: [gnugo-devel] auto generated regression tests, Arend Bayer, 2002/08/14
Re: [gnugo-devel] auto generated regression tests, bump, 2002/08/08