[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] arend_1_33.1a: hash_(re)init, -S and -t output matters
From: |
Arend Bayer |
Subject: |
[gnugo-devel] arend_1_33.1a: hash_(re)init, -S and -t output matters |
Date: |
Mon, 15 Apr 2002 00:42:02 +0200 (CEST) |
- new function hash_reinit() called from update_random_seed
- hash_init made behaviour made independent of boardsize
- output cleanup: --statistics, and EITHER_MOVE-trace
After this patch, we can restart in the middle of a twogtp match and get
identical --statistics and --trace output. It does various things:
* When update_random_seed is called, the hash values are automatically
re-initialized. This is done by calling gg_srand with the new random
seed and by calling hash_reinit.
* The current implementation of hash_init contained a bug that would
occur if --boardsize is used and this is later increased in a GTP
session.
* The either move trace output was broken; the statistics output was
for some reason sent to stdout instead of stderr -- I guess by mistake,
as I can't see a reason for this.
The hash_reinit() stuff could get ignored if we want to use a fixed seed
in the hash initialization, while the stuff in hash_init() should go in
anyway.
This patch replaces arend_1_33.1.
Arend
Index: engine/genmove.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v
retrieving revision 1.39
diff -u -r1.39 genmove.c
--- engine/genmove.c 13 Apr 2002 18:11:00 -0000 1.39
+++ engine/genmove.c 14 Apr 2002 22:28:00 -0000
@@ -524,12 +525,12 @@
/* If statistics is turned on, this is the place to show it. */
if (showstatistics) {
- printf("Nodes: %d\n", stats.nodes);
- printf("Positions entered: %d\n", stats.position_entered);
- printf("Position hits: %d\n", stats.position_hits);
- printf("Read results entered: %d\n", stats.read_result_entered);
- printf("Read result hits: %d\n", stats.read_result_hits);
- printf("Hash collisions: %d\n", stats.hash_collisions);
+ gprintf("Nodes: %d\n", stats.nodes);
+ gprintf("Positions entered: %d\n", stats.position_entered);
+ gprintf("Position hits: %d\n", stats.position_hits);
+ gprintf("Read results entered: %d\n", stats.read_result_entered);
+ gprintf("Read result hits: %d\n", stats.read_result_hits);
+ gprintf("Hash collisions: %d\n", stats.hash_collisions);
}
if (showtime) {
Index: engine/hash.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/hash.c,v
retrieving revision 1.12
diff -u -r1.12 hash.c
--- engine/hash.c 25 Mar 2002 04:47:27 -0000 1.12
+++ engine/hash.c 14 Apr 2002 22:28:01 -0000
@@ -65,6 +65,18 @@
}
+/* Force re-initialization of the hash system, even if it has been
+ * intialized before.
+ */
+
+void
+hash_reinit(void)
+{
+ is_initialized = 0;
+ hash_init();
+}
+
+
/*
* Initialize the entire hash system.
*/
@@ -94,12 +106,14 @@
#endif
for (i = 0; i < NUM_HASHVALUES; i++)
- for (pos = BOARDMIN; pos < BOARDMAX; pos++)
- if (ON_BOARD(pos)) {
- black_hash[pos][i] = hash_rand();
- white_hash[pos][i] = hash_rand();
- ko_hash[pos][i] = hash_rand();
- }
+ for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
+ /* Note: We initialize _all_ positions, not just those on board.
+ * This way we don't have to worry about changing board sizes.
+ */
+ black_hash[pos][i] = hash_rand();
+ white_hash[pos][i] = hash_rand();
+ ko_hash[pos][i] = hash_rand();
+ }
gg_set_rand_state(&state);
Index: engine/hash.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/hash.h,v
retrieving revision 1.7
diff -u -r1.7 hash.h
--- engine/hash.h 25 Mar 2002 04:47:27 -0000 1.7
+++ engine/hash.h 14 Apr 2002 22:28:02 -0000
@@ -134,6 +134,7 @@
void hash_init(void);
+void hash_reinit(void);
#if FULL_POSITION_IN_HASH
int hashposition_compare(Hashposition *pos1, Hashposition *pos2);
void hashposition_dump(Hashposition *pos, FILE *outfile);
Index: engine/move_reasons.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v
retrieving revision 1.79
diff -u -r1.79 move_reasons.c
--- engine/move_reasons.c 12 Apr 2002 14:23:54 -0000 1.79
+++ engine/move_reasons.c 14 Apr 2002 22:28:09 -0000
@@ -1619,19 +1619,25 @@
break;
case EITHER_MOVE:
+ reason1 = either_data[move_reasons[r].what].reason1;
+ reason2 = either_data[move_reasons[r].what].reason2;
+ worm1 = either_data[move_reasons[r].what].what1;
+ worm2 = either_data[move_reasons[r].what].what2;
+ aa = worms[worm1];
+ bb = worms[worm2];
+ gprintf("Move at %1m either %s %1m or %s %1m\n", pos,
+ reason1 == ATTACK_STRING ? "attacks" : "defends", aa,
+ reason2 == ATTACK_STRING ? "attacks" : "defends", bb);
+ break;
+
case ALL_MOVE:
- /* FIXME: Generalize this. */
- /* FIXME: This is broken. EITHER_MOVE should reference either_data
- see, for example:
- http://www.public32.com/regress/?tstfile=nngs&num=850&move=R9*/
reason1 = all_data[move_reasons[r].what].reason1;
reason2 = all_data[move_reasons[r].what].reason2;
worm1 = all_data[move_reasons[r].what].what1;
worm2 = all_data[move_reasons[r].what].what2;
aa = worms[worm1];
bb = worms[worm2];
- gprintf("Move at %1m %s %s %1m or %s %1m\n",
- pos, move_reasons[r].type == EITHER_MOVE ? "either" : "both",
+ gprintf("Move at %1m both %s %1m or %s %1m\n", pos,
reason1 == ATTACK_STRING ? "attacks" : "defends", aa,
reason2 == ATTACK_STRING ? "attacks" : "defends", bb);
break;
Index: engine/utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.44
diff -u -r1.44 utils.c
--- engine/utils.c 13 Apr 2002 18:11:00 -0000 1.44
+++ engine/utils.c 14 Apr 2002 22:28:15 -0000
@@ -30,6 +30,7 @@
#include "liberty.h"
#include "sgftree.h"
#include "random.h"
+#include "hash.h"
#include "gg_utils.h"
@@ -1751,6 +1752,8 @@
*/
if (random_seed == 0)
random_seed = 1;
+ gg_srand(random_seed);
+ hash_reinit();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] arend_1_33.1a: hash_(re)init, -S and -t output matters,
Arend Bayer <=