gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] arend_3_23.2


From: Arend Bayer
Subject: Re: [gnugo-devel] arend_3_23.2
Date: Sun, 6 Jul 2003 14:45:41 +0200 (CEST)

Dan wrote:

> Results of the patch arend_3_23.2, re-enabling
> the delta territory cache are two unexpected
> fails:
>
> ./regress.sh . trevorc.tst
> 880 unexpected FAIL: Correct 'J10', got 'G1'
> 890 unexpected FAIL: Correct 'J10', got 'G1'

Yes, I have corrected that problem, but apparently forgot to send out
the patch. With the patch below, the delta territory cache probably
works for the first time.

Arend

- add safety_hash field to delta territory cache

I hadn't put it in the patch to reenable the delta territory cache for
3.3.22, because it had turned up two FAILs in trevorc.tst. Further
investigation showed that endgame patterns had modified the move_safety
field, leading to a different territorial evaluation.

One nice thing about having a clearly defined interface to influence.c
is that we can catch such things now easily: The delta territory cache
stores a hash value of the safety[] array passed to influence.c.
(This is computed with goal_to_hashvalue(), that I had added for the
break-in code.)

Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.84
diff -u -p -r1.84 influence.c
--- engine/influence.c  27 Jun 2003 04:34:31 -0000      1.84
+++ engine/influence.c  30 Jun 2003 17:13:14 -0000
@@ -1824,6 +1824,7 @@ compute_escape_influence(int color, cons
 /* Cache of delta_territory_values. */
 static float delta_territory_cache[BOARDMAX];
 static float followup_territory_cache[BOARDMAX];
+Hash_data delta_territory_cache_hash[BOARDMAX];
 static int territory_cache_position_number = -1;
 static int territory_cache_influence_id = -1;
 static int territory_cache_color = -1;
@@ -1837,14 +1838,12 @@ static int territory_cache_color = -1;
 int
 retrieve_delta_territory_cache(int pos, int color, float *move_value,
                               float *followup_value,
-                              const struct influence_data *base)
+                              const struct influence_data *base,
+                              Hash_data safety_hash)
 {
   ASSERT_ON_BOARD1(pos);
   ASSERT1(IS_STONE(color), pos);

-#if 1
-  return 0;
-#endif
   /* We check whether the color, the board position, or the base influence
    * data has changed since the cache entry got entered.
    */
@@ -1852,6 +1851,11 @@ retrieve_delta_territory_cache(int pos,
       && territory_cache_color == color
       && territory_cache_influence_id == base->id
       && delta_territory_cache[pos] != NOT_COMPUTED) {
+    int i;
+    for (i = 0; i < NUM_HASHVALUES; i++)
+      if (delta_territory_cache_hash[pos].hashval[i]
+         != safety_hash.hashval[i])
+       return 0;
     *move_value = delta_territory_cache[pos];
     *followup_value = followup_territory_cache[pos];
     if (0)
@@ -1865,10 +1869,12 @@ retrieve_delta_territory_cache(int pos,
 void
 store_delta_territory_cache(int pos, int color,
                            float move_value, float followup_value,
-                           const struct influence_data *base)
+                           const struct influence_data *base,
+                           Hash_data safety_hash)
 {
   ASSERT_ON_BOARD1(pos);
   ASSERT1(IS_STONE(color), pos);
+  int i;

   if (territory_cache_position_number != position_number
       || territory_cache_color != color
@@ -1884,6 +1890,8 @@ store_delta_territory_cache(int pos, int
   }
   delta_territory_cache[pos] = move_value;
   followup_territory_cache[pos] = followup_value;
+  for (i = 0; i < NUM_HASHVALUES; i++)
+    delta_territory_cache_hash[pos].hashval[i] = safety_hash.hashval[i];
   if (0)
     gprintf("%1m: Stored delta territory cache: %f, %f\n", pos, move_value,
            followup_value);
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.184
diff -u -p -r1.184 liberty.h
--- engine/liberty.h    26 Jun 2003 20:24:03 -0000      1.184
+++ engine/liberty.h    30 Jun 2003 17:13:16 -0000
@@ -707,10 +707,12 @@ float influence_delta_territory(const st
                                int move);
 int retrieve_delta_territory_cache(int pos, int color, float *move_value,
                                   float *followup_value,
-                                  const struct influence_data *base);
+                                  const struct influence_data *base,
+                                  Hash_data safety_hash);
 void store_delta_territory_cache(int pos, int color, float move_value,
                                 float followup_value,
-                                const struct influence_data *base);
+                                const struct influence_data *base,
+                                Hash_data safety_hash);

 int whose_territory(const struct influence_data *q, int pos);
 int whose_moyo(const struct influence_data *q, int pos);
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.103
diff -u -p -r1.103 value_moves.c
--- engine/value_moves.c        21 Jun 2003 06:02:14 -0000      1.103
+++ engine/value_moves.c        30 Jun 2003 17:13:19 -0000
@@ -1943,9 +1943,11 @@ estimate_territorial_value(int pos, int
    */
   if (does_block
       && tryko(pos, color, "estimate_territorial_value", EMPTY, NO_MOVE)) {
+    Hash_data safety_hash = goal_to_hashvalue(safe_stones);
     if (!retrieve_delta_territory_cache(pos, color, &this_value,
                                        &move[pos].influence_followup_value,
-                                       OPPOSITE_INFLUENCE(color))) {
+                                       OPPOSITE_INFLUENCE(color),
+                                       safety_hash)) {
       compute_influence(OTHER_COLOR(color), safe_stones, strength,
                        &move_influence, pos, "after move");
       increase_depth_values();
@@ -1964,7 +1966,7 @@ estimate_territorial_value(int pos, int
                                    color, pos);
       store_delta_territory_cache(pos, color, this_value,
                                  move[pos].influence_followup_value,
-                                 OPPOSITE_INFLUENCE(color));
+                                 OPPOSITE_INFLUENCE(color), safety_hash);
     }
     else {
       if (this_value != 0.0)









reply via email to

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