[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] != EMPTY or IS_COLOR ?
From: |
Teun Burgers |
Subject: |
Re: [gnugo-devel] != EMPTY or IS_COLOR ? |
Date: |
Fri, 12 Oct 2001 21:00:51 +0200 |
Gunnar Farneback wrote:
> Teun wrote:
> > This patch defines a new macro IS_COLOR and as
> > an example replace != EMPTY tests in worm.c
> > with IS_COLOR tests. I think this is
> > safer in the long run
>
> That's quite possible, but wouldn't IS_STONE be a more intuitive name
> for detecting a stone of either color?
This patch rename IS_COLOR to IS_STONE and uses it at
quite a few more places.
Teun
? Makefile
? .deps
Index: board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.14
diff -u -r1.14 board.c
--- board.c 2001/10/11 15:39:37 1.14
+++ board.c 2001/10/12 18:54:00
@@ -189,7 +189,7 @@
#define MARK_STRING(pos) string[string_number[pos]].mark = string_mark
#define STRING_AT_VERTEX(pos, s)\
- (board[pos] != EMPTY && board[pos] != GRAY && string_number[pos] == (s))
+ (IS_STONE(board[pos]) && string_number[pos] == (s))
#define LIBERTIES(pos)\
string[string_number[pos]].liberties
@@ -380,7 +380,7 @@
if (sgf_dumptree) {
char buf[100];
if (str == 0) {
- if (komaster != EMPTY)
+ if (IS_STONE(komaster))
gg_snprintf(buf, 100, "%s (variation %d, hash %lx, komaster %s:%s)",
message, count_variations, hashdata.hashval,
color_to_string(komaster),
@@ -390,7 +390,7 @@
message, count_variations, hashdata.hashval);
}
else {
- if (komaster != EMPTY)
+ if (IS_STONE(komaster))
gg_snprintf(buf, 100, "%s at %s (variation %d, hash %lx, komaster
%s:%s)",
message, location_to_string(str), count_variations,
hashdata.hashval, color_to_string(komaster),
@@ -434,7 +434,7 @@
char buf[100];
if (!message)
message = "???";
- if (komaster != EMPTY)
+ if (IS_STONE(komaster))
gg_snprintf(buf, 100, "tryko: %s (variation %d, %lx, komaster %s:%s)",
message, count_variations, hashdata.hashval,
color_to_string(komaster), location_to_string(kom_pos));
@@ -680,7 +680,7 @@
{
ASSERT1(stackp == 0, pos);
ASSERT_ON_BOARD1(pos);
- ASSERT1(board[pos] != EMPTY, pos);
+ ASSERT1(IS_STONE(board[pos]), pos);
do_remove_stone(pos);
new_position();
@@ -908,8 +908,8 @@
* there is suicide. If komaster == GRAY we don't remember who
* owns the ko so we have to try both colors.
*/
- if (komaster != EMPTY
- && (board[kom_pos] != EMPTY
+ if (IS_STONE(komaster)
+ && (IS_STONE(board[kom_pos])
|| (komaster != GRAY
&& !is_ko(kom_pos, OTHER_COLOR(komaster), NULL)
&& is_suicide(kom_pos, OTHER_COLOR(komaster)))
@@ -1024,7 +1024,7 @@
return 1;
/* Conditional ko captures are only allowed if the komaster is EMPTY. */
- if (!consider_conditional_ko || komaster != EMPTY)
+ if (!consider_conditional_ko || IS_STONE(komaster))
return 0;
if (tryko(pos, color, message, komaster, kom_pos)) {
@@ -1138,7 +1138,7 @@
countlib(int str)
{
ASSERT_ON_BOARD1(str);
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1165,7 +1165,7 @@
int s;
ASSERT_ON_BOARD1(str);
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
ASSERT1(libs != NULL, str);
if (!strings_initialized)
@@ -1254,7 +1254,7 @@
ASSERT_ON_BOARD1(pos);
ASSERT1(board[pos] == EMPTY, pos);
- ASSERT1(color != EMPTY, pos);
+ ASSERT1(IS_STONE(color), pos);
if (!strings_initialized)
init_board();
@@ -1390,8 +1390,8 @@
ASSERT_ON_BOARD1(str1);
ASSERT_ON_BOARD1(str2);
- ASSERT1(board[str1] != EMPTY, str1);
- ASSERT1(board[str2] != EMPTY, str2);
+ ASSERT1(IS_STONE(board[str1]), str1);
+ ASSERT1(IS_STONE(board[str2]), str2);
if (!strings_initialized)
init_board();
@@ -1431,8 +1431,8 @@
ASSERT_ON_BOARD1(str1);
ASSERT_ON_BOARD1(str2);
- ASSERT1(board[str1] != EMPTY, str1);
- ASSERT1(board[str2] != EMPTY, str2);
+ ASSERT1(IS_STONE(board[str1]), str1);
+ ASSERT1(IS_STONE(board[str2]), str2);
ASSERT1(libs != NULL, str1);
if (!strings_initialized)
@@ -1471,8 +1471,8 @@
ASSERT_ON_BOARD1(str1);
ASSERT_ON_BOARD1(str2);
- ASSERT1(board[str1] != EMPTY, str1);
- ASSERT1(board[str2] != EMPTY, str2);
+ ASSERT1(IS_STONE(board[str1]), str1);
+ ASSERT1(IS_STONE(board[str2]), str2);
if (!strings_initialized)
init_board();
@@ -1504,7 +1504,7 @@
countstones(int str)
{
ASSERT_ON_BOARD1(str);
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1527,7 +1527,7 @@
int k;
ASSERT_ON_BOARD1(str);
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1556,7 +1556,7 @@
struct string_data *s;
int k;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1584,7 +1584,7 @@
int k;
int neighbors;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1612,7 +1612,7 @@
int
find_origin(int str)
{
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1634,7 +1634,7 @@
ASSERT_ON_BOARD1(pos);
ASSERT1(board[pos] == EMPTY, pos);
- ASSERT1(color != EMPTY, pos);
+ ASSERT1(IS_STONE(color), pos);
if (!strings_initialized)
init_board();
@@ -1664,7 +1664,7 @@
int
liberty_of_string(int pos, int str)
{
- if (board[pos] != EMPTY)
+ if (IS_STONE(board[pos]))
return 0;
return neighbor_of_string(pos, str);
@@ -1681,7 +1681,7 @@
int s;
int color = board[str];
- ASSERT1(color != EMPTY, str);
+ ASSERT1(IS_STONE(color), str);
if (!strings_initialized)
init_board();
@@ -1717,8 +1717,8 @@
{
ASSERT_ON_BOARD1(str1);
ASSERT_ON_BOARD1(str2);
- ASSERT1(board[str1] != EMPTY, str1);
- ASSERT1(board[str2] != EMPTY, str2);
+ ASSERT1(IS_STONE(board[str1]), str1);
+ ASSERT1(IS_STONE(board[str2]), str2);
if (!strings_initialized)
init_board();
@@ -1739,8 +1739,8 @@
ASSERT_ON_BOARD1(str1);
ASSERT_ON_BOARD1(str2);
- ASSERT1(board[str1] != EMPTY, str1);
- ASSERT1(board[str2] != EMPTY, str2);
+ ASSERT1(IS_STONE(board[str1]), str1);
+ ASSERT1(IS_STONE(board[str2]), str2);
if (!strings_initialized)
init_board();
@@ -1851,7 +1851,7 @@
color = board[SOUTH(pos)];
else
color = board[NORTH(pos)];
- if (color != EMPTY && is_ko(pos, OTHER_COLOR(color), NULL))
+ if (IS_STONE(color) && is_ko(pos, OTHER_COLOR(color), NULL))
return 1;
}
else {
@@ -1904,7 +1904,7 @@
{
int pos = str;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -1922,7 +1922,7 @@
int str = POS(m, n);
int pos = str;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (!strings_initialized)
init_board();
@@ -2066,7 +2066,7 @@
for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
if (!ON_BOARD(pos))
continue;
- if (board[pos] != EMPTY && string_number[pos] == -1) {
+ if (IS_STONE(board[pos]) && string_number[pos] == -1) {
string_number[pos] = next_string;
string[next_string].size = propagate_string(pos, pos);
string[next_string].color = board[pos];
Index: dragon.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v
retrieving revision 1.21
diff -u -r1.21 dragon.c
--- dragon.c 2001/10/12 15:09:52 1.21
+++ dragon.c 2001/10/12 18:54:04
@@ -170,7 +170,7 @@
continue;
/* Tell the move generation code about the lunch. */
- if (color != EMPTY)
+ if (IS_STONE(color))
add_lunch(POS(m, n), food);
/* If several lunches are found, we pick the juiciest.
@@ -341,7 +341,7 @@
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++)
if (dragon[POS(m, n)].origin == POS(m, n)
- && BOARD(m, n) != EMPTY) {
+ && IS_STONE(BOARD(m, n))) {
DRAGON2(POS(m, n)).escape_route = compute_escape(m, n, 0);
}
@@ -507,7 +507,7 @@
*/
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++)
- if (BOARD(m, n) != EMPTY) {
+ if (IS_STONE(BOARD(m, n))) {
if (dragon[POS(m, n)].owl_status != UNCHECKED)
dragon[POS(m, n)].matcher_status = dragon[POS(m, n)].owl_status;
else if (dragon[POS(m, n)].status == DEAD
@@ -672,7 +672,7 @@
*/
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++) {
- if (BOARD(m, n) != EMPTY
+ if (IS_STONE(BOARD(m, n))
&& dragon[POS(m, n)].origin == POS(m, n)) {
DRAGON2(POS(m, n)).origin = POS(m, n);
}
@@ -722,7 +722,7 @@
/* Initialize the arrays. */
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++) {
- if (BOARD(m, n) != EMPTY) {
+ if (IS_STONE(BOARD(m, n))) {
dragons[m][n] = dragon[POS(m, n)].id;
distances[m][n] = 0;
}
@@ -886,7 +886,7 @@
int strong_eyes = 0;
- gg_assert(BOARD(m, n) != EMPTY);
+ gg_assert(IS_STONE(BOARD(m, n)));
/* First look for invincible strings in the dragon. */
for (i = 0; i < board_size; i++)
@@ -1130,7 +1130,7 @@
gg_assert(board[d1] == board[d2]);
gg_assert(dragon2_initialized == 0);
- gg_assert(board[d1] != EMPTY);
+ gg_assert(IS_STONE(board[d1]));
/* We want to have the origin pointing to the largest string of
* the dragon. If this is not unique, we take the "upper
@@ -1274,7 +1274,7 @@
int distance;
int escape_potential = 0;
- gg_assert(color != EMPTY);
+ gg_assert(IS_STONE(color));
if (!mx_initialized) {
memset(mx, 0, sizeof(mx));
@@ -1408,7 +1408,7 @@
char goal[BOARDMAX];
int escape_value[BOARDMAX];
- ASSERT1(board[POS(m, n)] != EMPTY, POS(m, n));
+ ASSERT1(IS_STONE(board[POS(m, n)]), POS(m, n));
for (i = 0; i < board_size; i++)
for (j = 0; j < board_size; j++) {
Index: gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.17
diff -u -r1.17 gnugo.h
--- gnugo.h 2001/10/12 15:09:52 1.17
+++ gnugo.h 2001/10/12 18:54:05
@@ -63,7 +63,7 @@
#define OTHER_COLOR(color) (WHITE+BLACK-(color))
-#define IS_COLOR(arg) ((arg) == WHITE || (arg) == BLACK)
+#define IS_STONE(arg) ((arg) == WHITE || (arg) == BLACK)
/* Return codes for reading functions */
Index: influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.12
diff -u -r1.12 influence.c
--- influence.c 2001/10/12 15:09:52 1.12
+++ influence.c 2001/10/12 18:54:09
@@ -352,7 +352,7 @@
q->black_strength[i][j] = 0.0;
q->p[i][j] = BOARD(i, j);
- if (BOARD(i, j) != EMPTY) {
+ if (IS_STONE(BOARD(i, j))) {
if (worm[POS(i, j)].attack_codes[0] == WIN
&& (OTHER_COLOR(q->p[i][j]) == color
|| worm[POS(i, j)].defend_codes[0] == 0)) {
@@ -383,7 +383,7 @@
/* When evaluating influence after a move, the newly placed
* stone will have the invalid dragon id -1.
*/
- if (BOARD(i, j) != EMPTY) {
+ if (IS_STONE(BOARD(i, j))) {
if (!dragons_known || dragon[POS(i, j)].id == -1) {
if (q->p[i][j] == WHITE)
q->white_strength[i][j] = DEFAULT_STRENGTH;
@@ -657,7 +657,7 @@
int m,n;
global_matchpat(influence_callback, ANCHOR_COLOR, &influencepat_db, q, NULL);
- if (color != EMPTY)
+ if (IS_STONE(color))
global_matchpat(influence_callback, color, &barrierspat_db, q, NULL);
/* When color == EMPTY, we introduce a weaker kind of barriers
@@ -665,7 +665,7 @@
*/
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++)
- if (BOARD(m, n) != EMPTY) {
+ if (IS_STONE(BOARD(m, n))) {
int k;
for (k = 0; k < 8; k++) {
int dm = deltai[k];
@@ -792,7 +792,7 @@
float wi = q->white_influence[m][n];
int territory_color = whose_territory(q, m, n);
- if (territory_color != EMPTY)
+ if (IS_STONE(territory_color))
return territory_color;
if (bi > 7.0 * wi && bi > 5.0 && wi < 10.0)
@@ -828,7 +828,7 @@
return EMPTY;
/* default */
- if (territory_color != EMPTY)
+ if (IS_STONE(territory_color))
color = territory_color;
else if ((bi > 10.0 * wi && bi > 10.0 && wi < 10.0) || bi > 25.0 * wi)
color = BLACK;
@@ -859,7 +859,7 @@
float wi = q->white_influence[m][n];
int moyo_color = whose_moyo(q, m, n);
- if (moyo_color != EMPTY)
+ if (IS_STONE(moyo_color))
return moyo_color;
if (bi > 3.0 * wi && bi > 1.0 && wi < 40.0)
@@ -885,7 +885,7 @@
int m, n;
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++) {
- if (q->w[m][n] == UNMARKED && region_owner(q, m, n) != EMPTY) {
+ if (q->w[m][n] == UNMARKED && IS_STONE(region_owner(q, m, n))) {
/* Found an unlabelled intersection. Use flood filling to find
* the rest of the region.
*/
Index: optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.19
diff -u -r1.19 optics.c
--- optics.c 2001/10/12 15:09:52 1.19
+++ optics.c 2001/10/12 18:54:13
@@ -348,7 +348,7 @@
domain[pos] = 1;
}
else {
- if (board[pos] != EMPTY || false_margins[pos] != 1)
+ if (IS_STONE(board[pos]) || false_margins[pos] != 1)
domain[pos] = 1;
}
}
@@ -444,7 +444,7 @@
}
}
else {
- if (board[pos] != EMPTY || false_margins[pos] != 1) {
+ if (IS_STONE(board[pos]) || false_margins[pos] != 1) {
found_one = 1;
domain[pos] = 1;
}
@@ -824,15 +824,15 @@
if (eye[POS(m, n)].origin != pos)
continue;
- if (eye[POS(m, n)].marginal && BOARD(m, n) != EMPTY)
+ if (eye[POS(m, n)].marginal && IS_STONE(BOARD(m, n)))
DEBUG(DEBUG_EYES, "%m (X!)\n", m, n);
else if (eye[POS(m, n)].marginal && BOARD(m, n) == EMPTY)
DEBUG(DEBUG_EYES, "%m (!)\n", m, n);
- else if (!eye[POS(m, n)].marginal && BOARD(m, n) != EMPTY)
+ else if (!eye[POS(m, n)].marginal && IS_STONE(BOARD(m, n)))
DEBUG(DEBUG_EYES, "%m (X)\n", m, n);
else if (is_halfeye(heye, POS(m, n)) && BOARD(m, n) == EMPTY)
DEBUG(DEBUG_EYES, "%m (H)\n", m, n);
- else if (is_halfeye(heye, POS(m, n)) && BOARD(m, n) != EMPTY)
+ else if (is_halfeye(heye, POS(m, n)) && IS_STONE(BOARD(m, n)))
DEBUG(DEBUG_EYES, "%m (XH)\n", m, n);
else
DEBUG(DEBUG_EYES, "%m\n", m, n);
@@ -980,15 +980,15 @@
if (eye[POS(m, n)].origin != pos)
continue;
- if (eye[POS(m, n)].marginal && BOARD(m, n) != EMPTY)
+ if (eye[POS(m, n)].marginal && IS_STONE(BOARD(m, n)))
DEBUG(DEBUG_EYES, "%m (X!)\n", m, n);
else if (eye[POS(m, n)].marginal && BOARD(m, n) == EMPTY)
DEBUG(DEBUG_EYES, "%m (!)\n", m, n);
- else if (!eye[POS(m, n)].marginal && BOARD(m, n) != EMPTY)
+ else if (!eye[POS(m, n)].marginal && IS_STONE(BOARD(m, n)))
DEBUG(DEBUG_EYES, "%m (X)\n", m, n);
else if (is_halfeye(heye, POS(m, n)) && BOARD(m, n) == EMPTY)
DEBUG(DEBUG_EYES, "%m (H)\n", m, n);
- else if (is_halfeye(heye, POS(m, n)) && BOARD(m, n) != EMPTY)
+ else if (is_halfeye(heye, POS(m, n)) && IS_STONE(BOARD(m, n)))
DEBUG(DEBUG_EYES, "%m (XH)\n", m, n);
else
DEBUG(DEBUG_EYES, "%m\n", m, n);
@@ -1301,7 +1301,7 @@
* .OX.O
* -----
*/
- if (board[*vital_point] != EMPTY) {
+ if (IS_STONE(board[*vital_point])) {
*max = 0;
*vital_point = NO_MOVE;
}
@@ -1315,10 +1315,10 @@
/* Exceptional cases. (eyes.tst:312) */
if ((eye[POS(end1i, end1j)].marginal
- && BOARD(end1i, end1j) != EMPTY
+ && IS_STONE(BOARD(end1i, end1j))
&& BOARD(end2i, end2j) == EMPTY)
|| (eye[POS(end2i, end2j)].marginal
- && BOARD(end2i, end2j) != EMPTY
+ && IS_STONE(BOARD(end2i, end2j))
&& BOARD(end1i, end1j) == EMPTY)) {
*min = 0;
*vital_point = POS(middlei, middlej);
@@ -1333,7 +1333,7 @@
*vital_point = POS(end1i, end1j);
}
else {
- if (BOARD(end2i, end2j) != EMPTY)
+ if (IS_STONE(BOARD(end2i, end2j)))
*min = 1; /* three tactically dead stones in a row. */
else
*max = 0;
@@ -1344,7 +1344,7 @@
*vital_point = POS(end2i, end2j);
}
else {
- if (BOARD(end1i, end1j) != EMPTY)
+ if (IS_STONE(BOARD(end1i, end1j)))
*min = 1; /* three tactically dead stones in a row. */
else
*max = 0;
@@ -1601,7 +1601,7 @@
(graphs[graph].vertex[q].type == '@')))
ok = 0;
- if (ok && (board[vpos[map[q]]] != EMPTY)
+ if (ok && (IS_STONE(board[vpos[map[q]]]))
&& (graphs[graph].vertex[q].type != 'X')
&& (graphs[graph].vertex[q].type != 'x'))
ok = 0;
Index: owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.20
diff -u -r1.20 owl.c
--- owl.c 2001/10/12 15:09:52 1.20
+++ owl.c 2001/10/12 18:54:21
@@ -1137,7 +1137,7 @@
* marked when stackp==0, which has not been captured. If no
* such string is found, owl_attack declares victory.
*/
- if (board[str] != EMPTY)
+ if (IS_STONE(board[str]))
origin = str;
else {
int found_string = 0;
@@ -1272,7 +1272,7 @@
int found_string = 0;
for (oi = 0; oi < board_size && !found_string; oi++)
for (oj = 0; oj < board_size && !found_string; oj++) {
- if (BOARD(oi, oj) != EMPTY
+ if (IS_STONE(BOARD(oi, oj))
&& owl.goal[POS(oi, oj)] == 1) {
origin = find_origin(POS(oi, oj));
found_string = 1;
@@ -1774,7 +1774,7 @@
move = moves[k].pos;
popgo();
/* Don't return the second move if occupied before trymove */
- if (move2 != 0 && board[move2] != EMPTY)
+ if (move2 != 0 && IS_STONE(board[move2]))
move2 = 0;
result = WIN;
break;
@@ -3351,7 +3351,7 @@
int other = OTHER_COLOR(board[pos]);
int size;
- ASSERT1(board[pos] != EMPTY, pos);
+ ASSERT1(IS_STONE(board[pos]), pos);
if (owl->boundary[pos] == 2) {
*min = 2;
@@ -3531,7 +3531,7 @@
owl_eyespace(int ai, int aj, int bi, int bj)
{
int opos;
- ASSERT2(BOARD(bi, bj) != EMPTY, bi, bj);
+ ASSERT2(IS_STONE(BOARD(bi, bj)), bi, bj);
if (BOARD(bi, bj) == WHITE) {
opos = current_owl_data->white_eye[POS(ai, aj)].origin;
@@ -3556,7 +3556,7 @@
owl_big_eyespace(int ai, int aj, int bi, int bj)
{
int opos;
- ASSERT2(BOARD(bi, bj) != EMPTY, bi, bj);
+ ASSERT2(IS_STONE(BOARD(bi, bj)), bi, bj);
ASSERT_ON_BOARD2(ai, aj);
@@ -3859,7 +3859,7 @@
int value = board[pos];
if (!active[pos])
value = GRAY;
- else if (board[pos] != EMPTY && countlib2(m, n) > 4)
+ else if (IS_STONE(board[pos]) && countlib2(m, n) > 4)
value |= HIGH_LIBERTY_BIT;
persistent_owl_cache[persistent_owl_cache_size].board[pos] = value;
@@ -3900,7 +3900,7 @@
int pos, float contribution)
{
int i, j, k;
- ASSERT1(board[pos] != EMPTY, pos);
+ ASSERT1(IS_STONE(board[pos]), pos);
for (i = 0; i < board_size; i++)
for (j = 0; j < board_size; j++) {
if (BOARD(i, j) != EMPTY)
@@ -3909,7 +3909,7 @@
int di = deltai[k];
int dj = deltaj[k];
if (ON_BOARD2(i+di, j+dj)
- && BOARD(i+di, j+dj) != EMPTY
+ && IS_STONE(BOARD(i+di, j+dj))
&& same_dragon(POS(i+di, j+dj), pos)
&& (countlib2(i+di, j+dj) <= 4
|| i == 0 || i == board_size-1
Index: readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.6
diff -u -r1.6 readconnect.c
--- readconnect.c 2001/10/11 15:39:37 1.6
+++ readconnect.c 2001/10/12 18:54:22
@@ -114,7 +114,7 @@
if (trymove(libs[0], OTHER_COLOR(board[str]),
"snapback", str, EMPTY, 0)) {
liberties=0;
- if (board[libs[0]] != EMPTY)
+ if (IS_STONE(board[libs[0]]))
liberties = countlib(libs[0]);
popgo();
if (liberties > 1)
Index: reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.21
diff -u -r1.21 reading.c
--- reading.c 2001/10/12 15:09:52 1.21
+++ reading.c 2001/10/12 18:54:35
@@ -391,7 +391,7 @@
attack_either(int astr, int bstr)
{
int color = board[astr];
- ASSERT1(color != EMPTY , astr);
+ ASSERT1(IS_STONE(color) , astr);
ASSERT1(color == board[bstr], bstr);
/* Start by attacking the string with the fewest liberties. On
@@ -425,7 +425,7 @@
int dcode = 0;
int color = board[astr];
- ASSERT1(color != EMPTY , astr);
+ ASSERT1(IS_STONE(color) , astr);
ASSERT1(color == board[bstr], bstr);
attack_and_defend(astr, &acode, NULL, &dcode, &cpos);
@@ -569,7 +569,7 @@
int success2 = 0;
/* Basic sanity checking. */
- ASSERT1(color != EMPTY , apos);
+ ASSERT1(IS_STONE(color) , apos);
ASSERT1(color == board[bpos], bpos);
ASSERT1(color == board[cpos], cpos);
@@ -1469,7 +1469,7 @@
SETUP_TRACE_INFO("defend1", str);
reading_node_counter++;
- gg_assert(board[str] != EMPTY);
+ gg_assert(IS_STONE(board[str]));
ASSERT1(countlib(str) == 1, str);
RTRACE("try to escape atari on %1m.\n", str);
@@ -1622,7 +1622,7 @@
color = board[str];
other = OTHER_COLOR(color);
- gg_assert(board[str] != EMPTY);
+ gg_assert(IS_STONE(board[str]));
gg_assert(countlib(str) == 2);
if ((stackp <= depth) && (hashflags & HASH_DEFEND2)) {
@@ -1905,7 +1905,7 @@
color = board[str];
other = OTHER_COLOR(color);
- gg_assert(board[str] != EMPTY);
+ gg_assert(IS_STONE(board[str]));
gg_assert(countlib(str) == 3);
if ((stackp <= depth) && (hashflags & HASH_DEFEND3)) {
@@ -2223,7 +2223,7 @@
color = board[str];
other = OTHER_COLOR(color);
- gg_assert(board[str] != EMPTY);
+ gg_assert(IS_STONE(board[str]));
gg_assert(countlib(str) == 4);
if ((stackp <= depth) && (hashflags & HASH_DEFEND4)) {
@@ -3104,7 +3104,7 @@
reading_node_counter++;
str = find_origin(str);
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
ASSERT1(countlib(str) == 2, str);
RTRACE("checking attack on %1m with 2 liberties\n", str);
@@ -3400,7 +3400,7 @@
SETUP_TRACE_INFO("attack3", str);
reading_node_counter++;
- gg_assert(board[str] != EMPTY);
+ gg_assert(IS_STONE(board[str]));
if ((stackp <= depth) && (hashflags & HASH_ATTACK3)) {
found_read_result = get_read_result(ATTACK3, komaster, kom_pos,
@@ -3679,7 +3679,7 @@
SETUP_TRACE_INFO("attack4", str);
- gg_assert(board[str] != EMPTY);
+ gg_assert(IS_STONE(board[str]));
reading_node_counter++;
if (stackp > depth) {
@@ -4733,7 +4733,7 @@
if (!ko_move) {
if (countlib(bpos) <= 2)
try_harder = 1;
- if (board[str] != EMPTY) {
+ if (IS_STONE(board[str])) {
int dcode = do_find_defense(str, NULL, newer_komaster,
newer_kom_pos);
if (dcode == WIN && !try_harder) {
@@ -4753,7 +4753,7 @@
}
else {
try_harder = 1;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
if (do_find_defense(str, NULL, newer_komaster, newer_kom_pos) != 0) {
savecode = KO_A; /* Not KO_B since we are one move deeper
* than usual. */
@@ -5062,7 +5062,7 @@
SETUP_TRACE_INFO("restricted_defend1", str);
reading_node_counter++;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
ASSERT1(countlib(str) == 1, str);
RTRACE("try to escape atari on %1m.\n", str);
@@ -5190,7 +5190,7 @@
reading_node_counter++;
str = find_origin(str);
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
ASSERT1(countlib(str) == 2, str);
RTRACE("restricted attack on %1m with 2 liberties\n", str);
@@ -6031,7 +6031,7 @@
|| (ON_BOARD(WEST(k)) && active[WEST(k)] == 1)
|| (ON_BOARD(NORTH(k)) && active[NORTH(k)] == 1)
|| (ON_BOARD(EAST(k)) && active[EAST(k)] == 1)) {
- if (board[k] != EMPTY)
+ if (IS_STONE(board[k]))
mark_string(k, active, 2);
else
active[k] = 2;
@@ -6044,13 +6044,13 @@
for (k = BOARDMIN; k < BOARDMAX; k++) {
if (!ON_BOARD(k))
continue;
- if (board[k] != EMPTY && worm[k].invincible)
+ if (IS_STONE(board[k]) && worm[k].invincible)
active[k] = 0;
}
/* Expand empty to empty. */
for (k = BOARDMIN; k < BOARDMAX; k++) {
- if (board[k] != EMPTY || active[k] != 0)
+ if (IS_STONE(board[k]) || active[k] != 0)
continue;
if ((board[SOUTH(k)] == EMPTY && active[SOUTH(k)] == 2)
|| (board[WEST(k)] == EMPTY && active[WEST(k)] == 2)
@@ -6153,7 +6153,7 @@
int di = deltai[k];
int dj = deltaj[k];
if (ON_BOARD2(i+di, j+dj)
- && BOARD(i+di, j+dj) != EMPTY
+ && IS_STONE(BOARD(i+di, j+dj))
&& same_string(POS(i+di, j+dj), POS(m, n))) {
if (k < 4) {
values[i][j] += contribution;
@@ -6269,7 +6269,7 @@
int scores[2];
int k;
- ASSERT1(board[str] != EMPTY, str);
+ ASSERT1(IS_STONE(board[str]), str);
ASSERT1(countlib(str) == 2, str);
DEBUG(DEBUG_READING, "naive_ladder(%1m)\n", str);
Index: utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.21
diff -u -r1.21 utils.c
--- utils.c 2001/10/12 15:09:52 1.21
+++ utils.c 2001/10/12 18:54:39
@@ -701,7 +701,7 @@
int liberties = 0;
ASSERT1(board[pos] == EMPTY, pos);
- ASSERT1(color != EMPTY, pos);
+ ASSERT1(IS_STONE(color), pos);
/* Use tryko() since we don't care whether the move would violate
* the ko rule.
Index: worm.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/worm.c,v
retrieving revision 1.16
diff -u -r1.16 worm.c
--- worm.c 2001/10/12 15:09:52 1.16
+++ worm.c 2001/10/12 18:54:43
@@ -489,8 +489,8 @@
for (n = 0; n < board_size; n++) {
int pos = POS(m, n);
if (!is_same_worm(pos, SOUTH(pos))
- && IS_COLOR(board[pos])
- && IS_COLOR(board[SOUTH(pos)])) {
+ && IS_STONE(board[pos])
+ && IS_STONE(board[SOUTH(pos)])) {
if (worm[pos].attack_codes[0] != 0
&& worm[SOUTH(pos)].attack_codes[0] != 0) {
if (worm[pos].defend_codes[0] == 0
@@ -512,8 +512,8 @@
for (n = 0; n < board_size-1; n++) {
int pos = POS(m, n);
if (!is_same_worm(pos, EAST(pos))
- && IS_COLOR(board[pos])
- && IS_COLOR(board[EAST(pos)])) {
+ && IS_STONE(board[pos])
+ && IS_STONE(board[EAST(pos)])) {
if (worm[pos].attack_codes[0] != 0
&& worm[EAST(pos)].attack_codes[0] != 0) {
if (worm[pos].defend_codes[0] == 0
@@ -633,7 +633,7 @@
worm[pos].invincible = 0;
worm[pos].unconditional_status = UNKNOWN;
worm[pos].effective_size = 0.0;
- if (IS_COLOR(board[pos])) {
+ if (IS_STONE(board[pos])) {
worm[pos].liberties = countlib(pos);
worm[pos].size = countstones(pos);
propagate_worm(pos);
@@ -740,7 +740,7 @@
/* Propagate the effective size values all over the worms. */
for (m = 0; m < board_size; m++)
for (n = 0; n < board_size; n++)
- if (IS_COLOR(BOARD(m, n)) && is_worm_origin(POS(m, n), POS(m, n)))
+ if (IS_STONE(BOARD(m, n)) && is_worm_origin(POS(m, n), POS(m, n)))
propagate_worm(POS(m, n));
}
@@ -1004,7 +1004,7 @@
int bb = libs[k] + delta[l];
if (!ON_BOARD(bb)
- || IS_COLOR(board[bb])
+ || IS_STONE(board[bb])
|| liberty_of_string(bb, pos))
continue;
@@ -1066,7 +1066,7 @@
int bb = libs[k] + delta[l];
if (!ON_BOARD(bb)
- || IS_COLOR(board[bb])
+ || IS_STONE(board[bb])
|| liberty_of_string(bb, pos))
continue;
@@ -1107,7 +1107,7 @@
int i, j;
int k;
- ASSERT1(IS_COLOR(board[str]), str);
+ ASSERT1(IS_STONE(board[str]), str);
ASSERT1(stackp == 0, str);
*lunch = NO_MOVE;
@@ -1402,7 +1402,7 @@
int num_stones;
int stones[MAX_BOARD * MAX_BOARD];
gg_assert(stackp == 0);
- ASSERT1(IS_COLOR(board[pos]), pos);
+ ASSERT1(IS_STONE(board[pos]), pos);
num_stones = findstones(pos, MAX_BOARD * MAX_BOARD, stones);
for (k = 0; k < num_stones; k++)
@@ -1422,7 +1422,7 @@
{
int pos;
ASSERT_ON_BOARD1(str);
- ASSERT1(IS_COLOR(worm[str].color), str);
+ ASSERT1(IS_STONE(worm[str].color), str);
for (pos = BOARDMIN; pos < BOARDMAX; pos++)
if (board[pos] == board[str] && is_same_worm(pos, str))
@@ -1662,7 +1662,7 @@
*edge = 0;
- if (IS_COLOR(board[pos]))
+ if (IS_STONE(board[pos]))
origin = find_origin(pos);
cavity_recurse(pos, ml, &border_color, edge, origin);