[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] breakin and readconnect fixes
From: |
Arend Bayer |
Subject: |
[gnugo-devel] breakin and readconnect fixes |
Date: |
Wed, 24 Mar 2004 16:32:57 +0100 (CET) |
> Arend wrote:
> > Btw, Paul, I tried to get on good terms with your change of the connection
> > queue logic (only storing the origin instead of each stone of a string)
> > and failed badly. So I hope you won't be too upset in case I revert that
> > change soon...
I still don't like it very much (as it transforms each loop over every
intersection in the connection queue into a double loop) but...
> I would like to see profiles before and after, btw.
...you seem to have a point here. (My reverting patch caused about 2%
performance penalty, I didn't investigate very closely.)
So instead of reverting your change, here is a patch with 3 fixes, two
of them resolving issues caused by your patch:
1. Ladder attack against "secondary target" in break-in reading only
makes sense in block_off reading (unrelated).
2. add_to_start_queue must be called with string origin.
3. Allow for strings to be partially in the break-in goal.
Arend
- fixes for breakin and connection reading
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.70
diff -u -p -r1.70 readconnect.c
--- engine/readconnect.c 11 Feb 2004 12:36:27 -0000 1.70
+++ engine/readconnect.c 24 Mar 2004 15:24:06 -0000
@@ -2753,12 +2753,21 @@ find_break_moves(int str, const char goa
compute_connection_distances(str, NO_MOVE, 2.501, &conn1, 1);
for (k = 0; k < conn1.queue_end; k++)
- if (goal[conn1.queue[k]]
- && board[conn1.queue[k]] == color) {
- str2 = conn1.queue[k];
- TRACE("%oUsing %1m as secondary target.\n", str2);
- mark_string(str2, breakin_shadow, 1);
- break;
+ if (board[conn1.queue[k]] == color) {
+ int stones[MAX_BOARD * MAX_BOARD];
+ int num_stones = findstones(conn1.queue[k],
+ MAX_BOARD * MAX_BOARD, stones);
+ int i;
+ for (i = 0; i < num_stones; i++) {
+ if (goal[stones[i]]) {
+ str2 = find_origin(stones[i]);
+ TRACE("%oUsing %1m as secondary target.\n", str2);
+ mark_string(str2, breakin_shadow, 1);
+ break;
+ }
+ }
+ if (i < num_stones)
+ break;
}
/* Add all stones in the goal to the queue. */
@@ -2802,7 +2811,7 @@ find_break_moves(int str, const char goa
moves, *total_distance, cutoff);
}
- {
+ if (color_to_move != board[str]) {
int move;
if (num_moves < MAX_MOVES
&& ON_BOARD(str2)
@@ -2810,6 +2819,7 @@ find_break_moves(int str, const char goa
moves[num_moves++] = move;
}
}
+
for (k = 0; k < num_moves; k++)
breakin_shadow[moves[k]] = 1;
@@ -4093,7 +4103,7 @@ compute_connection_distances(int str, in
clear_connection_data(conn);
/* Add the origin of the initial string to the queue. */
- add_to_start_queue(str, 0.0, conn);
+ add_to_start_queue(find_origin(str), 0.0, conn);
conn->target = target;
conn->cutoff_distance = cutoff;
- [gnugo-devel] breakin and readconnect fixes,
Arend Bayer <=