gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] cache.h distanglement


From: Gunnar Farneback
Subject: [gnugo-devel] cache.h distanglement
Date: Thu, 14 Aug 2003 21:24:53 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

This patch moves a few pieces around between the header files, aiming
to reduce the dependency of cache.h to the files which actually use
caching. Additionally it fixes a couple of small bugs and reinstates
SGF traces for cached results in the tactical reading.

- #define USE_HASHTABLE_NG moved from board.h to cache.h
- enum routine_id moved from cache.h to liberty.h
- ttable moved from liberty.h to cache.h
- hash.h includes board.h (needed for Intersection typedef)
- liberty.h includes hash.h
- liberty.h no longer includes cache.h
- bugfix in dump_stack()
- bugfix of DRAGON_STATUS_NAMES macro
- SGFTRACEs for results cached in new cache in do_attack() and
  do_find_defense() 

/Gunnar

Index: engine/board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.85
diff -u -r1.85 board.c
--- engine/board.c      10 Aug 2003 17:56:50 -0000      1.85
+++ engine/board.c      14 Aug 2003 19:03:43 -0000
@@ -757,7 +757,7 @@
   if (count_variations)
     gprintf("%o (variation %d)", count_variations-1);
 #else
-  gprintf("%o (%d)", hashdata_to_string(&hashdata));
+  gprintf("%o (%s)", hashdata_to_string(&hashdata));
 #endif
 
   gprintf("%o\n");
Index: engine/board.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.h,v
retrieving revision 1.2
diff -u -r1.2 board.h
--- engine/board.h      12 Aug 2003 09:15:20 -0000      1.2
+++ engine/board.h      14 Aug 2003 19:03:43 -0000
@@ -25,10 +25,6 @@
 
 #include "sgftree.h"
 
-
-/* Define to 1 if you want the new transposition table. */
-#define USE_HASHTABLE_NG       1
-
 /* local versions of absolute value, min and max */
 
 #define gg_abs(x) ((x) < 0 ? -(x) : (x))
Index: engine/cache.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v
retrieving revision 1.35
diff -u -r1.35 cache.h
--- engine/cache.h      10 Aug 2003 17:56:50 -0000      1.35
+++ engine/cache.h      14 Aug 2003 19:03:44 -0000
@@ -32,6 +32,9 @@
 #ifndef _CACHE_H_
 #define _CACHE_H_
 
+/* Define to 1 if you want the new transposition table. */
+#define USE_HASHTABLE_NG 1
+
 
 /* Hashnode: a node stored in the transposition table.
  *
@@ -90,46 +93,7 @@
   int            is_clean;
 } Transposition_table;
 
-
-enum routine_id {
-  OWL_ATTACK,
-  OWL_DEFEND,
-  SEMEAI,
-  FIND_DEFENSE,
-  ATTACK,
-  CONNECT,
-  DISCONNECT,
-  BREAK_IN,
-  BLOCK_OFF,
-  OWL_THREATEN_ATTACK,
-  OWL_THREATEN_DEFENSE,
-  OWL_DOES_DEFEND,
-  OWL_DOES_ATTACK,
-  OWL_CONNECTION_DEFENDS,
-  OWL_SUBSTANTIAL,
-  OWL_CONFIRM_SAFETY,
-  NUM_CACHE_ROUTINES
-};
-
-#define ROUTINE_NAMES \
-  "owl_attack", \
-  "owl_defend", \
-  "semeai", \
-  "find_defense", \
-  "attack", \
-  "connect", \
-  "disconnect", \
-  "break_in", \
-  "block_off" \
-  "owl_threaten_attack" \
-  "owl_threatend_defense" \
-  "owl_does_defend" \
-  "owl_does_attack" \
-  "owl_connection_defends" \
-  "owl_substantial" \
-  "owl_confirm_safety"
-
-const char *routine_id_to_string(enum routine_id routine);
+extern Transposition_table  ttable;
 
 extern void  tt_init(Transposition_table *table, int memsize);
 extern void  tt_clear(Transposition_table *table);
Index: engine/hash.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/hash.h,v
retrieving revision 1.17
diff -u -r1.17 hash.h
--- engine/hash.h       10 Aug 2003 17:56:50 -0000      1.17
+++ engine/hash.h       14 Aug 2003 19:03:44 -0000
@@ -22,6 +22,7 @@
 
 
 #include "config.h"
+#include "board.h"
 
 /*
  * This file, together with engine/hash.c implements hashing of go positions
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.197
diff -u -r1.197 liberty.h
--- engine/liberty.h    12 Aug 2003 03:05:33 -0000      1.197
+++ engine/liberty.h    14 Aug 2003 19:03:45 -0000
@@ -24,6 +24,7 @@
 #define _LIBERTY_H_
 
 #include "board.h"
+#include "hash.h"
 #include "gnugo.h"
 
 /* ================================================================ */
