[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] new cache for break-in
From: |
Arend Bayer |
Subject: |
[gnugo-devel] new cache for break-in |
Date: |
Sun, 18 Jan 2004 13:10:11 +0100 (CET) |
This patch converts the break-in code to use Inge's new cache. It will
conflict slightly with Inge's owl patch, as I had to change the prototyp
of tt_get, too (adding the additional hash value to identify the goal).
But it should be trivial to merge.
No regression changes (*), almost no node count change.
Arend
(*) Apart from a mysterious PASS in century2002:240. Mysterious because
the cvs version also passes when the test is invoked separately. I didn't
investigate this closer.
- convert break-in reading to use new cache implementation
Index: engine/cache.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v
retrieving revision 1.33
diff -u -p -r1.33 cache.c
--- engine/cache.c 13 Nov 2003 22:48:40 -0000 1.33
+++ engine/cache.c 18 Jan 2004 12:09:58 -0000
@@ -176,7 +176,7 @@ int
tt_get(Transposition_table *table,
int komaster, int kom_pos, enum routine_id routine, int target,
int remaining_depth,
- int *result, int *move)
+ int *result, int *move, Hash_data *extra_hash)
{
Hash_data hashval;
Hashentry_ng *entry;
@@ -185,6 +185,8 @@ tt_get(Transposition_table *table,
/* Get the combined hash value. */
calculate_hashval_for_tt(komaster, kom_pos, routine, target,
&hashval);
+ if (extra_hash)
+ hashdata_xor(hashval, *extra_hash);
/* Sanity check. */
if (remaining_depth < 0)
Index: engine/cache.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v
retrieving revision 1.38
diff -u -p -r1.38 cache.h
--- engine/cache.h 16 Jan 2004 12:42:09 -0000 1.38
+++ engine/cache.h 18 Jan 2004 12:09:59 -0000
@@ -101,7 +101,8 @@ void tt_free(Transposition_table *table)
int tt_get(Transposition_table *table,
int komaster, int kom_pos, enum routine_id routine,
int target, int remaining_depth,
- int *result, int *move);
+ int *result, int *move,
+ Hash_data *extra_hash);
void tt_update(Transposition_table *table,
int komaster, int kom_pos, enum routine_id routine,
int target, int remaining_depth,
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.62
diff -u -p -r1.62 readconnect.c
--- engine/readconnect.c 16 Jan 2004 12:43:25 -0000 1.62
+++ engine/readconnect.c 18 Jan 2004 12:10:02 -0000
@@ -2714,9 +2714,13 @@ recursive_break(int str, const char goal
int xpos;
int savemove = NO_MOVE;
int savecode = 0;
- int found_read_result;
int tried_moves = 0;
+#if USE_HASHTABLE_NG
+ int retval;
+#else
+ int found_read_result;
Read_result *read_result = NULL;
+#endif
SETUP_TRACE_INFO("recursive_break", str);
@@ -2741,6 +2745,19 @@ recursive_break(int str, const char goal
return 0;
}
+#if USE_HASHTABLE_NG
+ if (stackp <= depth
+ && (hashflags & HASH_BREAK_IN)
+ && !has_passed
+ && tt_get(&ttable, komaster, kom_pos, BREAK_IN, str,
+ depth - stackp, &retval, &xpos, goal_hash) == 2) {
+ /* FIXME: Use move for move ordering if tt_get() returned 1 */
+ SGFTRACE(xpos, retval, "cached");
+ if (move)
+ *move = xpos;
+ return retval;
+ }
+#else
if (stackp <= depth
&& (hashflags & HASH_BREAK_IN)
&& !has_passed) {
@@ -2758,6 +2775,7 @@ recursive_break(int str, const char goal
return rr_get_result(*read_result);
}
}
+#endif
#if 0
if (trivial_connection(str1, str2, &xpos) == WIN) {
@@ -2786,7 +2804,12 @@ recursive_break(int str, const char goal
popgo();
if (acode == 0) {
SGFTRACE(xpos, WIN, "break effective");
+#if USE_HASHTABLE_NG
+ READ_RETURN_NG(komaster, kom_pos, BREAK_IN, str, depth - stackp,
+ move, xpos, WIN);
+#else
READ_RETURN(read_result, move, xpos, WIN);
+#endif
}
/* if the move works with ko we save it, then look for something
* better.
@@ -2806,16 +2829,31 @@ recursive_break(int str, const char goal
if (tried_moves == 0 && distance < 1.0) {
SGFTRACE(NO_MOVE, WIN, "no move, probably connected");
+#if USE_HASHTABLE_NG
+ READ_RETURN_NG(komaster, kom_pos, BREAK_IN, str, depth -stackp,
+ move, xpos, WIN);
+#else
READ_RETURN(read_result, move, NO_MOVE, WIN);
+#endif
}
if (savecode != 0) {
SGFTRACE(savemove, savecode, "saved move");
+#if USE_HASHTABLE_NG
+ READ_RETURN_NG(komaster, kom_pos, BREAK_IN, str, depth -stackp,
+ move, xpos, savecode);
+#else
READ_RETURN(read_result, move, savemove, savecode);
+#endif
}
SGFTRACE(0, 0, NULL);
+#if USE_HASHTABLE_NG
+ READ_RETURN_NG(komaster, kom_pos, BREAK_IN, str, depth -stackp,
+ move, xpos, 0);
+#else
READ_RETURN(read_result, move, NO_MOVE, 0);
+#endif
}
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.133
diff -u -p -r1.133 reading.c
--- engine/reading.c 14 Jan 2004 22:22:36 -0000 1.133
+++ engine/reading.c 18 Jan 2004 12:10:17 -0000
@@ -1225,7 +1225,7 @@ do_find_defense(int str, int *move, int
if ((stackp <= depth) && (hashflags & HASH_FIND_DEFENSE)
&& tt_get(&ttable, komaster, kom_pos, FIND_DEFENSE, str,
depth - stackp,
- &retval, &xpos) == 2) {
+ &retval, &xpos, NULL) == 2) {
/* Note that if return value is 1 (too small depth), the move will
* still be used for move ordering.
*/
@@ -3018,7 +3018,7 @@ do_attack(int str, int *move, int komast
if ((stackp <= depth) && (hashflags & HASH_ATTACK)
&& tt_get(&ttable, komaster, kom_pos, ATTACK, str,
depth - stackp,
- &retval, &xpos) == 2) {
+ &retval, &xpos, NULL) == 2) {
SGFTRACE(xpos, retval, "cached");
if (move)
*move = xpos;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] new cache for break-in,
Arend Bayer <=