? regression/TEST.OUT Index: engine/cache.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v retrieving revision 1.37 diff -u -r1.37 cache.c --- engine/cache.c 24 Jan 2004 23:53:11 -0000 1.37 +++ engine/cache.c 4 Feb 2004 20:23:29 -0000 @@ -92,14 +92,17 @@ } static void -calculate_hashval_for_tt(int komaster, int kom_pos, int routine, int target, +calculate_hashval_for_tt(int komaster, int kom_pos, int routine, + int target1, int target2, Hash_data *hashdata2) { *hashdata2 = hashdata; /* from globals.c */ hashdata_xor(*hashdata2, komaster_hash[komaster]); hashdata_xor(*hashdata2, kom_pos_hash[kom_pos]); hashdata_xor(*hashdata2, routine_hash[routine]); - hashdata_xor(*hashdata2, target1_hash[target]); + hashdata_xor(*hashdata2, target1_hash[target1]); + if (target2 != NO_MOVE) + hashdata_xor(*hashdata2, target2_hash[target2]); } @@ -174,8 +177,8 @@ int tt_get(Transposition_table *table, - int komaster, int kom_pos, enum routine_id routine, int target, - int remaining_depth, + int komaster, int kom_pos, enum routine_id routine, + int target1, int target2, int remaining_depth, Hash_data *extra_hash, int *value1, int *value2, int *move) { @@ -184,7 +187,8 @@ Hashnode_ng *node; /* Get the combined hash value. */ - calculate_hashval_for_tt(komaster, kom_pos, routine, target, &hashval); + calculate_hashval_for_tt(komaster, kom_pos, routine, target1, target2, + &hashval); if (extra_hash) hashdata_xor(hashval, *extra_hash); @@ -226,7 +230,8 @@ void tt_update(Transposition_table *table, - int komaster, int kom_pos, enum routine_id routine, int target, + int komaster, int kom_pos, enum routine_id routine, + int target1, int target2, int remaining_depth, Hash_data *extra_hash, int value1, int value2, int move) @@ -238,7 +243,8 @@ unsigned int data; /* Get the combined hash value. */ - calculate_hashval_for_tt(komaster, kom_pos, routine, target, &hashval); + calculate_hashval_for_tt(komaster, kom_pos, routine, target1, target2, + &hashval); if (extra_hash) hashdata_xor(hashval, *extra_hash); @@ -1017,7 +1023,8 @@ */ int get_read_result2(enum routine_id routine, int komaster, int kom_pos, - int *str1, int *str2, Read_result **read_result) + int *str1, int *str2, + Read_result **read_result) { /* Only store the result if stackp <= depth. Above that, there * is no branching, so we won't gain anything. Index: engine/cache.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v retrieving revision 1.43 diff -u -r1.43 cache.h --- engine/cache.h 31 Jan 2004 12:50:12 -0000 1.43 +++ engine/cache.h 4 Feb 2004 20:23:29 -0000 @@ -100,12 +100,12 @@ 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 target1, int target2, int remaining_depth, Hash_data *extra_hash, int *value1, int *value2, int *move); void tt_update(Transposition_table *table, int komaster, int kom_pos, enum routine_id routine, - int target, int remaining_depth, + int target, int target2, int remaining_depth, Hash_data *extra_hash, int value1, int value2, int move); @@ -357,14 +357,34 @@ #define READ_RETURN0_NG(komaster, kom_pos, routine, str, remaining_depth) \ do { \ - tt_update(&ttable, komaster, kom_pos, routine, str, remaining_depth, \ - NULL, 0, 0, NO_MOVE);\ + tt_update(&ttable, komaster, kom_pos, routine, str, NO_MOVE, \ + remaining_depth, NULL,\ + 0, 0, NO_MOVE);\ return 0; \ } while (0) #define READ_RETURN_NG(komaster, kom_pos, routine, str, remaining_depth, point, move, value) \ do { \ - tt_update(&ttable, komaster, kom_pos, routine, str, remaining_depth, NULL,\ + tt_update(&ttable, komaster, kom_pos, routine, str, NO_MOVE, \ + remaining_depth, NULL,\ + value, 0, move);\ + if ((value) != 0 && (point) != 0) *(point) = (move); \ + return (value); \ + } while (0) + +#define READ_RETURN_SEMEAI_NG(komaster, kom_pos, routine, str1, str2, remaining_depth, point, move, value1, value2) \ + do { \ + tt_update(&ttable, komaster, kom_pos, routine, str1, str2, \ + remaining_depth, NULL, \ + value1, value2, move); \ + if ((value1) != 0 && (point) != 0) *(point) = (move); \ + return; \ + } while (0) + +#define READ_RETURN_CONN_NG(komaster, kom_pos, routine, str1, str2, remaining_depth, point, move, value) \ + do { \ + tt_update(&ttable, komaster, kom_pos, routine, str1, str2, \ + remaining_depth, NULL,\ value, 0, move);\ if ((value) != 0 && (point) != 0) *(point) = (move); \ return (value); \ @@ -372,7 +392,8 @@ #define READ_RETURN_HASH_NG(komaster, kom_pos, routine, str, remaining_depth, hash, point, move, value) \ do { \ - tt_update(&ttable, komaster, kom_pos, routine, str, remaining_depth, hash,\ + tt_update(&ttable, komaster, kom_pos, routine, str, NO_MOVE, \ + remaining_depth, hash,\ value, 0, move);\ if ((value) != 0 && (point) != 0) *(point) = (move); \ return (value); \ @@ -380,7 +401,8 @@ #define READ_RETURN2_NG(komaster, kom_pos, routine, str, remaining_depth, point, move, value1, value2) \ do { \ - tt_update(&ttable, komaster, kom_pos, routine, str, remaining_depth, NULL,\ + tt_update(&ttable, komaster, kom_pos, routine, str, NO_MOVE, \ + remaining_depth, NULL,\ value1, value2, move);\ if ((value1) != 0 && (point) != 0) *(point) = (move); \ return (value1); \ Index: engine/owl.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v retrieving revision 1.197 diff -u -r1.197 owl.c --- engine/owl.c 4 Feb 2004 16:04:21 -0000 1.197 +++ engine/owl.c 4 Feb 2004 20:23:30 -0000 @@ -547,7 +547,13 @@ const char *best_move_name = NULL; int this_resulta = -1; int this_resultb = -1; +#if USE_HASHTABLE_NG + int xpos; + int value1; + int value2; +#else Read_result *read_result = NULL; +#endif int this_variation_number = count_variations - 1; int you_look_alive = 0; int I_look_alive = 0; @@ -568,9 +574,33 @@ ASSERT1(board[apos] == owla->color, apos); ASSERT1(board[bpos] == owlb->color, bpos); +#if USE_HASHTABLE_NG + + if (stackp <= semeai_branch_depth && (hashflags & HASH_SEMEAI) + && !pass && owl_phase + && tt_get(&ttable, komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, NULL, + &value1, &value2, &xpos)) { + /* TRACE_CACHED_RESULT2(*read_result);*/ + if (value1 != 0) + *move = xpos; + + *resulta = value1; + *resultb = value2; + + TRACE("%oVariation %d: %1m %1m %s %s %1m (cached) ", + this_variation_number, apos, bpos, + result_to_string(*resulta), + result_to_string(*resultb), + *move); + SGFTRACE_SEMEAI(xpos, *resulta, *resultb, "cached"); + return; + } + +#else if (stackp <= semeai_branch_depth && (hashflags & HASH_SEMEAI) && !pass && owl_phase) { - if (get_read_result2(SEMEAI, EMPTY, 0, &apos, &bpos, &read_result)) { + if (get_read_result2(SEMEAI, EMPTY, NO_MOVE, &apos, &bpos, &read_result)) { TRACE_CACHED_RESULT2(*read_result); if (rr_get_result1(*read_result) != 0) @@ -590,6 +620,8 @@ } } +#endif + global_owl_node_counter++; local_owl_node_counter++; @@ -640,7 +672,12 @@ sgf_dumptree = save_sgf_dumptree; count_variations = save_count_variations; SGFTRACE_SEMEAI(upos, WIN, WIN, "tactical win found"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, upos, WIN, WIN); +#else READ_RETURN_SEMEAI(read_result, move, upos, WIN, WIN); +#endif } else if (acode != 0 && find_defense(semeai_worms[sworm], NULL)) { @@ -758,7 +795,12 @@ count_variations = save_count_variations; TRACE("Both live\n"); SGFTRACE_SEMEAI(PASS_MOVE, WIN, 0, "Both live"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, WIN, 0); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, WIN, 0); +#endif } /* Next the shape moves. */ @@ -991,7 +1033,12 @@ SGFTRACE_SEMEAI(mpos, WIN, WIN, moves[k].name); close_pattern_list(color, &shape_defensive_patterns); close_pattern_list(color, &shape_offensive_patterns); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, mpos, WIN, WIN); +#else READ_RETURN_SEMEAI(read_result, move, mpos, WIN, WIN); +#endif } /* When there is a choice between ko and seki, the prefer_ko * variable decides policy. Thus if prefer_ko == color we @@ -1025,7 +1072,12 @@ *resultb = 0; *move = PASS_MOVE; SGFTRACE_SEMEAI(PASS_MOVE, 0, 0, "You live, I die"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, 0, 0); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, 0, 0); +#endif } /* If we can't find a move and we look dead even if including the @@ -1052,7 +1104,12 @@ *resultb = 0; *move = PASS_MOVE; SGFTRACE_SEMEAI(PASS_MOVE, 0, 0, "You live, I die - 2"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, 0, 0); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, 0, 0); +#endif } include_semeai_worms_in_eyespace = 0; } @@ -1068,7 +1125,12 @@ *move = PASS_MOVE; TRACE("You have more eyes.\n"); SGFTRACE_SEMEAI(PASS_MOVE, 0, 0, "You have more eyes"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, 0, 0); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, 0, 0); +#endif } else if (max_eyes(&probable_eyes_b) < min_eyes(&probable_eyes_a)) { *resulta = WIN; @@ -1076,7 +1138,12 @@ *move = PASS_MOVE; TRACE("I have more eyes\n"); SGFTRACE_SEMEAI(PASS_MOVE, WIN, WIN, "I have more eyes"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, WIN, WIN); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, WIN, WIN); +#endif } else { *resulta = WIN; @@ -1084,7 +1151,12 @@ *move = PASS_MOVE; TRACE("Seki\n"); SGFTRACE_SEMEAI(PASS_MOVE, WIN, 0, "Seki"); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, WIN, 0); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, WIN, 0); +#endif } } @@ -1097,7 +1169,12 @@ TRACE("No move found\n"); SGFTRACE_SEMEAI(PASS_MOVE, *resulta, *resultb, "No move found"); *move = PASS_MOVE; +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, + depth - stackp, move, PASS_MOVE, *resulta, *resultb); +#else READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, *resulta, *resultb); +#endif } *resulta = best_resulta; @@ -1106,7 +1183,12 @@ best_move = PASS_MOVE; *move = best_move; SGFTRACE_SEMEAI(best_move, best_resulta, best_resultb, best_move_name); +#if USE_HASHTABLE_NG + READ_RETURN_SEMEAI_NG(komaster, kom_pos, SEMEAI, apos, bpos, depth - stackp, + move, best_move, best_resulta, best_resultb); +#else READ_RETURN_SEMEAI(read_result, move, best_move, best_resulta, best_resultb); +#endif } /* Play a move, update goal and boundaries appropriately, and call @@ -1698,7 +1780,7 @@ #if USE_HASHTABLE_NG if ((hashflags & HASH_OWL_ATTACK) - && tt_get(&ttable, komaster, kom_pos, OWL_ATTACK, str, + && tt_get(&ttable, komaster, kom_pos, OWL_ATTACK, str, NO_MOVE, depth - stackp, NULL, &value1, &value2, &xpos) == 2) { @@ -2426,7 +2508,7 @@ #if USE_HASHTABLE_NG if ((hashflags & HASH_OWL_DEFEND) - && tt_get(&ttable, komaster, kom_pos, OWL_DEFEND, str, + && tt_get(&ttable, komaster, kom_pos, OWL_DEFEND, str, NO_MOVE, depth - stackp, NULL, &value1, &value2, &xpos) == 2) { Index: engine/readconnect.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v retrieving revision 1.68 diff -u -r1.68 readconnect.c --- engine/readconnect.c 3 Feb 2004 21:12:06 -0000 1.68 +++ engine/readconnect.c 4 Feb 2004 20:23:30 -0000 @@ -1938,9 +1938,13 @@ int xpos; int savemove = NO_MOVE; int savecode = 0; - int found_read_result; int tried_moves = 0; +#if USE_HASHTABLE_NG + int value; +#else + int found_read_result; Read_result *read_result = NULL; +#endif SETUP_TRACE_INFO2("recursive_connect2", str1, str2); @@ -1970,6 +1974,24 @@ return 0; } +#if USE_HASHTABLE_NG + + if (stackp <= depth && (hashflags & HASH_CONNECT) + && !has_passed + && tt_get(&ttable, komaster, kom_pos, CONNECT, str1, str2, + depth - stackp, NULL, + &value, NULL, &xpos) == 2) { + /*TRACE_CACHED_RESULT2(*read_result);*/ + if (value != 0) + if (move) + *move = xpos; + + SGFTRACE2(xpos, value, "cached"); + return value; + } + +#else + if (stackp <= depth && (hashflags & HASH_CONNECT) && !has_passed) { @@ -1986,10 +2008,18 @@ return rr_get_result(*read_result); } } + +#endif if (trivial_connection(str1, str2, &xpos) == WIN) { SGFTRACE2(xpos, WIN, "trivial connection"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, CONNECT, str1, str2, + depth - stackp, + move, xpos, WIN); +#else READ_RETURN_CONN(read_result, move, xpos, WIN); +#endif } num_moves = find_string_connection_moves(str1, str2, color, @@ -2013,7 +2043,13 @@ popgo(); if (acode == 0) { SGFTRACE2(xpos, WIN, "connection effective"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, CONNECT, str1, str2, + depth - stackp, + move, xpos, WIN); +#else READ_RETURN_CONN(read_result, move, xpos, WIN); +#endif } /* if the move works with ko we save it, then look for something * better. @@ -2034,16 +2070,34 @@ if (tried_moves == 0 && distance < 1.0) { SGFTRACE2(NO_MOVE, WIN, "no move, probably connected"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, CONNECT, str1, str2, + depth - stackp, + move, NO_MOVE, WIN); +#else READ_RETURN_CONN(read_result, move, NO_MOVE, WIN); +#endif } if (savecode != 0) { SGFTRACE2(savemove, savecode, "saved move"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, CONNECT, str1, str2, + depth - stackp, + move, savemove, savecode); +#else READ_RETURN_CONN(read_result, move, savemove, savecode); +#endif } SGFTRACE2(0, 0, NULL); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, CONNECT, str1, str2, + depth - stackp, + move, NO_MOVE, 0); +#else READ_RETURN_CONN(read_result, move, NO_MOVE, 0); +#endif } @@ -2077,9 +2131,13 @@ int xpos; int savemove = NO_MOVE; int savecode = 0; - int found_read_result; int tried_moves = 0; +#if USE_HASHTABLE_NG + int value; +#else + int found_read_result; Read_result *read_result = NULL; +#endif SETUP_TRACE_INFO2("recursive_disconnect2", str1, str2); @@ -2109,6 +2167,22 @@ return WIN; } +#if USE_HASHTABLE_NG + if ((stackp <= depth) && (hashflags & HASH_DISCONNECT) + && tt_get(&ttable, komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, NULL, + &value, NULL, &xpos) == 2) { + /*TRACE_CACHED_RESULT2(*read_result);*/ + if (value != 0) + if (move) + *move = xpos; + + SGFTRACE2(xpos, value, "cached"); + return value; + } + +#else + if ((stackp <= depth) && (hashflags & HASH_DISCONNECT)) { found_read_result = get_read_result2(DISCONNECT, komaster, kom_pos, &str1, &str2, &read_result); @@ -2124,14 +2198,28 @@ } } +#endif + if (ladder_capture(str1, &xpos) == WIN) { SGFTRACE2(xpos, WIN, "first string capturable"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, + move, xpos, WIN); +#else READ_RETURN_CONN(read_result, move, xpos, WIN); +#endif } if (ladder_capture(str2, &xpos) == WIN) { SGFTRACE2(xpos, WIN, "second string capturable"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, + move, xpos, WIN); +#else READ_RETURN_CONN(read_result, move, xpos, WIN); +#endif } num_moves = find_string_connection_moves(str1, str2, other, @@ -2154,7 +2242,13 @@ popgo(); if (dcode == 0) { SGFTRACE2(xpos, WIN, "disconnection effective"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, + move, xpos, WIN); +#else READ_RETURN_CONN(read_result, move, xpos, WIN); +#endif } /* if the move works with ko we save it, then look for something * better. @@ -2178,16 +2272,34 @@ && (has_passed || !recursive_connect2(str1, str2, NULL, komaster, kom_pos, 1))) { SGFTRACE2(NO_MOVE, WIN, "no move, probably disconnected"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, + move, NO_MOVE, WIN); +#else READ_RETURN_CONN(read_result, move, NO_MOVE, WIN); +#endif } if (savecode != 0) { SGFTRACE2(savemove, savecode, "saved move"); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, + move, savemove, savecode); +#else READ_RETURN_CONN(read_result, move, savemove, savecode); +#endif } SGFTRACE2(0, 0, NULL); +#if USE_HASHTABLE_NG + READ_RETURN_CONN_NG(komaster, kom_pos, DISCONNECT, str1, str2, + depth - stackp, + move, NO_MOVE, 0); +#else READ_RETURN_CONN(read_result, move, NO_MOVE, 0); +#endif } @@ -2750,7 +2862,7 @@ if (stackp <= depth && (hashflags & HASH_BREAK_IN) && !has_passed - && tt_get(&ttable, komaster, kom_pos, BREAK_IN, str, + && tt_get(&ttable, komaster, kom_pos, BREAK_IN, str, NO_MOVE, depth - stackp, goal_hash, &retval, NULL, &xpos) == 2) { /* FIXME: Use move for move ordering if tt_get() returned 1 */ @@ -2915,7 +3027,7 @@ str = find_origin(str); if ((stackp <= depth) && (hashflags & HASH_BLOCK_OFF) - && (tt_get(&ttable, komaster, kom_pos, BLOCK_OFF, str, + && (tt_get(&ttable, komaster, kom_pos, BLOCK_OFF, str, NO_MOVE, depth - stackp, goal_hash, &retval, NULL, &xpos) == 2)) { SGFTRACE(xpos, retval, "cached"); if (move) Index: engine/reading.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v retrieving revision 1.137 diff -u -r1.137 reading.c --- engine/reading.c 24 Jan 2004 23:21:13 -0000 1.137 +++ engine/reading.c 4 Feb 2004 20:23:31 -0000 @@ -1223,7 +1223,7 @@ #if USE_HASHTABLE_NG if ((stackp <= depth) && (hashflags & HASH_FIND_DEFENSE) - && tt_get(&ttable, komaster, kom_pos, FIND_DEFENSE, str, + && tt_get(&ttable, komaster, kom_pos, FIND_DEFENSE, str, NO_MOVE, depth - stackp, NULL, &retval, NULL, &xpos) == 2) { /* Note that if return value is 1 (too small depth), the move will @@ -3025,7 +3025,7 @@ * still be used for move ordering. */ if ((stackp <= depth) && (hashflags & HASH_ATTACK) - && tt_get(&ttable, komaster, kom_pos, ATTACK, str, + && tt_get(&ttable, komaster, kom_pos, ATTACK, str, NO_MOVE, depth - stackp, NULL, &retval, NULL, &xpos) == 2) { SGFTRACE(xpos, retval, "cached");