[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] gtp `influence' command
From: |
Paul Pogonyshev |
Subject: |
[gnugo-devel] gtp `influence' command |
Date: |
Mon, 11 Aug 2003 23:39:55 +0000 |
User-agent: |
KMail/1.5.9 |
this patch enhances output of gtp `influence' command. it eliminates
access to uninitialized memory, prints 'X'/'@' in influence region map
where stones are and adds territory value output.
Paul
Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.93
diff -u -p -r1.93 influence.c
--- engine/influence.c 3 Aug 2003 12:15:36 -0000 1.93
+++ engine/influence.c 11 Aug 2003 20:21:51 -0000
@@ -2132,13 +2132,16 @@ void
get_influence(const struct influence_data *q,
float white_influence[BOARDMAX],
float black_influence[BOARDMAX],
+ float territory_value[BOARDMAX],
int influence_regions[BOARDMAX])
{
int ii;
- for (ii = BOARDMIN; ii < BOARDMAX; ii++)
+ for (ii = BOARDMIN; ii < BOARDMAX; ii++) {
+ white_influence[ii] = q->white_influence[ii];
+ black_influence[ii] = q->black_influence[ii];
+ territory_value[ii] = q->territory_value[ii];
+
if (board[ii] == EMPTY) {
- white_influence[ii] = q->white_influence[ii];
- black_influence[ii] = q->black_influence[ii];
if (whose_territory(q, ii) == WHITE)
influence_regions[ii] = 3;
else if (whose_territory(q, ii) == BLACK)
@@ -2154,6 +2157,11 @@ get_influence(const struct influence_dat
else
influence_regions[ii] = 0;
}
+ else if (board[ii] == WHITE)
+ influence_regions[ii] = 4;
+ else if (board[ii] == BLACK)
+ influence_regions[ii] = -4;
+ }
}
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.195
diff -u -p -r1.195 liberty.h
--- engine/liberty.h 8 Aug 2003 15:12:07 -0000 1.195
+++ engine/liberty.h 11 Aug 2003 20:21:59 -0000
@@ -732,6 +732,7 @@ void influence_get_moyo_data(const struc
void get_influence(const struct influence_data *q,
float white_influence[BOARDMAX],
float black_influence[BOARDMAX],
+ float territory_value[BOARDMAX],
int regions[BOARDMAX]);
float influence_score(const struct influence_data *q);
float game_status(int color);
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.127
diff -u -p -r1.127 play_gtp.c
--- interface/play_gtp.c 6 Aug 2003 14:31:44 -0000 1.127
+++ interface/play_gtp.c 11 Aug 2003 20:22:06 -0000
@@ -58,6 +58,7 @@ static void analyze_time_data(int time_l
static void adjust_level_offset(int color);
static void print_influence(float white_influence[BOARDMAX],
float black_influence[BOARDMAX],
+ float territory_value[BOARDMAX],
int influence_regions[BOARDMAX]);
static void gtp_print_code(int c);
static void gtp_print_vertices2(int n, int *moves);
@@ -3431,6 +3432,10 @@ gtp_dump_stack(char *s)
* .
* .
* 100.00 139.39 100.00 139.39 100.00 0.00 0.00 0.00 0.00
+ * territory value:
+ * .
+ * .
+ * .
* regions:
* -1 0 0 1 1 0 -1 -3 -3
* .
@@ -3453,6 +3458,7 @@ gtp_influence(char *s)
int color;
float white_influence[BOARDMAX];
float black_influence[BOARDMAX];
+ float territory_value[BOARDMAX];
int influence_regions[BOARDMAX];
if (!gtp_decode_color(s, &color))
@@ -3462,16 +3468,20 @@ gtp_influence(char *s)
gtp_start_response(GTP_SUCCESS);
get_influence(OPPOSITE_INFLUENCE(color), white_influence,
- black_influence, influence_regions);
- print_influence(white_influence, black_influence, influence_regions);
+ black_influence, territory_value, influence_regions);
+ print_influence(white_influence, black_influence, territory_value,
+ influence_regions);
+
/* We already have one newline and thus can't use gtp_finish_response(). */
gtp_printf("\n");
return GTP_OK;
}
+
static void
print_influence(float white_influence[BOARDMAX],
float black_influence[BOARDMAX],
+ float territory_value[BOARDMAX],
int influence_regions[BOARDMAX])
{
int m, n;
@@ -3491,10 +3501,23 @@ print_influence(float white_influence[BO
gtp_printf("\n");
}
+ gtp_printf("territory value:\n");
+ for (m = 0; m < board_size; m++) {
+ for (n = 0; n < board_size; n++)
+ gtp_printf("%+6.2f ", territory_value[POS(m, n)]);
+
+ gtp_printf("\n");
+ }
+
gtp_printf("regions:\n");
for (m = 0; m < board_size; m++) {
for (n = 0; n < board_size; n++) {
- gtp_printf("%2d ", influence_regions[POS(m, n)]);
+ if (influence_regions[POS(m, n)] == 4)
+ gtp_printf(" @ "); /* 'O' looks too much like '0'. */
+ else if (influence_regions[POS(m, n)] == -4)
+ gtp_printf(" X ");
+ else
+ gtp_printf("%2d ", influence_regions[POS(m, n)]);
}
gtp_printf("\n");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] gtp `influence' command,
Paul Pogonyshev <=