[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] First patch in a while
From: |
Inge Wallin |
Subject: |
[gnugo-devel] First patch in a while |
Date: |
Sat, 21 Sep 2002 23:31:11 +0200 (MEST) |
Here is my first patch for a long time, inge_3_9.1. I decided that
over 150 FIXMEs in the code was too much so I wanted to trim them a
bit. The diff is against the current CVS version.
In the process, I also unified the naming conventions for struct worm_data.
changes:
- report_worm(): print all attack, defense, attack threat and
defense threat points/codes
- worm_data::defend_codes is now called defense_codes
- enhanced result_to_string() with new return codes.
- removed strategically_sound_defense()
-Inge
================================================================
Index: engine/aftermath.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/aftermath.c,v
retrieving revision 1.33
diff -u -r1.33 aftermath.c
--- engine/aftermath.c 10 Sep 2002 20:06:01 -0000 1.33
+++ engine/aftermath.c 21 Sep 2002 21:16:28 -0000
@@ -586,7 +586,7 @@
for (r = 0; r < neighbors; r++) {
if (worm[adjs[r]].attack_codes[0] != 0
&& (find_defense(adjs[r], NULL)
- > worm[adjs[r]].defend_codes[0])) {
+ > worm[adjs[r]].defense_codes[0])) {
DEBUG(DEBUG_AFTERMATH,
"Blunder: %1m becomes tactically safer after %1m\n",
adjs[r], move);
Index: engine/combination.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/combination.c,v
retrieving revision 1.33
diff -u -r1.33 combination.c
--- engine/combination.c 10 Sep 2002 20:06:01 -0000 1.33
+++ engine/combination.c 21 Sep 2002 21:16:28 -0000
@@ -447,7 +447,7 @@
else if (dragon[pos].status == CRITICAL)
aa_status[pos] = CRITICAL;
else if (worm[pos].attack_codes[0] != 0) {
- if (worm[pos].defend_codes[0] != 0)
+ if (worm[pos].defense_codes[0] != 0)
aa_status[pos] = CRITICAL;
else
aa_status[pos] = DEAD;
Index: engine/dragon.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v
retrieving revision 1.78
diff -u -r1.78 dragon.c
--- engine/dragon.c 18 Sep 2002 15:10:01 -0000 1.78
+++ engine/dragon.c 21 Sep 2002 21:16:28 -0000
@@ -158,7 +158,7 @@
/* In contrast to worm lunches, a dragon lunch must also be
* able to defend itself.
*/
- if (worm[food].defend_codes[0] == 0)
+ if (worm[food].defense_codes[0] == 0)
continue;
/* Tell the move generation code about the lunch. */
@@ -543,7 +543,7 @@
dragon2[d].safety = INESSENTIAL;
else if (dragon[origin].size == worm[origin].size
&& worm[origin].attack_codes[0] != 0
- && worm[origin].defend_codes[0] == 0)
+ && worm[origin].defense_codes[0] == 0)
dragon2[d].safety = TACTICALLY_DEAD;
else if (0) /* Seki is detected by the call to semeai() below. */
dragon2[d].safety = ALIVE_IN_SEKI;
@@ -596,7 +596,7 @@
if (ON_BOARD(str)) {
if (is_worm_origin(str, str)
&& worm[str].attack_codes[0] != 0
- && worm[str].defend_codes[0] != 0
+ && worm[str].defense_codes[0] != 0
&& !worm[str].inessential) {
int adjs[MAXCHAIN];
int neighbors;
@@ -1088,11 +1088,11 @@
}
for (k = 0; k < MAX_TACTICAL_POINTS; k++) {
- if (w->defend_codes[k] == 0)
+ if (w->defense_codes[k] == 0)
break;
- if (w->defend_codes[k] != 0)
+ if (w->defense_codes[k] != 0)
gprintf("- defendable at %1m, defend code = %d\n",
- w->defense_points[k], w->defend_codes[k]);
+ w->defense_points[k], w->defense_codes[k]);
}
for (k = 0; k < MAX_TACTICAL_POINTS; k++) {
@@ -1318,13 +1318,13 @@
*/
if (dragon[pos].size == worm[pos].size
&& worm[pos].attack_codes[0] != 0
- && worm[pos].defend_codes[0] == 0
+ && worm[pos].defense_codes[0] == 0
&& true_genus < 3)
return DEAD;
if (lunch != NO_MOVE
&& true_genus < 3
- && worm[lunch].defend_codes[0] != 0
+ && worm[lunch].defense_codes[0] != 0
&& DRAGON2(pos).escape_route < 5)
if (true_genus == 2 || worm[lunch].size > 2)
return CRITICAL;
Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.60
diff -u -r1.60 influence.c
--- engine/influence.c 10 Sep 2002 15:05:42 -0000 1.60
+++ engine/influence.c 21 Sep 2002 21:16:29 -0000
@@ -404,7 +404,7 @@
|| (saved_stones[pos] == INFLUENCE_UNCHANGED_STONE
&& ((worm[pos].attack_codes[0] != 0
&& (OTHER_COLOR(q->p[i][j]) == color
- || worm[pos].defend_codes[0] == 0))
+ || worm[pos].defense_codes[0] == 0))
|| (q->dragons_known
&& dragon[pos].id != -1
&& (DRAGON2(pos).safety == DEAD
@@ -1167,7 +1167,7 @@
int territory_color = whose_territory(q, m, n);
if (worm[POS(m, n)].attack_codes[0] != 0
- && worm[POS(m, n)].defend_codes[0] != 0)
+ && worm[POS(m, n)].defense_codes[0] != 0)
return EMPTY;
/* default */
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.115
diff -u -r1.115 liberty.h
--- engine/liberty.h 18 Sep 2002 15:10:02 -0000 1.115
+++ engine/liberty.h 21 Sep 2002 21:16:29 -0000
@@ -754,7 +754,7 @@
int attack_points[MAX_TACTICAL_POINTS];
int attack_codes[MAX_TACTICAL_POINTS];
int defense_points[MAX_TACTICAL_POINTS];
- int defend_codes[MAX_TACTICAL_POINTS];
+ int defense_codes[MAX_TACTICAL_POINTS];
int attack_threat_points[MAX_TACTICAL_POINTS];
int attack_threat_codes[MAX_TACTICAL_POINTS];
int defense_threat_points[MAX_TACTICAL_POINTS];
Index: engine/move_reasons.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v
retrieving revision 1.93
diff -u -r1.93 move_reasons.c
--- engine/move_reasons.c 17 Sep 2002 10:15:20 -0000 1.93
+++ engine/move_reasons.c 21 Sep 2002 21:16:29 -0000
@@ -339,7 +339,7 @@
case YOUR_ATARI_ATARI_MOVE:
return NO_MOVE;
}
- /* We shoud never get here: */
+ /* We should never get here: */
gg_assert(1>2);
return 0; /* To keep gcc happy. */
}
@@ -854,8 +854,8 @@
* Ignore the cut or connection if either (w1) or (w2)
* points to a tactically captured worm.
*/
- if ((worm[w1].attack_codes[0] != 0 && worm[w1].defend_codes[0] == 0)
- || (worm[w2].attack_codes[0] != 0 && worm[w2].defend_codes[0] == 0))
+ if ((worm[w1].attack_codes[0] != 0 && worm[w1].defense_codes[0] == 0)
+ || (worm[w2].attack_codes[0] != 0 && worm[w2].defense_codes[0] == 0))
return;
add_move_reason(pos, CUT_MOVE, connection);
@@ -968,7 +968,7 @@
/* If this string is already attacked, and with no defense, then
* there is no additional value of this move reason. */
if (worm[target1].attack_codes[0] != 0
- && worm[target1].defend_codes[0] == 0)
+ && worm[target1].defense_codes[0] == 0)
return;
}
break;
@@ -985,7 +985,7 @@
/* If this string is already attacked, and with no defense, then
* there is no additional value of this move reason. */
if (worm[target2].attack_codes[0] != 0
- && worm[target2].defend_codes[0] == 0)
+ && worm[target2].defense_codes[0] == 0)
return;
}
break;
@@ -1546,7 +1546,7 @@
if (board[pos] == OTHER_COLOR(color)) {
if (dragon[pos].status == DEAD
|| (worm[pos].attack_codes[0] != 0
- && worm[pos].defend_codes[0] == 0))
+ && worm[pos].defense_codes[0] == 0))
safe_stones[pos] = 0;
else
safe_stones[pos] = 1;
@@ -1555,7 +1555,7 @@
if (dragon[pos].status == DEAD
|| (dragon[pos].status == CRITICAL && !saved_dragons[pos])
|| (worm[pos].attack_codes[0] != 0
- && (worm[pos].defend_codes[0] == 0 || !saved_worms[pos])))
+ && (worm[pos].defense_codes[0] == 0 || !saved_worms[pos])))
safe_stones[pos] = 0;
else
safe_stones[pos] = 1;
@@ -1599,17 +1599,17 @@
case ATTACK_MOVE:
aa = worms[move_reasons[r].what];
gprintf("Move at %1m attacks %1m%s\n", pos, aa,
- (worm[aa].defend_codes[0] == 0) ? " (defenseless)" : "");
+ (worm[aa].defense_codes[0] == 0) ? " (defenseless)" : "");
break;
case ATTACK_MOVE_GOOD_KO:
aa = worms[move_reasons[r].what];
gprintf("Move at %1m attacks %1m%s with good ko\n", pos, aa,
- (worm[aa].defend_codes[0] == 0) ? " (defenseless)" : "");
+ (worm[aa].defense_codes[0] == 0) ? " (defenseless)" : "");
break;
case ATTACK_MOVE_BAD_KO:
aa = worms[move_reasons[r].what];
gprintf("Move at %1m attacks %1m%s with bad ko\n", pos, aa,
- (worm[aa].defend_codes[0] == 0) ? " (defenseless)" : "");
+ (worm[aa].defense_codes[0] == 0) ? " (defenseless)" : "");
break;
case DEFEND_MOVE:
Index: engine/optics.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/optics.c,v
retrieving revision 1.50
diff -u -r1.50 optics.c
--- engine/optics.c 18 Sep 2002 15:10:02 -0000 1.50
+++ engine/optics.c 21 Sep 2002 21:16:30 -0000
@@ -453,7 +453,7 @@
else
result = (!worm[pos].inessential
&& (worm[pos].attack_codes[0] == 0
- || worm[pos].defend_codes[0] != 0));
+ || worm[pos].defense_codes[0] != 0));
return result;
}
@@ -1654,7 +1654,7 @@
if (stackp == 0) {
acode = worm[pos].attack_codes[0];
apos = worm[pos].attack_points[0];
- dcode = worm[pos].defend_codes[0];
+ dcode = worm[pos].defense_codes[0];
dpos = worm[pos].defense_points[0];
}
else
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.104
diff -u -r1.104 owl.c
--- engine/owl.c 18 Sep 2002 15:10:02 -0000 1.104
+++ engine/owl.c 21 Sep 2002 21:16:31 -0000
@@ -3418,6 +3418,7 @@
for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
if (!ON_BOARD(pos) || board[pos] == EMPTY)
continue;
+
if (dragon[pos].origin == pos
&& dragon[pos].status == CRITICAL
&& dragon[pos].owl_attack_point != NO_MOVE) {
Index: engine/printutils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v
retrieving revision 1.25
diff -u -r1.25 printutils.c
--- engine/printutils.c 4 Sep 2002 07:23:46 -0000 1.25
+++ engine/printutils.c 21 Sep 2002 21:16:31 -0000
@@ -422,18 +422,18 @@
const char *
result_to_string(int result)
{
- if (result == 0)
- return "0";
- else if (result == KO_A)
- return "KO_A";
- else if (result == KO_B)
- return "KO_B";
- else if (result == WIN)
- return "WIN";
- else if (result == ALIVE_IN_SEKI)
- return "SEKI";
- else
- return "ERROR";
+ switch (result) {
+ case 0: return "0";
+ case KO_B: return "KO_B";
+ case LOSS: return "LOSS";
+ case GAIN: return "GAIN";
+ case KO_A: return "KO_A";
+ case WIN: return "WIN";
+
+ /* ALIVE_IN_SEKI is not defined as a return code, but is used here anyhow. */
+ case ALIVE_IN_SEKI: return "SEKI";
+ default: return "ERROR";
+ }
}
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.70
diff -u -r1.70 reading.c
--- engine/reading.c 11 Sep 2002 15:33:17 -0000 1.70
+++ engine/reading.c 21 Sep 2002 21:16:32 -0000
@@ -982,7 +982,7 @@
if (stackp == 0) {
if (r == -1)
continue;
- if (worm[adjs[k]].defend_codes[r] == 0)
+ if (worm[adjs[k]].defense_codes[r] == 0)
break;
bb = worm[adjs[k]].defense_points[r];
}
Index: engine/semeai.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/semeai.c,v
retrieving revision 1.44
diff -u -r1.44 semeai.c
--- engine/semeai.c 16 Sep 2002 07:27:49 -0000 1.44
+++ engine/semeai.c 21 Sep 2002 21:16:32 -0000
@@ -863,7 +863,7 @@
owl_analyze_semeai(apos, bpos, &resulta, &resultb, &move, 0);
if (resulta != DEAD
- && worm[apos].defend_codes[0] == 0
+ && worm[apos].defense_codes[0] == 0
&& move != NO_MOVE) {
if (save_verbose)
gprintf("small semeai: changing defense of %1m to %1m\n",
Index: engine/utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.52
diff -u -r1.52 utils.c
--- engine/utils.c 18 Sep 2002 12:00:25 -0000 1.52
+++ engine/utils.c 21 Sep 2002 21:16:33 -0000
@@ -105,7 +105,7 @@
if (stackp == 0) {
if (worm[str].attack_codes[0] != 0
- && worm[str].defend_codes[0] == 0)
+ && worm[str].defense_codes[0] == 0)
return 0;
spos = worm[str].defense_points[0];
}
@@ -1001,7 +1001,7 @@
else if (board[pos] == other
&& worm[pos].origin == pos
&& worm[pos].attack_codes[0] != 0
- && worm[pos].defend_codes[0] == 0
+ && worm[pos].defense_codes[0] == 0
&& find_defense(pos, NULL)) {
/* A dead opponent's worm has become defendable.
* Also ask the owl code whether the string can live
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.53
diff -u -r1.53 value_moves.c
--- engine/value_moves.c 16 Sep 2002 07:27:49 -0000 1.53
+++ engine/value_moves.c 21 Sep 2002 21:16:34 -0000
@@ -142,7 +142,7 @@
if (board[ii]
&& worm[ii].origin == ii
&& worm[ii].attack_codes[0] != 0
- && worm[ii].defend_codes[0] != 0) {
+ && worm[ii].defense_codes[0] != 0) {
unstable_worms[N] = find_worm(ii);
N++;
}
@@ -208,7 +208,7 @@
&& !attack_move_reason_known(ii, unstable_worms[k])) {
int dcode = find_defense(aa, NULL);
- if (dcode < worm[aa].defend_codes[0]) {
+ if (dcode < worm[aa].defense_codes[0]) {
/* Maybe find_defense() doesn't find the defense. Try to
* defend with the stored defense move.
*/
@@ -220,7 +220,7 @@
int this_dcode = REVERSE_RESULT(attack(aa, NULL));
if (this_dcode > dcode) {
dcode = this_dcode;
- if (dcode >= worm[aa].defend_codes[0])
+ if (dcode >= worm[aa].defense_codes[0])
attack_works = 0;
}
popgo();
@@ -409,22 +409,6 @@
}
-/*
- * It's often bad to run away with a worm that is in a strategically
- * weak position. This function gives heuristics for determining
- * whether a move at (ti, tj) to defend the worm (ai, aj) is
- * strategically sound.
- *
- * FIXME: This function has played out its role. Should be eliminated.
- */
-static int
-strategically_sound_defense(int aa, int tt)
-{
- UNUSED(aa);
- return move[tt].move_safety;
-}
-
-
/*
* Any move that captures or defends a worm also potentially connects
@@ -472,7 +456,7 @@
color_to_move = board[aa];
}
- if (worm[aa].defend_codes[0] == 0)
+ if (worm[aa].defense_codes[0] == 0)
continue; /* No defense. */
/* Don't care about inessential dragons. */
@@ -486,7 +470,7 @@
*
* FIXME: We may want to revise this policy.
*/
- if (!attack_move && !strategically_sound_defense(aa, pos))
+ if (!attack_move && !move[pos].move_safety)
continue;
num_adj = extended_chainlinks(aa, adjs, 1);
@@ -1236,7 +1220,7 @@
gg_assert(board[aa] != color);
/* Defenseless stone. */
- if (worm[aa].defend_codes[0] == 0) {
+ if (worm[aa].defense_codes[0] == 0) {
DEBUG(DEBUG_MOVE_REASONS,
" %1m: %f (secondary) - attack on %1m (defenseless)\n",
pos, worm[aa].effective_size, aa);
@@ -1835,7 +1819,7 @@
aa = worms[worm1];
/* Defenseless stone */
- if (worm[aa].defend_codes[0] == 0)
+ if (worm[aa].defense_codes[0] == 0)
break;
/* FIXME: This is totally ad hoc, just guessing the value of
@@ -1943,6 +1927,8 @@
/* Also if there is a combination attack, we assume it covers
* the same thing.
+ * FIXME: This is only applicable as long as the only moves
+ * handled by EITHER_MOVE are attacks.
*/
if (move_reason_known(pos, MY_ATARI_ATARI_MOVE, -1))
break;
Index: engine/worm.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/worm.c,v
retrieving revision 1.41
diff -u -r1.41 worm.c
--- engine/worm.c 10 Sep 2002 20:17:27 -0000 1.41
+++ engine/worm.c 21 Sep 2002 21:16:34 -0000
@@ -303,21 +303,21 @@
*/
if (worm[str].color == OTHER_COLOR(color)
&& worm[str].attack_codes[0] != 0
- && worm[str].defend_codes[0] != 0) {
+ && worm[str].defense_codes[0] != 0) {
int dcode = find_defense(str, NULL);
- if (dcode < worm[str].defend_codes[0]) {
+ if (dcode < worm[str].defense_codes[0]) {
int attack_works = 1;
/* Sometimes find_defense() fails to find a
* defense which has been found by other means.
* Try if the old defense move still works.
*/
- if (worm[str].defend_codes[0] != 0
+ if (worm[str].defense_codes[0] != 0
&& trymove(worm[str].defense_points[0],
OTHER_COLOR(color), "make_worms", 0, EMPTY, 0)) {
int this_dcode = REVERSE_RESULT(attack(str, NULL));
if (this_dcode > dcode) {
dcode = this_dcode;
- if (dcode >= worm[str].defend_codes[0])
+ if (dcode >= worm[str].defense_codes[0])
attack_works = 0;
}
popgo();
@@ -381,12 +381,12 @@
&& !is_same_worm(pos, SOUTH(pos))) {
if (worm[pos].attack_codes[0] != 0
&& worm[SOUTH(pos)].attack_codes[0] != 0) {
- if (worm[pos].defend_codes[0] == 0
+ if (worm[pos].defense_codes[0] == 0
&& does_defend(worm[SOUTH(pos)].attack_points[0], pos)) {
/* FIXME: need to check ko relationship here */
change_defense(pos, worm[SOUTH(pos)].attack_points[0], WIN);
}
- if (worm[SOUTH(pos)].defend_codes[0] == 0
+ if (worm[SOUTH(pos)].defense_codes[0] == 0
&& does_defend(worm[pos].attack_points[0], SOUTH(pos))) {
/* FIXME: need to check ko relationship here */
change_defense(SOUTH(pos), worm[pos].attack_points[0], WIN);
@@ -402,12 +402,12 @@
&& !is_same_worm(pos, EAST(pos))) {
if (worm[pos].attack_codes[0] != 0
&& worm[EAST(pos)].attack_codes[0] != 0) {
- if (worm[pos].defend_codes[0] == 0
+ if (worm[pos].defense_codes[0] == 0
&& does_defend(worm[EAST(pos)].attack_points[0], pos)) {
/* FIXME: need to check ko relationship here */
change_defense(pos, worm[EAST(pos)].attack_points[0], WIN);
}
- if (worm[EAST(pos)].defend_codes[0] == 0
+ if (worm[EAST(pos)].defense_codes[0] == 0
&& does_defend(worm[pos].attack_points[0], EAST(pos))) {
/* FIXME: need to check ko relationship here */
change_defense(EAST(pos), worm[pos].attack_points[0], WIN);
@@ -725,7 +725,7 @@
for (k = 0; k < MAX_TACTICAL_POINTS; k++) {
worm[str].attack_codes[k] = 0;
worm[str].attack_points[k] = 0;
- worm[str].defend_codes[k] = 0;
+ worm[str].defense_codes[k] = 0;
worm[str].defense_points[k] = 0;
}
propagate_worm(str);
@@ -823,7 +823,7 @@
}
/* Try to defend at the liberty. */
if (!defense_move_known(pos, str)) {
- if (worm[str].defend_codes[0] != 0)
+ if (worm[str].defense_codes[0] != 0)
if (trymove(pos, color, "make_worms", NO_MOVE, EMPTY, NO_MOVE)) {
acode = attack(str, NULL);
if (acode != WIN)
@@ -871,11 +871,11 @@
num_adj = chainlinks(str, adjs);
for (k = 0; k < num_adj; k++) {
if (worm[adjs[k]].attack_codes[0] != 0
- && worm[adjs[k]].defend_codes[0] != 0)
+ && worm[adjs[k]].defense_codes[0] != 0)
for (r = 0; r < MAX_TACTICAL_POINTS; r++) {
int bb;
- if (worm[adjs[k]].defend_codes[r] == 0)
+ if (worm[adjs[k]].defense_codes[r] == 0)
break;
bb = worm[adjs[k]].defense_points[r];
if (trymove(bb, other, "threaten attack", str,
@@ -898,7 +898,7 @@
/* 2. Continue with finding defense threats. */
/* Only try those worms that have an attack. */
if (worm[str].attack_codes[0] != 0
- && worm[str].defend_codes[0] == 0) {
+ && worm[str].defense_codes[0] == 0) {
liberties = findlib(str, MAXLIBS, libs);
@@ -1033,7 +1033,7 @@
{
str = worm[str].origin;
change_tactical_point(str, move, dcode,
- worm[str].defense_points, worm[str].defend_codes);
+ worm[str].defense_points, worm[str].defense_codes);
}
@@ -1112,7 +1112,7 @@
{
return movelist_move_known(move, MAX_TACTICAL_POINTS,
worm[str].defense_points,
- worm[str].defend_codes);
+ worm[str].defense_codes);
}
/* Check whether (move) is listed as an attack threat point for (str)
@@ -1231,9 +1231,9 @@
if (board[pos] == color) {
for (k = 0; k < MAX_TACTICAL_POINTS; k++) {
- if (worm[pos].defend_codes[k] != 0)
+ if (worm[pos].defense_codes[k] != 0)
add_defense_move(worm[pos].defense_points[k], pos,
- worm[pos].defend_codes[k]);
+ worm[pos].defense_codes[k]);
if (worm[pos].defense_threat_codes[k] != 0)
add_defense_threat_move(worm[pos].defense_threat_points[k], pos,
@@ -1580,7 +1580,7 @@
/* No defenses are known at this time, so defend_code is always 0. */
#if 0
/* If the string can be attacked but not defended, ignore it. */
- if (worm[str].attack_codes[0] == WIN && worm[str].defend_codes[0] == 0)
+ if (worm[str].attack_codes[0] == WIN && worm[str].defense_codes[0] == 0)
continue;
#endif
@@ -1710,7 +1710,9 @@
void
report_worm(int m, int n)
{
- int pos = POS(m, n);
+ int pos = POS(m, n);
+ int i;
+
if (board[pos] == EMPTY) {
gprintf("There is no worm at %1m\n", pos);
return;
@@ -1727,35 +1729,72 @@
worm[pos].liberties3,
worm[pos].liberties4);
- /* FIXME: List all attack points. */
- if (worm[pos].attack_points[0] != NO_MOVE)
- gprintf("attack point %1m, ", worm[pos].attack_points[0]);
- else
+ /* List all attack points. */
+ if (worm[pos].attack_points[0] == NO_MOVE)
gprintf("no attack point, ");
+ else {
+ gprintf("attack point(s):");
+ i = 0;
+ while (worm[pos].attack_points[i] != NO_MOVE) {
+ if (i > 0)
+ gprintf(",");
+ gprintf(" %1m: %s", worm[pos].attack_points[i],
+ result_to_string(worm[pos].attack_codes[i]));
+ i++;
+ }
+ gprintf("\n;");
+ }
- if (worm[pos].attack_codes[0] == WIN)
- gprintf("attack code WIN\n");
- else if (worm[pos].attack_codes[0] == KO_A)
- gprintf("attack code KO_A\n");
- else if (worm[pos].attack_codes[0] == KO_B)
- gprintf("attack code KO_B\n");
-
- /* FIXME: List all defense points. */
- if (worm[pos].defense_points[0] != NO_MOVE)
- gprintf("defense point %1m, ", worm[pos].defense_points[0]);
- else
+ /* List all defense points. */
+ if (worm[pos].defense_points[0] == NO_MOVE)
gprintf("no defense point, ");
+ else {
+ gprintf("defense point(s):");
+ i = 0;
+ while (worm[pos].defense_points[i] != NO_MOVE) {
+ if (i > 0)
+ gprintf(",");
+ gprintf(" %1m: %s", worm[pos].defense_points[i],
+ result_to_string(worm[pos].defense_codes[i]));
+ i++;
+ }
+ gprintf("\n;");
+ }
+
+ /* List all attack threat points. */
+ if (worm[pos].attack_threat_points[0] == NO_MOVE)
+ gprintf("no attack threat point, ");
+ else {
+ gprintf("attack threat point(s):");
+ i = 0;
+ while (worm[pos].attack_threat_points[i] != NO_MOVE) {
+ if (i > 0)
+ gprintf(",");
+ gprintf(" %1m: %s", worm[pos].attack_threat_points[i],
+ result_to_string(worm[pos].attack_threat_codes[i]));
+ i++;
+ }
+ gprintf("\n;");
+ }
- if (worm[pos].defend_codes[0] == WIN)
- gprintf("defend code WIN\n");
- else if (worm[pos].defend_codes[0] == KO_A)
- gprintf("defend code KO_A\n");
- else if (worm[pos].defend_codes[0] == KO_B)
- gprintf("defend code KO_B\n");
-
- /* FIXME: List all attack and defense threat points. */
+ /* List all defense threat points. */
+ if (worm[pos].defense_threat_points[0] == NO_MOVE)
+ gprintf("no defense threat point, ");
+ else {
+ gprintf("defense threat point(s):");
+ i = 0;
+ while (worm[pos].defense_threat_points[i] != NO_MOVE) {
+ if (i > 0)
+ gprintf(",");
+ gprintf(" %1m: %s", worm[pos].defense_threat_points[i],
+ result_to_string(worm[pos].defense_threat_codes[i]));
+ i++;
+ }
+ gprintf("\n;");
+ }
+ /* Report lunch if any. */
if (worm[pos].lunch != NO_MOVE)
gprintf("lunch at %1m\n", worm[pos].lunch);
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.91
diff -u -r1.91 play_gtp.c
--- interface/play_gtp.c 16 Sep 2002 08:37:08 -0000 1.91
+++ interface/play_gtp.c 21 Sep 2002 21:16:34 -0000
@@ -2607,7 +2607,7 @@
I(w->lunch), J(w->lunch));
gtp_mprintf("defense_point %m\n",
I(w->defense_points[0]), J(w->defense_points[0]));
- gtp_printf("defend_code %d\n", w->defend_codes[0]);
+ gtp_printf("defense_code %d\n", w->defense_codes[0]);
gtp_printf("cutstone %d\n", w->cutstone);
gtp_printf("cutstone2 %d\n", w->cutstone2);
gtp_printf("genus %d\n", w->genus);
Index: interface/debugboard/gui.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/debugboard/gui.c,v
retrieving revision 1.19
diff -u -r1.19 gui.c
--- interface/debugboard/gui.c 16 Sep 2002 07:27:49 -0000 1.19
+++ interface/debugboard/gui.c 21 Sep 2002 21:16:35 -0000
@@ -118,11 +118,11 @@
wmove(info_window, 10, 19 + i * 6);
if (worm[w].defense_points[i] == 0)
- gg_wprintw(info_window, "---:0 ", worm[w].defend_codes[i]);
+ gg_wprintw(info_window, "---:0 ", worm[w].defense_codes[i]);
else
gg_wprintw(info_window, "%3s:%d ",
location_to_string(worm[w].defense_points[i]),
- worm[w].defend_codes[i]);
+ worm[w].defense_codes[i]);
wmove(info_window, 11, 19 + i * 6);
if (worm[w].attack_threat_points[i] == 0)
@@ -162,7 +162,7 @@
if (worm[ii].attack_codes[i] != 0)
display_board_char(I(worm[ii].attack_points[i]),
J(worm[ii].attack_points[i]), 'A');
- if (worm[ii].defend_codes[i] != 0)
+ if (worm[ii].defense_codes[i] != 0)
display_board_char(I(worm[ii].defense_points[i]),
J(worm[ii].defense_points[i]), 'D');
if (worm[ii].attack_threat_codes[i] != 0)
Index: patterns/helpers.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/helpers.c,v
retrieving revision 1.38
diff -u -r1.38 helpers.c
--- patterns/helpers.c 5 Sep 2002 15:56:14 -0000 1.38
+++ patterns/helpers.c 21 Sep 2002 21:16:35 -0000
@@ -329,7 +329,7 @@
bpos = OFFSET(-1, 0);
cpos = OFFSET( 0, -1);
- if (worm[apos].defend_codes[0] == 0)
+ if (worm[apos].defense_codes[0] == 0)
return 0;
dpos = worm[apos].defense_points[0];
@@ -424,7 +424,7 @@
adj = chainlinks2(str, adjs, 1);
for (k = 0; k < adj; k++)
- if (worm[adjs[k]].defend_codes[0] != 0
+ if (worm[adjs[k]].defense_codes[0] != 0
&& !does_defend(move, adjs[k]))
return;
@@ -466,7 +466,7 @@
/* No value if the string can capture out of atari. */
adj = chainlinks2(str, adjs, 1);
for (k = 0; k < adj; k++)
- if (worm[adjs[k]].defend_codes[0] != 0
+ if (worm[adjs[k]].defense_codes[0] != 0
&& !does_defend(move, adjs[k]))
return;
Index: patterns/patterns.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v
retrieving revision 1.36
diff -u -r1.36 patterns.h
--- patterns/patterns.h 27 Aug 2002 18:06:16 -0000 1.36
+++ patterns/patterns.h 21 Sep 2002 21:16:35 -0000
@@ -93,7 +93,7 @@
#define ATTACK_MACRO(pos) ((stackp==0) ? (worm[pos].attack_codes[0]) :
attack(pos, NULL))
-#define DEFEND_MACRO(pos) ((stackp==0) ? (worm[pos].defend_codes[0]) :
find_defense(pos, NULL))
+#define DEFEND_MACRO(pos) ((stackp==0) ? (worm[pos].defense_codes[0]) :
find_defense(pos, NULL))
#define DRAGON_WEAK(pos) dragon_weak(pos)
struct pattern; /* forward reference to keep gcc happy */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] First patch in a while,
Inge Wallin <=