gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] arend_1_14.6


From: Arend Bayer
Subject: [gnugo-devel] arend_1_14.6
Date: Thu, 15 Nov 2001 16:00:31 +0100 (CET)

This patch changes the fixed values for j and t patterns, basically in
the way Gunnar suggested in the reply my e-mail: In general, they become
minimum values; only for the patterns in fuseki.db, they are still
fixed values to guarantee sufficient indeterminacy during fuseki.

This is done as follows:
I added the CLASS_F as a move classification; this denotes a (non-global)
fuseki pattern. (I thought that there might be more ideas in future for
special treatments of these moves.)
mkpat compiles fuseki.db with the command line option -F; this induces all
patterns to have CLASS_F by default. An F classification in the .db file
toggles this.
Shapes.c does not enforce maximum values for j and t patterns unless it
is a fuseki pattern.
Finally, in value_move_reasons in move_reasons.c: moves with minimum
value (and no maximum value) get total value at least
tot_value = min_value + tot_value/200. 

I ran half the test suites; as fare as I would attribute the new
fails/passes to my patch, it seemed a small net gain.

-Arend

Index: gnugo/engine/move_reasons.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v
retrieving revision 1.38
diff -U4 -r1.38 move_reasons.c
--- gnugo/engine/move_reasons.c 2001/11/14 19:16:28     1.38
+++ gnugo/engine/move_reasons.c 2001/11/15 07:37:05
@@ -3601,18 +3601,28 @@
       tot_value = new_tot_value;
     }
   }
   
-  /* Test if min_value or max_value values constrain the total value. */
+  /* Test if min_value or max_value values constrain the total value.
+   * First avoid contradictions between min_value and max_value,
+   * assuming that min_value is right.
+   */
+  if (move[pos].min_value > move[pos].max_value)
+    move[pos].max_value = move[pos].min_value;
+  /* If several moves have an identical minimum value, then GnuGo's
+   * judgement will be the secondary criterium (unless min_value and
+   * max_value agree):
+   */
+  if (tot_value < move[pos].min_value + tot_value / 200
+      && move[pos].min_value > 0) {
+    tot_value = move[pos].min_value + tot_value / 200;
+    TRACE("  %1m:   %f - minimum accepted value\n", pos, tot_value);
+  }
+  
   if (tot_value > move[pos].max_value) {
     tot_value = move[pos].max_value;
     TRACE("  %1m:   %f - maximum accepted value\n",
-         pos, tot_value);
-  }
-  
-  if (tot_value < move[pos].min_value && move[pos].min_value > 0) {
-    tot_value = move[pos].min_value;
-    TRACE("  %1m:   %f - minimum accepted value\n", pos, tot_value);
+          pos, tot_value);
   }
 
   if (tot_value > 0
       || move[pos].territorial_value > 0
Index: gnugo/engine/shapes.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/shapes.c,v
retrieving revision 1.17
diff -U4 -r1.17 shapes.c
--- gnugo/engine/shapes.c       2001/11/09 19:03:43     1.17
+++ gnugo/engine/shapes.c       2001/11/15 07:37:07
@@ -305,54 +305,64 @@
     TRACE("... minimum move value %f\n", 27 * board_size / 19.0);
   }
 
   /* Pattern class j, less urgent joseki move. Add expand territory and
-   * moyo, but set the value at 20.
+   * moyo, set a minimum value of 20. If it is a fuseki pattern, set also
+   * the maximum value to 20.
    */
   if (class & CLASS_j) {
-    float fixed_value = 20;
+    float min_value = 20;
     TRACE("...less urgent joseki move\n");
     add_expand_territory_move(move);
     TRACE("...expands territory\n");
     add_expand_moyo_move(move);
     TRACE("...expands moyo\n");
 
     /* Board size modification. */
-    fixed_value *= board_size / 19.0;
+    min_value *= board_size / 19.0;
     
     if (class & VALUE_SHAPE) {
-      fixed_value *= (1 + 0.01 * pattern->shape);
-      TRACE("...move value %f (shape %f)\n", fixed_value, pattern->shape);
+      min_value *= (1 + 0.01 * pattern->shape);
       class &= ~VALUE_SHAPE;
-    }
-    else
-      TRACE("...move value %f\n", fixed_value);
+    };
 
-    set_minimum_move_value(move, fixed_value);
-    if (board_size >= 17)
-      set_maximum_move_value(move, fixed_value);
+    if ((board_size >= 17) && (class & CLASS_F)) {
+      min_value *= 1.005; /* Otherwise, j patterns not of CLASS_F would */
+                          /* get preferred in value_move_reasons */
+      set_maximum_move_value(move, min_value);
+      TRACE("...move value %f (shape %f)\n", min_value, pattern->shape);
+    }
+    else 
+      TRACE("...minimum move value %f (shape %f)\n",
+            min_value, pattern->shape);
+    set_minimum_move_value(move, min_value);
   }
 
