gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] arend_1_14.6a


From: Arend Bayer
Subject: [gnugo-devel] arend_1_14.6a
Date: Sat, 17 Nov 2001 00:39:41 +0100 (CET)

Here is a revised version of my patch arend_1_14.6.

- use of minimum move values changed (in value_move_reasons)
- New class CLASS_F as part of CLASS_MOVE_REASONS
- new command line option -F and handling of F class added in mkpat.c
- fuseki.db and joseki databases get compiled with mkpat -F
- treatment of j/t patterns in shapes_callback changed 

The effects of these changes should be in detail: 

No change for J/U patterns (this is different to arend_1_14.6)

Patterns in fuseki.db and in the joseki database (I had forgotten joseki
databases in previous patch) get the class F by default.  This can be
toggled for each pattern by adding F in the move classification.

GnuGo chooses randomly between different moves of class jF (resp. tF).
Moves of class j/t without class F (which frequently appears in patterns.db)
no longer have a maximum value. Choice between different such moves is
according to GnuGo's valuation as a secondary reason (which is valued
sufficiently low so that it does not overrule shape tuning).
A move of class jF is preferred to class j unless GnuGo values the latter
to be worth more than 20 pts; similarly with t patterns.

Choice between other moves with identical minimum value (with min. val < 25)
is again according to GnuGo's judgement as a secondary criterium.

-Arend




Index: 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
--- engine/move_reasons.c       2001/11/14 19:16:28     1.38
+++ engine/move_reasons.c       2001/11/16 23:03:39
@@ -3601,18 +3601,31 @@
       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, and unless min_value is bigger than 25, in which
+   * case it probably comes from a J or U pattern):
+   */
+  if (move[pos].min_value < 25)
+    move[pos].min_value += tot_value / 200;
+  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);
+  }
+  
   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: engine/shapes.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/shapes.c,v
retrieving revision 1.17
diff -U4 -r1.17 shapes.c
--- engine/shapes.c     2001/11/09 19:03:43     1.17
+++ engine/shapes.c     2001/11/16 23:03:41
@@ -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: patterns/Makefile.am
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.am,v
retrieving revision 1.7
diff -U4 -r1.7 Makefile.am
--- patterns/Makefile.am        2001/11/15 23:54:48     1.7
+++ patterns/Makefile.am        2001/11/16 23:03:43
@@ -95,9 +95,9 @@
        cat  $(srcdir)/patterns.db $(srcdir)/patterns2.db \
                | ./mkpat -b pat >patterns.c
 
 josekidb.c : $(DBBUILT) mkpat$(EXEEXT)
-       cat  $(DBBUILT) | ./mkpat -b joseki >josekidb.c
+       cat  $(DBBUILT) | ./mkpat -b -F joseki >josekidb.c
 
 apatterns.c : $(srcdir)/attack.db mkpat$(EXEEXT)
        cat $(srcdir)/attack.db | ./mkpat -X attpat >apatterns.c
 
@@ -128,9 +128,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: patterns/Makefile.in
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.in,v
retrieving revision 1.18
diff -U4 -r1.18 Makefile.in
--- patterns/Makefile.in        2001/11/15 23:54:48     1.18
+++ patterns/Makefile.in        2001/11/16 23:03:50
@@ -438,9 +438,9 @@
        cat  $(srcdir)/patterns.db $(srcdir)/patterns2.db \
                | ./mkpat -b pat >patterns.c
 
 josekidb.c : $(DBBUILT) mkpat$(EXEEXT)
-       cat  $(DBBUILT) | ./mkpat -b joseki >josekidb.c
+       cat  $(DBBUILT) | ./mkpat -b -F joseki >josekidb.c
 
 apatterns.c : $(srcdir)/attack.db mkpat$(EXEEXT)
        cat $(srcdir)/attack.db | ./mkpat -X attpat >apatterns.c
 
@@ -471,9 +471,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: patterns/fuseki.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/fuseki.db,v
retrieving revision 1.1
diff -U4 -r1.1 fuseki.db
--- patterns/fuseki.db  2001/09/26 15:31:32     1.1
+++ patterns/fuseki.db  2001/11/16 23:03:51
@@ -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: patterns/mkpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v
retrieving revision 1.29
diff -U4 -r1.29 mkpat.c
--- patterns/mkpat.c    2001/11/15 16:18:40     1.29
+++ patterns/mkpat.c    2001/11/16 23:03:53
@@ -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: patterns/patterns.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v
retrieving revision 1.13
diff -U4 -r1.13 patterns.h
--- patterns/patterns.h 2001/11/09 21:06:53     1.13
+++ patterns/patterns.h 2001/11/16 23:04:12
@@ -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]