[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] readconnect patch
From: |
Gunnar Farneback |
Subject: |
[gnugo-devel] readconnect patch |
Date: |
Sun, 28 Oct 2001 13:47:43 +0100 |
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) |
This is a patch to readconnect.c.
- add_array() in readconnect.c simplified
- bugfix in moves_to_connect_in_two_moves()
- sgf traces turned off in quiescence_capture()
The bugfix in moves_to_connect_in_two_moves() causes 5 unexpected
passes in test suite connect.tst (cases 6, 24, 27, 48, 68). Turning
off sgf traces in quiescence_capture() eliminates distracting
variations generated by the naive_ladder() call.
I'm slowly starting to find my way around the readconnect code. I have
a fairly good idea how to add testing of additional connecting moves.
What's still a mystery to me is how to fix disconnect mistakes in e.g.
the basic position in test case 2 of connect.tst. I'm just getting
lost in the maze of calls
recursive_disconnect() ->
prevent_connection_two_moves() ->
connection_two_moves() ->
connected_one_move() ->
connection_one_move()
and similar. Returning to connect:2, the problem is to try to
disconnect the two space jump on the third line between G17 and K17.
A B C D E F G H J K L M N O P Q R S T
19 . . . . . . . . . . . . . . . . . . . 19
18 . . . . . . . . . . . . . . . . . . . 18
17 . . . . O . X . . X . O . . . . . . . 17
16 . . . + . . . . . + . . . . . X . . . 16
15 . . . . O . . . . . . O . . . . . . . 15
14 . . . . . . . . . . . . . . . . . . . 14
13 . . . . O . O . O . O . . . . . . . . 13
What basically happens is that it first tries to determine whether X
can connect the two stones at all. This involves trying the moves
X H17 (generated by connection_two_moves())
O J17 (generated by connected_one_move())
to get to the position
A B C D E F G H J K L M N O P Q R S T
19 . . . . . . . . . . . . . . . . . . . 19
18 . . . . . . . . . . . . . . . . . . . 18
17 . . . . O . X X O X . O . . . . . . . 17
16 . . . + . . . . . + . . . . . X . . . 16
15 . . . . O . . . . . . O . . . . . . . 15
14 . . . . . . . . . . . . . . . . . . . 14
13 . . . . O . O . O . O . . . . . . . . 13
and then connection_one_move() says "no, no connection" and the
variation is disregarded. After trying the symmetric moves X J17 and O
H17 with the same result it gives up and says "G17 and K17 are
disconnected as it stands". Clearly something goes wrong here but I
don't know how to deal with it. One can notice that
recursive_connect() manages to find a connection, but this involves
other code than the functionns called from recursive_disconnect().
Tristan, could you try to explain the overall structure of the code?
Which function needs to be improved/bugfixed to solve the mistake
above?
/Gunnar
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.8
diff -u -r1.8 readconnect.c
--- engine/readconnect.c 2001/10/13 15:29:15 1.8
+++ engine/readconnect.c 2001/10/28 12:11:58
@@ -63,16 +63,15 @@
int nodes_connect=0,max_nodes_connect=2000,max_connect_depth=64;
static int add_array (int *array, int elt) {
- int r, add = 1;
+ int r;
- for (r = 1; ((r < array[0] + 1) && add); r++)
+ for (r = 1; r < array[0] + 1; r++)
if (array[r] == elt)
- add = 0;
- if (add) {
- array[0]++;
- array[array[0]] = elt;
- }
- return add;
+ return 0;
+
+ array[0]++;
+ array[array[0]] = elt;
+ return 1;
}
static int element_array (int *array,int elt) {
@@ -259,19 +258,19 @@
add_array(moves, WEST(libs[r]));
}
}
- else if (board[EAST(libs[r])] == EMPTY) {
+ if (board[EAST(libs[r])] == EMPTY) {
if (liberty_of_string(EAST(libs[r]), str2)) {
add_array(moves, libs[r]);
add_array(moves, EAST(libs[r]));
}
}
- else if (board[SOUTH(libs[r])] == EMPTY) {
+ if (board[SOUTH(libs[r])] == EMPTY) {
if (liberty_of_string(SOUTH(libs[r]), str2)) {
add_array(moves, libs[r]);
add_array(moves, SOUTH(libs[r]));
}
}
- else if (board[NORTH(libs[r])] == EMPTY) {
+ if (board[NORTH(libs[r])] == EMPTY) {
if (liberty_of_string(NORTH(libs[r]), str2)) {
add_array(moves, libs[r]);
add_array(moves, NORTH(libs[r]));
@@ -543,13 +542,28 @@
}
static int quiescence_capture (int str, int *move) {
+ SGFTree *save_sgf_dumptree = sgf_dumptree;
+ int save_count_variations = count_variations;
+ int result = 0;
+
+ /* We turn off the sgf traces here to avoid cluttering them up with
+ * naive_ladder moves.
+ */
+ sgf_dumptree = NULL;
+ count_variations = 0;
+
if (countlib(str) == 1) {
findlib(str, 1, move);
- return WIN;
+ result = WIN;
}
else if (countlib(str) == 2)
- return naive_ladder(str, move);
- return 0;
+ result = naive_ladder(str, move);
+
+ /* Turn the sgf traces back on. */
+ sgf_dumptree = save_sgf_dumptree;
+ count_variations = save_count_variations;
+
+ return result;
}
/* static int capture_one_move (int str) { */
- [gnugo-devel] readconnect patch,
Gunnar Farneback <=