-  /* Pattern class t, minor joseki move (tenuki OK). Set the value at 15.
+  /* Pattern class t, minor joseki move (tenuki OK).
+   * Set the (min-)value at 15.
    */
   if (class & CLASS_t) {
-    float fixed_value = 15;
+    float min_value = 15;
     TRACE("...minor joseki move\n");
     
     /* Board size modification. */
-    fixed_value *= board_size / 19.0;
+    min_value *= board_size / 19.0;
     
     if (class & VALUE_SHAPE) {
-      fixed_value *= (1 + 0.01 * pattern->shape);
-      TRACE("...move value %f (shape %f)\n", fixed_value, pattern->shape);
+      min_value *= (1 + 0.01 * pattern->shape);
       class &= ~VALUE_SHAPE;
-    }
-    else
-      TRACE("...move value %f\n", fixed_value);
+    };
     
-    set_minimum_move_value(move, fixed_value);
-    if (board_size >= 17)
-      set_maximum_move_value(move, fixed_value);
+    if ((board_size >= 17) && (class & CLASS_F)) {
+      min_value *= 1.005; /* Otherwise, j patterns not of CLASS_F would */
+                          /* get preferred in value_move_reasons */
+      set_maximum_move_value(move, min_value);
+      TRACE("...move value %f (shape %f)\n", min_value, pattern->shape);
+    }
+    else 
+      TRACE("...minimum move value %f (shape %f)\n",
+            min_value, pattern->shape);
+    set_minimum_move_value(move, min_value);
   }
 
   /* Pattern class U, very urgent move joseki. Add strategical defense
    * and attack, plus a shape bonus of 15 and a minimum value of 40.
Index: gnugo/patterns/Makefile.am
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.am,v
retrieving revision 1.6
diff -U4 -r1.6 Makefile.am
--- gnugo/patterns/Makefile.am  2001/11/10 16:14:56     1.6
+++ gnugo/patterns/Makefile.am  2001/11/15 07:37:08
@@ -162,9 +162,9 @@
 owl_defendpat.c : $(srcdir)/owl_defendpats.db mkpat$(EXEEXT)
        ./mkpat $(DFAFLAGS) -b owl_defendpat < $(srcdir)/owl_defendpats.db 
>owl_defendpat.c
 
 fusekipat.c : $(srcdir)/fuseki.db mkpat$(EXEEXT)
-       ./mkpat -b fusekipat < $(srcdir)/fuseki.db >fusekipat.c
+       ./mkpat -b -F fusekipat < $(srcdir)/fuseki.db >fusekipat.c
 
 fuseki9.c : $(srcdir)/fuseki9.db mkpat$(EXEEXT)
        ./mkpat -b -f fuseki9 < $(srcdir)/fuseki9.db >fuseki9.c
 
Index: gnugo/patterns/Makefile.in
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.in,v
retrieving revision 1.17
diff -U4 -r1.17 Makefile.in
--- gnugo/patterns/Makefile.in  2001/11/10 16:14:56     1.17
+++ gnugo/patterns/Makefile.in  2001/11/15 07:37:08
@@ -523,9 +523,9 @@
 owl_defendpat.c : $(srcdir)/owl_defendpats.db mkpat$(EXEEXT)
        ./mkpat $(DFAFLAGS) -b owl_defendpat < $(srcdir)/owl_defendpats.db 
>owl_defendpat.c
 
 fusekipat.c : $(srcdir)/fuseki.db mkpat$(EXEEXT)
-       ./mkpat -b fusekipat < $(srcdir)/fuseki.db >fusekipat.c
+       ./mkpat -b -F fusekipat < $(srcdir)/fuseki.db >fusekipat.c
 
 fuseki9.c : $(srcdir)/fuseki9.db mkpat$(EXEEXT)
        ./mkpat -b -f fuseki9 < $(srcdir)/fuseki9.db >fuseki9.c
 
Index: gnugo/patterns/fuseki.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/fuseki.db,v
retrieving revision 1.1
diff -U4 -r1.1 fuseki.db
--- gnugo/patterns/fuseki.db    2001/09/26 15:31:32     1.1
+++ gnugo/patterns/fuseki.db    2001/11/15 07:37:11
@@ -91,8 +91,13 @@
 # Invasions in the middle of the edge
 # Jumps
 #
 ######################################################################
+#
+# If the maximum values for a j or t patterns should NOT be enforced,
+# add the F classification.
+#
+######################################################################
 
 ################
 # Approach moves
 ################
Index: gnugo/patterns/mkpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v
retrieving revision 1.28
diff -U4 -r1.28 mkpat.c
--- gnugo/patterns/mkpat.c      2001/11/14 19:16:28     1.28
+++ gnugo/patterns/mkpat.c      2001/11/15 07:37:16
@@ -49,8 +49,10 @@
            -X = allow only X to be anchor (default is only O)\n\
            -f = compile a fullboard pattern database\n\
            -m = try to place the anchor in the center of the pattern\n\
                 (reduce dfa size)\n\
+           -F = compile as a databases of fuseki patterns (this adds\n\
+                the class F to all patterns)\n\
 \n\
  If compiled with --enable-dfa the following options also work:\n\n\
            -D = generate a dfa and save it as a C file.\n\
            -V <level>  = dfa verbose level\n\
@@ -307,8 +309,9 @@
 
 int choose_best_anchor = 0;  /* -m */
 
 int fullboard = 0;   /* Whether this is a database of fullboard patterns. */
