[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] bug report
From: |
Gunnar Farnebäck |
Subject: |
Re: [gnugo-devel] bug report |
Date: |
Thu, 04 Nov 2004 00:40:27 +0100 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI) |
I wrote:
> There are at least two ways to fix this bug:
> 1. Change safe_move() to not cache results when reading at reduced
> depth. The main difficulty with this is that we currently have no
> way to detect reduced depth.
Implemented below. Fixes the crash.
- new global variable depth_offset
- only cache safe_move() results when reading depth is unmodified
/Gunnar
Index: engine/globals.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/globals.c,v
retrieving revision 1.67
diff -u -r1.67 globals.c
--- engine/globals.c 8 Jun 2004 05:06:12 -0000 1.67
+++ engine/globals.c 3 Nov 2004 21:18:07 -0000
@@ -49,6 +49,7 @@
int ko_depth; /* deep reading cut off */
int branch_depth; /* deep reading cut off */
int aa_depth;
+int depth_offset; /* keeps track of temporary depth changes */
int owl_distrust_depth; /* below this owl trusts the optics code */
int owl_branch_depth; /* below this owl tries only one variation */
int owl_reading_depth; /* owl does not read below this depth */
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.228
diff -u -r1.228 liberty.h
--- engine/liberty.h 11 Oct 2004 21:03:28 -0000 1.228
+++ engine/liberty.h 3 Nov 2004 21:18:07 -0000
@@ -719,6 +719,7 @@
extern int fourlib_depth; /* deep reading cutoff */
extern int ko_depth; /* deep ko reading cutoff */
extern int aa_depth; /* deep global reading cutoff */
+extern int depth_offset; /* keeps track of temporary depth changes */
extern int owl_distrust_depth; /* below this owl trusts the optics code */
extern int owl_branch_depth; /* below this owl tries only one variation */
extern int owl_reading_depth; /* owl does not read below this depth */
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.152
diff -u -r1.152 reading.c
--- engine/reading.c 8 Sep 2004 17:03:42 -0000 1.152
+++ engine/reading.c 3 Nov 2004 21:18:07 -0000
@@ -5558,8 +5558,12 @@
initialized = 1;
}
- /* If we have this position cached, use the previous value. */
+ /* If we have this position cached, use the previous value.
+ * Only use cached values when stackp is 0 and reading is not being done
+ * at a modified depth.
+ */
if (stackp == 0
+ && depth_offset == 0
&& safe_move_cache_when[move][color == BLACK] == position_number)
return safe_move_cache[move][color == BLACK];
@@ -5578,7 +5582,7 @@
* Comment: This is currently not a problem since no reduced depth
* reading is performed.
*/
- if (stackp == 0) {
+ if (stackp == 0 && depth_offset == 0) {
if (0)
gprintf("Safe move at %1m for %s cached when depth=%d, position
number=%d\n",
move, color_to_string(color), depth, position_number);
Index: engine/utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.97
diff -u -r1.97 utils.c
--- engine/utils.c 8 Sep 2004 17:03:42 -0000 1.97
+++ engine/utils.c 3 Nov 2004 21:18:08 -0000
@@ -806,6 +806,8 @@
if (mandated_owl_node_limit != -1)
owl_node_limit = mandated_owl_node_limit;
+ depth_offset = 0;
+
if (report_levels) {
fprintf(stderr, "at level %d:\n\n\
depth: %d\n\
@@ -861,6 +863,7 @@
fourlib_depth += n;
ko_depth += n;
breakin_depth += n;
+ depth_offset += n;
}
void