@@ -31,10 +32,6 @@
 /* ================================================================ */
 
 
-/* We need the defintion of type Hash_data here. */
-#include "cache.h"
-extern Transposition_table  ttable;
-
 /* ================================================================ */
 
 
@@ -64,6 +61,48 @@
 int rotate1(int pos, int rot);
 int inv_rotate1(int pos, int rot);
 
+/* Routine names used by persistent and non-persistent caching schemes. */
+enum routine_id {
+  OWL_ATTACK,
+  OWL_DEFEND,
+  SEMEAI,
+  FIND_DEFENSE,
+  ATTACK,
+  CONNECT,
+  DISCONNECT,
+  BREAK_IN,
+  BLOCK_OFF,
+  OWL_THREATEN_ATTACK,
+  OWL_THREATEN_DEFENSE,
+  OWL_DOES_DEFEND,
+  OWL_DOES_ATTACK,
+  OWL_CONNECTION_DEFENDS,
+  OWL_SUBSTANTIAL,
+  OWL_CONFIRM_SAFETY,
+  NUM_CACHE_ROUTINES
+};
+
+#define ROUTINE_NAMES \
+  "owl_attack", \
+  "owl_defend", \
+  "semeai", \
+  "find_defense", \
+  "attack", \
+  "connect", \
+  "disconnect", \
+  "break_in", \
+  "block_off" \
+  "owl_threaten_attack" \
+  "owl_threatend_defense" \
+  "owl_does_defend" \
+  "owl_does_attack" \
+  "owl_connection_defends" \
+  "owl_substantial" \
+  "owl_confirm_safety"
+
+const char *routine_id_to_string(enum routine_id routine);
+
+
 /* Forward struct declarations. */
 struct pattern;
 struct pattern_db;
@@ -754,18 +793,18 @@
 };
 
 #define DRAGON_STATUS_NAMES \
-  "dead" \
-  "alive" \
-  "critical" \
-  "unknown" \
-  "unchecked" \
-  "can threaten attack" \
-  "can threaten defense" \
-  "inessential" \
-  "tactically dead" \
-  "alive in seki" \
-  "strongly alive" \
-  "invincible" \
+  "dead", \
+  "alive", \
+  "critical", \
+  "unknown", \
+  "unchecked", \
+  "can threaten attack", \
+  "can threaten defense", \
+  "inessential", \
+  "tactically dead", \
+  "alive in seki", \
+  "strongly alive", \
+  "invincible", \
   "insubstantial"
 
 const char *status_to_string(enum dragon_status status);
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.122
diff -u -r1.122 reading.c
--- engine/reading.c    12 Aug 2003 09:15:20 -0000      1.122
+++ engine/reading.c    14 Aug 2003 19:03:47 -0000
@@ -1059,8 +1059,9 @@
 #if !USE_HASHTABLE_NG
   int found_read_result;
   Read_result *read_result = NULL;
-#endif
+#else
   int retval;
+#endif
   
   SETUP_TRACE_INFO("find_defense", str);
   
@@ -1090,9 +1091,13 @@
   if ((stackp <= depth) && (hashflags & HASH_FIND_DEFENSE)
       && tt_get(&ttable, komaster, kom_pos, FIND_DEFENSE, str, 
                depth - stackp,
-               &retval, move) == 2)
+               &retval, &xpos) == 2) {
     /* FIXME: Use move for move ordering if tt_get() returned 1 */
+    SGFTRACE(xpos, retval, "cached");
+    if (move)
+      *move = xpos;
     return retval;
+  }
 
 #else
 
@@ -2972,8 +2977,9 @@
 #if !USE_HASHTABLE_NG
   int found_read_result;
   Read_result *read_result = NULL;
-#endif
+#else
   int  retval;
+#endif
 
   SETUP_TRACE_INFO("attack", str);
 
@@ -3005,9 +3011,13 @@
   if ((stackp <= depth) && (hashflags & HASH_ATTACK)
       && tt_get(&ttable, komaster, kom_pos, ATTACK, str, 
                depth - stackp,
-               &retval, move) == 2)
+               &retval, &xpos) == 2) {
     /* FIXME: Use move for move ordering if tt_get() returned 1 */
+    SGFTRACE(xpos, retval, "cached");
+    if (move)
+      *move = xpos;
     return retval;
+  }
 
 #else
 




reply via email to

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