+int fusekidb = 0;  /* Whether this is a database of fuseki patterns. */
 int dfa_generate = 0; /* if 1 a dfa is created. */
 int dfa_c_output = 0; /* if 1 the dfa is saved as a c file */
 dfa_t dfa;
 
@@ -839,12 +842,16 @@
       if (strchr(class, 't')) pattern[patno].class |= CLASS_t;
       if (strchr(class, 'T')) pattern[patno].class |= CLASS_T;
       if (strchr(class, 'U')) pattern[patno].class |= CLASS_U;
       if (strchr(class, 'W')) pattern[patno].class |= CLASS_W;
+      if (strchr(class, 'F')) pattern[patno].class |= CLASS_F;
     }
 
   }
-
+  /* Patterns in fuseki.db are assumed to be a fuseki pattern.
+   * The letter F toggles this.
+   */
+  if (fusekidb)  pattern[patno].class ^= CLASS_F;
       
   /* Now get the symmetry. There are extra checks we can make to do with
    * square-ness and edges. We do this before we work out the edge constraints,
    * since that mangles the size info.
@@ -1418,9 +1425,9 @@
   int i;
   
   {
     /* parse command-line args */
-    while ((i = gg_getopt(argc, argv, "i:o:V:vcbXfmtD")) != EOF) {
+    while ((i = gg_getopt(argc, argv, "i:o:V:vcbXfmtDF")) != EOF) {
       switch(i) {
       case 'v': verbose = 1; break;
       case 'c': pattern_type = CONNECTIONS; break;
       case 'b': anchor = ANCHOR_BOTH; break;
@@ -1432,8 +1439,9 @@
       case 'D':
        dfa_generate = 1; dfa_c_output = 1; 
        break;
       case 'V': dfa_verbose = strtol(gg_optarg, NULL, 10); break;
+      case 'F': fusekidb = 1; break;
 
       default:
        fprintf(stderr, "Invalid argument ignored\n");
       }
Index: gnugo/patterns/patterns.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v
retrieving revision 1.13
diff -U4 -r1.13 patterns.h
--- gnugo/patterns/patterns.h   2001/11/09 21:06:53     1.13
+++ gnugo/patterns/patterns.h   2001/11/15 07:37:28
@@ -159,23 +159,24 @@
 #define CLASS_t 0x80000  /* minor joseki move (tenuki OK) */
 #define CLASS_U 0x100000 /* very urgent joseki move */
 #define CLASS_T 0x200000 /* joseki trick move */
 #define CLASS_W 0x400000 /* worthwhile threat move */
+#define CLASS_F 0x800000 /* a fuseki pattern */
 
 /* Collection of the classes inducing move reasons. */
 #define CLASS_MOVE_REASONS (CLASS_C | CLASS_B | CLASS_b | \
                             CLASS_e | CLASS_E | CLASS_a | CLASS_d | \
                            CLASS_J | CLASS_j | CLASS_U | CLASS_T | CLASS_t | \
-                            CLASS_W | CLASS_c)
+                            CLASS_W | CLASS_c | CLASS_F)
 
 /* Values associated with patterns. Stored together with classes. */
-#define VALUE_MINVAL       0x00800000 /* pattern has a minimum value */
-#define VALUE_MAXVAL       0x01000000 /* pattern has a maximum value */
-#define VALUE_MINTERRITORY 0x02000000 /* pattern has a min territorial value */
-#define VALUE_MAXTERRITORY 0x04000000 /* pattern has a max territorial value */
-#define VALUE_SHAPE        0x08000000 /* pattern has a shape value */
-#define VALUE_FOLLOWUP     0x10000000 /* pattern has a followup value */
-#define VALUE_REV_FOLLOWUP 0x20000000 /* pattern has a reverse followup value 
*/
+#define VALUE_MINVAL       0x01000000 /* pattern has a minimum value */
+#define VALUE_MAXVAL       0x02000000 /* pattern has a maximum value */
+#define VALUE_MINTERRITORY 0x04000000 /* pattern has a min territorial value */
+#define VALUE_MAXTERRITORY 0x08000000 /* pattern has a max territorial value */
+#define VALUE_SHAPE        0x10000000 /* pattern has a shape value */
+#define VALUE_FOLLOWUP     0x20000000 /* pattern has a followup value */
+#define VALUE_REV_FOLLOWUP 0x40000000 /* pattern has a reverse followup value 
*/
 
 /* Collection of the classes inducing move values. */
 #define CLASS_MOVE_VALUES (VALUE_MINVAL | VALUE_MAXVAL | VALUE_MINTERRITORY \
                           | VALUE_MAXTERRITORY | VALUE_SHAPE \




reply via email to

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