[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] abort on inconsistent genmove result
From: |
Gunnar Farneback |
Subject: |
Re: [gnugo-devel] abort on inconsistent genmove result |
Date: |
Mon, 16 Sep 2002 21:31:52 +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) |
Arend wrote:
> This was here caused by fill_liberty(). I am not familiar with the code
> there, but I guess it should now be rather easy to track the problem
> down.
The appended patch fixes the problem in fill_liberty(). As an extra
bonus I have included a revision of filllib_confirm_safety(), solving
filllib:39.
- bugfix in fill_liberty()
- filllib_confirm_safety() revised
/Gunnar
Index: engine/filllib.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/filllib.c,v
retrieving revision 1.24
diff -u -r1.24 filllib.c
--- engine/filllib.c 10 Sep 2002 20:17:27 -0000 1.24
+++ engine/filllib.c 16 Sep 2002 14:36:00 -0000
@@ -305,12 +305,16 @@
if (board[pos + d] == other
&& worm[pos + d].attack_codes[0] != 0) {
/* Just pick some other liberty. */
+ /* FIXME: Something is odd about this code. */
int libs[2];
if (findlib(pos + d, 2, libs) > 1) {
if (is_legal(libs[0], color))
*move = libs[0];
else if (is_legal(libs[1], color))
*move = libs[1];
+ else
+ continue;
+
DEBUG(DEBUG_FILLLIB, "Filllib: Found at %1m.\n", *move);
return 1;
}
@@ -517,7 +521,7 @@
&& !play_attack_defend_n(color, 0, 1, move, pos2)) {
int adj;
adj = chainlinks(pos2, adjs);
- /* It seems unlikely that we would ever get adjacent strings
+ /* It seems unlikely that we would ever get no adjacent strings
* here, but if it should happen we simply give up and say the
* move is unsafe.
*/
@@ -529,6 +533,24 @@
}
}
+ /* Next attempt are diagonal neighbors. */
+ if (apos == NO_MOVE) {
+ for (k = 4; k < 8; k++)
+ if (board[move + delta[k]] == color) {
+ apos = move + delta[k];
+ break;
+ }
+ }
+
+ /* And two steps away. */
+ if (apos == NO_MOVE) {
+ for (k = 0; k < 4; k++)
+ if (board[move + 2 * delta[k]] == color) {
+ apos = move + 2 * delta[k];
+ break;
+ }
+ }
+
/* We should have found something by now. If not something's
* probably broken elsewhere. Declare the move unsafe if it happens.
*/