gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] fixed random seed et al.


From: Arend Bayer
Subject: [gnugo-devel] fixed random seed et al.
Date: Mon, 11 Aug 2003 17:03:52 +0200 (CEST)


I suggest the following patch for now. Using a fixed random seed, I
think we should test its quality. But at the moment its more important
to get back to deterministic regression runs again.

Arend

(P.S.: I prefer #if to #ifdef because a) this means -Wundef can take
effect, and b) its more likely to work with ccache when changing it, such as
45 seconds insted of 4 min compile time.)

- use #if, not #ifdef with USE_HASHTABLE_NG; fix compile warnings
- used fixed random seed for initializing Zobrist hashes

Index: engine/board.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.h,v
retrieving revision 1.1
diff -u -p -r1.1 board.h
--- engine/board.h      10 Aug 2003 17:56:50 -0000      1.1
+++ engine/board.h      11 Aug 2003 14:06:10 -0000
@@ -26,8 +26,8 @@
 #include "sgftree.h"


-/* Define if you want the new transposition table. */
-#define USE_HASHTABLE_NG
+/* Define to 1 if you want the new transposition table. */
+#define USE_HASHTABLE_NG       1

 /* local versions of absolute value, min and max */

Index: engine/cache.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v
retrieving revision 1.30
diff -u -p -r1.30 cache.c
--- engine/cache.c      10 Aug 2003 17:56:50 -0000      1.30
+++ engine/cache.c      11 Aug 2003 14:06:11 -0000
@@ -898,7 +898,7 @@ reading_cache_init(int bytes)
 {
   float nodes;

-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG

   /* Use a majority of the memory for the transposition table because
    * that one is used for the tactical reading.  Tests reveal that we
Index: engine/interface.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
retrieving revision 1.43
diff -u -p -r1.43 interface.c
--- engine/interface.c  18 Jul 2003 18:59:21 -0000      1.43
+++ engine/interface.c  11 Aug 2003 14:06:11 -0000
@@ -39,8 +39,13 @@
 void
 init_gnugo(float memory, unsigned int seed)
 {
-  set_random_seed(seed);
+  /* We need a fixed seed when initializing the Zobrist hashing to get
+   * reproducable results.
+   * FIXME: Test the quality of the seed.
+   */
+  set_random_seed(12345);
   reading_cache_init(memory * 1024 * 1024);
+  set_random_seed(seed);
   clear_board();

   transformation_init();
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.121
diff -u -p -r1.121 reading.c
--- engine/reading.c    4 Aug 2003 23:49:18 -0000       1.121
+++ engine/reading.c    11 Aug 2003 14:06:19 -0000
@@ -1056,8 +1056,10 @@ do_find_defense(int str, int *move, int
   int xpos = NO_MOVE;
   int dcode = 0;
   int liberties;
+#if !USE_HASHTABLE_NG
   int found_read_result;
   Read_result *read_result = NULL;
+#endif
   int retval;

   SETUP_TRACE_INFO("find_defense", str);
@@ -1083,7 +1085,7 @@ do_find_defense(int str, int *move, int
     return WIN;
   }

-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG

   if ((stackp <= depth) && (hashflags & HASH_FIND_DEFENSE)
       && tt_get(&ttable, komaster, kom_pos, FIND_DEFENSE, str,
@@ -1129,7 +1131,7 @@ do_find_defense(int str, int *move, int
     dcode = defend4(str, &xpos, komaster, kom_pos);

   if (dcode) {
-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG
     READ_RETURN_NG(komaster, kom_pos, FIND_DEFENSE, str, depth - stackp,
                   move, xpos, dcode);
 #else
@@ -1137,7 +1139,7 @@ do_find_defense(int str, int *move, int
 #endif
   }

-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG
   READ_RETURN0_NG(komaster, kom_pos, FIND_DEFENSE, str, depth - stackp);
 #else
   READ_RETURN0(read_result);
@@ -2967,8 +2969,10 @@ do_attack(int str, int *move, int komast
   int xpos = NO_MOVE;
   int libs;
   int result = 0;
+#if !USE_HASHTABLE_NG
   int found_read_result;
   Read_result *read_result = NULL;
+#endif
   int  retval;

   SETUP_TRACE_INFO("attack", str);
@@ -2996,7 +3000,7 @@ do_attack(int str, int *move, int komast
     return 0;
   }

-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG

   if ((stackp <= depth) && (hashflags & HASH_ATTACK)
       && tt_get(&ttable, komaster, kom_pos, ATTACK, str,
@@ -3051,14 +3055,14 @@ do_attack(int str, int *move, int komast
   ASSERT1(result >= 0 && result <= WIN, str);

   if (result)
-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG
     READ_RETURN_NG(komaster, kom_pos, ATTACK, str, depth - stackp,
                   move, xpos, result);
 #else
     READ_RETURN(read_result, move, xpos, result);
 #endif

-#ifdef USE_HASHTABLE_NG
+#if USE_HASHTABLE_NG
   READ_RETURN0_NG(komaster, kom_pos, ATTACK, str, depth - stackp);
 #else
   READ_RETURN0(read_result);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]