[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] Patch: 1D patch to aftermath.c
From: |
Inge Wallin |
Subject: |
[gnugo-devel] Patch: 1D patch to aftermath.c |
Date: |
Thu, 18 Oct 2001 15:42:30 +0200 (CEST) |
Here is a small patch that makes the rest of aftermath.c
1-dimensional. Somebody had already done some work there, but this
patch completes it.
-Inge
Index: engine/aftermath.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/aftermath.c,v
retrieving revision 1.12
diff -u -r1.12 aftermath.c
--- engine/aftermath.c 2001/10/16 19:53:01 1.12
+++ engine/aftermath.c 2001/10/18 13:40:37
@@ -737,9 +737,10 @@
play_aftermath(int color)
{
int m, n;
+ int ii;
Position saved_pos;
struct aftermath_data *a = &aftermath;
- static int current_board[MAX_BOARD][MAX_BOARD];
+ static int current_board[BOARDMAX];
static int current_color = EMPTY;
int cached_board = 1;
gg_assert(color == BLACK || color == WHITE);
@@ -750,11 +751,14 @@
}
for (m = 0; m < board_size; m++)
- for (n = 0; n < board_size; n++)
- if (board[POS(m, n)] != current_board[m][n]) {
- current_board[m][n] = board[POS(m, n)];
+ for (n = 0; n < board_size; n++) {
+ ii = POS(m, n);
+
+ if (board[ii] != current_board[ii]) {
+ current_board[ii] = board[ii];
cached_board = 0;
}
+ }
/* If this is exactly the same position as the one we analyzed the
* last time, the content of the aftermath struct is up to date.
@@ -777,40 +781,42 @@
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++) {
- if (a->black_control[POS(m, n)]) {
+ ii = POS(m, n);
+
+ if (a->black_control[ii]) {
a->black_area++;
- if (board[POS(m, n)] == WHITE) {
+ if (board[ii] == WHITE) {
a->black_territory++;
a->white_prisoners++;
- a->final_status[POS(m, n)] = DEAD;
+ a->final_status[ii] = DEAD;
}
- else if (board[POS(m, n)] == EMPTY) {
+ else if (board[ii] == EMPTY) {
a->black_territory++;
- a->final_status[POS(m, n)] = BLACK_TERRITORY;
+ a->final_status[ii] = BLACK_TERRITORY;
}
else
- a->final_status[POS(m, n)] = ALIVE;
+ a->final_status[ii] = ALIVE;
}
- else if (a->white_control[POS(m, n)]) {
+ else if (a->white_control[ii]) {
a->white_area++;
- if (board[POS(m, n)] == BLACK) {
+ if (board[ii] == BLACK) {
a->white_territory++;
a->black_prisoners++;
- a->final_status[POS(m, n)] = DEAD;
+ a->final_status[ii] = DEAD;
}
- else if (board[POS(m, n)] == EMPTY) {
+ else if (board[ii] == EMPTY) {
a->white_territory++;
- a->final_status[POS(m, n)] = WHITE_TERRITORY;
+ a->final_status[ii] = WHITE_TERRITORY;
}
else
- a->final_status[POS(m, n)] = ALIVE;
+ a->final_status[ii] = ALIVE;
}
else {
- if (board[POS(m, n)] == EMPTY)
- a->final_status[POS(m, n)] = DAME;
+ if (board[ii] == EMPTY)
+ a->final_status[ii] = DAME;
else {
- a->final_status[POS(m, n)] = ALIVE_IN_SEKI;
- if (board[POS(m, n)] == WHITE)
+ a->final_status[ii] = ALIVE_IN_SEKI;
+ if (board[ii] == WHITE)
a->white_area++;
else
a->black_area++;
@@ -843,11 +849,11 @@
* BLACK_TERRITORY, and DAME.
*/
int
-aftermath_final_status(int color, int m, int n)
+aftermath_final_status(int color, int pos)
{
- ASSERT_ON_BOARD1(POS(m, n));
+ ASSERT_ON_BOARD1(pos);
play_aftermath(color);
- return aftermath.final_status[POS(m, n)];
+ return aftermath.final_status[pos];
}
/*
Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.20
diff -u -r1.20 gnugo.h
--- engine/gnugo.h 2001/10/16 19:53:01 1.20
+++ engine/gnugo.h 2001/10/18 13:40:38
@@ -416,7 +416,7 @@
/* Play through the aftermath. */
float aftermath_compute_score(int color, float komi);
-int aftermath_final_status(int color, int m, int n);
+int aftermath_final_status(int color, int pos);
/* Basic information gathering. */
/* worm.c */
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.36
diff -u -r1.36 play_gtp.c
--- interface/play_gtp.c 2001/10/17 20:34:15 1.36
+++ interface/play_gtp.c 2001/10/18 13:40:38
@@ -1435,7 +1435,7 @@
final_score = aftermath_compute_score(next, komi);
for (i = 0; i < board_size; i++)
for (j = 0; j < board_size; j++) {
- final_status[i][j] = aftermath_final_status(next, i, j);
+ final_status[i][j] = aftermath_final_status(next, POS(i, j));
saved_board[i][j] = BOARD(i, j);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] Patch: 1D patch to aftermath.c,
Inge Wallin <=