gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] arend_1_16.4: minor fix in influence.c


From: Arend Bayer
Subject: [gnugo-devel] arend_1_16.4: minor fix in influence.c
Date: Sat, 8 Dec 2001 09:42:31 +0100 (CET)

- new function add_influence_source fixes minor inconsistency in influence.c 

It may happen (though very rarely) that different patterns produce two
different influence sources at the same intersection. Currently, there
was no way to handle this; I assume the strongest influence source should
be be used.
Due to a minor bug, at the moment an influence source with strength 0.25
and attenuation 1.5 plus another one of strength 30 and (intended)
attenuation 3.0 could result in an influence source of strength 30 and
attenuation 1.5. I stepped on this when it produced a negative territorial
evaluation (recent NNGS game gnugo-3.1.15-chayashida-200112050233.sgf,
move 18, move at L8).
This patch solves these problems.

-Arend

BREAKAGE: As expected, very few changes. I ran:
strategy strategy2 strategy3 strategy4 arend trevor nicklas1 nicklas2
nicklas3 nicklas4 nicklas5 global

Unexpected results compared to Trevor's latest CVS-based run:
./eval.sh strategy4.tst
179 passed
(This is a bit random, the two moves E2 and O5 only differ marginally. The
inherent problem that GNU Go believes that O5 kills S5 remains.)

./eval.sh arend.tst
1 passed
./eval.sh nicklas2.tst
1701 passed
./eval.sh global.tst
14 failed: Correct 'S9', got 'L13'
As I had no explanation for these three test cases, I tried to reproduce
these with my CVS at home, and got different results from Trevor's.
Trevor mentioned these test already in his e-mail fom Nov 30, maybe we
have some platform specific behaviour here? (I understand you are using
a VC-compiled GNU Go on Windows, Trevor?) The different moves are all due
to different OWL-results.

Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.22
diff -u -r1.22 influence.c
--- engine/influence.c  2001/12/04 20:26:07     1.22
+++ engine/influence.c  2001/12/08 08:38:20
@@ -32,6 +32,9 @@
 #include "patterns.h"
 
 static void value_territory(struct influence_data *q);
+static void add_influence_source(int pos, int color, float strength,
+                                 float attenuation,
+                                 struct influence_data *q);
 static void segment_influence(struct influence_data *q);
 static void print_influence(struct influence_data *q, int dragons_known);
 static void print_numeric_influence(struct influence_data *q,
@@ -436,6 +439,25 @@
     }
 }
 
+/* Adds an influence source at position pos with prescribed strength
+ * and attenuation. color can be BLACK, WHITE or both. If there
+ * already exists an influence source of the respective color at pos
+ * that is stronger than the new one, we do nothing.
+ */
+void
+add_influence_source(int pos, int color, float strength, float attenuation,
+                     struct influence_data *q)
+{
+  if ((color & WHITE) && (q->white_strength[I(pos)][J(pos)] < strength)) {
+    q->white_strength[I(pos)][J(pos)] = strength;
+    q->white_attenuation[I(pos)][J(pos)] = attenuation;
+  }
+  if ((color & BLACK) && (q->black_strength[I(pos)][J(pos)] < strength)) {
+    q->black_strength[I(pos)][J(pos)] = strength;
+    q->black_attenuation[I(pos)][J(pos)] = attenuation;
+  }
+}
+
 /* Callback for the matched patterns in influence.db and barriers.db.
  * The pattern classes used here are:
  * A - Barrier pattern, where O plays first and X tries to block influence.
@@ -596,24 +618,13 @@
       this_color = q->color_to_move;
 
     /* Increase strength if we're computing escape influence. */
-    if (q == &escape_influence && (pattern->class & CLASS_e)) {
-      if (this_color & WHITE)
-       q->white_strength[ti][tj] = 20 * pattern->value;
-      if (this_color & BLACK)
-       q->black_strength[ti][tj] = 20 * pattern->value;
-    }
-    else {
-      if (this_color & WHITE)
-       q->white_strength[ti][tj] = pattern->value;
-      if (this_color & BLACK)
-       q->black_strength[ti][tj] = pattern->value;
-    }
+    if (q == &escape_influence && (pattern->class & CLASS_e))
+      add_influence_source(POS(ti, tj), this_color,
+          20 * pattern->value, 1.5, q);
+    else
+      add_influence_source(POS(ti, tj), this_color,
+          pattern->value, 1.5, q);
 
-    if (this_color & WHITE)
-      q->white_attenuation[ti][tj] = 1.5;
-    if (this_color & BLACK)
-      q->black_attenuation[ti][tj] = 1.5;
-    
     DEBUG(DEBUG_INFLUENCE,
          "  low intensity influence source at %m, strength %f, color %C\n",
          ti, tj, pattern->value, this_color);
@@ -624,14 +635,8 @@
    * pattern defined strength at *.
    */
   if (pattern->class & CLASS_E) {
-    if (color == WHITE) {
-      q->white_strength[ti][tj] = pattern->value;
-      q->white_attenuation[ti][tj] = DEFAULT_ATTENUATION;
-    }
-    else {
-      q->black_strength[ti][tj] = pattern->value;
-      q->black_attenuation[ti][tj] = DEFAULT_ATTENUATION;
-    }
+    add_influence_source(POS(ti, tj), color,
+        pattern->value, DEFAULT_ATTENUATION, q);
     DEBUG(DEBUG_INFLUENCE,
          "  extra %C source at %m, strength %f\n", color,
          ti, tj, pattern->value);
@@ -669,11 +674,9 @@
       
       /* Low intensity influence source for the color in turn to move. */
       if (pattern->class & CLASS_B) {
+        add_influence_source(POS(x, y), color,
+            pattern->value, DEFAULT_ATTENUATION, q);
        DEBUG(DEBUG_INFLUENCE, "  intrusion at %m\n", x, y);
-       if (color == WHITE)
-         q->white_strength[x][y] = pattern->value;
-       else
-         q->black_strength[x][y] = pattern->value;
       }
     }
   }




reply via email to

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