gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Patch: Invasion patterns and INVASION_MOVE


From: Inge Wallin
Subject: [gnugo-devel] Patch: Invasion patterns and INVASION_MOVE
Date: Thu, 3 Oct 2002 23:19:28 +0200 (MEST)

Here is the patch I was discussing earlier.  It implements invasions
as a move reason and also as a pattern class.  The reason for it is
the function strategic_penalty that tries to compensate for an
overvaluation of invasions, but that does it without knowing whether
the move actually is an invasion or not.  After this patch, at least
we have a way of telling it if we want it to be or not.

Unfortunately my laptop is very slow, so I haven't had opportunity yet
to run the tests, but I ran the first batch and the only difference
was one FAIL (version 3.3.8).  I didn't manage to fix the test I was
going for (13x13:20), because there is a huge strategic effect on the
chosen move that makes it impossible to get it right at this time.
However, I managed to get the valuation of the correct move up to
something that is in the vincinity of the right score.

Summary: 
 - new move reason INVASION_MOVE
 - pattern class I (invasions) can now be used in patterns.db et al
   and not only in influence patterns
 - remove EXPAND_TERRITORY_MOVE from strategic_penalty()
 - some patterns converted from e or E patterns to I patterns
 - a few bug fixes in patterns and tests

   -Inge

================================================================

diff -ur gnugo-3.3.8/engine/liberty.h gnugo-3.3.8iw/engine/liberty.h
--- gnugo-3.3.8/engine/liberty.h        Tue Sep  3 16:13:37 2002
+++ gnugo-3.3.8iw/engine/liberty.h      Tue Oct  1 21:17:04 2002
@@ -381,6 +381,7 @@
 void add_my_atari_atari_move(int pos, int size);
 void add_your_atari_atari_move(int pos, int size);
 void add_vital_eye_move(int pos, int eyespace, int color);
+void add_invasion_move(int pos);
 void add_expand_territory_move(int pos);
 void add_expand_moyo_move(int pos);
 void add_strategical_attack_move(int pos, int dr);
diff -ur gnugo-3.3.8/engine/move_reasons.c gnugo-3.3.8iw/engine/move_reasons.c
--- gnugo-3.3.8/engine/move_reasons.c   Thu Sep  5 01:19:17 2002
+++ gnugo-3.3.8iw/engine/move_reasons.c Tue Oct  1 21:18:36 2002
@@ -335,6 +335,7 @@
   case ANTISUJI_MOVE:
   case EXPAND_TERRITORY_MOVE:
   case EXPAND_MOYO_MOVE:
+  case INVASION_MOVE:
   case MY_ATARI_ATARI_MOVE:
   case YOUR_ATARI_ATARI_MOVE:
     return NO_MOVE;
@@ -1075,6 +1076,15 @@
 }
 
 /*
+ * Add to the reasons for the move at (pos) that it is an invasion.
+ */
+void
+add_invasion_move(int pos)
+{
+  add_move_reason(pos, INVASION_MOVE, 0);
+}
+
+/*
  * This function is called when a shape value for the move at (pos)
  * is found. 
  * 
@@ -1756,6 +1766,10 @@
          gprintf("Move at %1m expands moyo\n", pos);
          break;
          
+       case INVASION_MOVE:
+         gprintf("Move at %1m is an invasion\n", pos);
+         break;
+         
        case STRATEGIC_ATTACK_MOVE:
        case STRATEGIC_DEFEND_MOVE:
          aa = dragons[move_reasons[r].what];
diff -ur gnugo-3.3.8/engine/move_reasons.h gnugo-3.3.8iw/engine/move_reasons.h
--- gnugo-3.3.8/engine/move_reasons.h   Mon Aug 26 01:49:24 2002
+++ gnugo-3.3.8iw/engine/move_reasons.h Tue Oct  1 21:15:55 2002
@@ -39,8 +39,9 @@
 #define SEMEAI_THREAT           (SEMEAI_MOVE | THREAT_BIT)
 
 /*      BLOCK_TERRITORY_MOVE    20   OBSOLETE */
-#define EXPAND_TERRITORY_MOVE   22
-#define EXPAND_MOYO_MOVE        24
+#define EXPAND_TERRITORY_MOVE   20
+#define EXPAND_MOYO_MOVE        22
+#define INVASION_MOVE           24
 
 #define OWL_ATTACK_MOVE         26
 #define OWL_ATTACK_MOVE_GOOD_KO 28
diff -ur gnugo-3.3.8/engine/shapes.c gnugo-3.3.8iw/engine/shapes.c
--- gnugo-3.3.8/engine/shapes.c Tue Sep  3 16:13:37 2002
+++ gnugo-3.3.8iw/engine/shapes.c       Tue Oct  1 21:37:48 2002
@@ -342,6 +342,12 @@
     TRACE("...expands moyo\n");
   }
 
+  /* Pattern class i, an invasion. */
+  if (class & CLASS_I) {
+    add_invasion_move(move);
+    TRACE("...is an invasion\n");
+  }
+
   /* Pattern class a, strategical level attack on all opponent dragons. */
   if (class & CLASS_a) {
     for (k = 0; k < your_ndragons; k++) {
diff -ur gnugo-3.3.8/engine/value_moves.c gnugo-3.3.8iw/engine/value_moves.c
--- gnugo-3.3.8/engine/value_moves.c    Tue Sep  3 16:13:37 2002
+++ gnugo-3.3.8iw/engine/value_moves.c  Thu Oct  3 14:19:50 2002
@@ -610,6 +610,8 @@
        break;
       case EXPAND_TERRITORY_MOVE:
       case EXPAND_MOYO_MOVE:
+      case INVASION_MOVE:   /* A real invasion should be safe.
+                              A sacrifice is something else.*/
         safety = 1;
        break;
       case ATTACK_MOVE:
@@ -1113,11 +1115,17 @@
       break;
     /* We assume that invasion moves can only have the move reasons listed
      * below.
+     *
+     * FIXME: EXPAND_TERRITORY should always be connected to our own
+     *        stones.  Remove later when that change is done.
      */
     switch (move_reasons[r].type) {
+#if 0
     case EXPAND_TERRITORY_MOVE:
+#endif
     case EXPAND_MOYO_MOVE:
     case STRATEGIC_ATTACK_MOVE:
+    case INVASION_MOVE:
       continue;
     /* If we find a tactical defense move, we just test whether it concerns
      * a single-stone-dragon; if not, we stop, if yes, we let the necessary
@@ -1512,6 +1520,7 @@
     case STRATEGIC_DEFEND_MOVE:
     case EXPAND_MOYO_MOVE:
     case EXPAND_TERRITORY_MOVE:
+    case INVASION_MOVE:
       does_block = 1;
       break;
       
diff -ur gnugo-3.3.8/patterns/fuseki.db gnugo-3.3.8iw/patterns/fuseki.db
--- gnugo-3.3.8/patterns/fuseki.db      Mon Aug  5 23:04:57 2002
+++ gnugo-3.3.8iw/patterns/fuseki.db    Thu Oct  3 14:12:59 2002
@@ -194,7 +194,7 @@
 |......
 +------
 
-:/,Fe
+:/,FI
 
 
 Pattern F7
@@ -207,7 +207,7 @@
 |.....
 +-----
 
-:/,Fe,shape(-2)
+:/,FI,shape(-2)
 
 
 Pattern F8
@@ -272,7 +272,7 @@
 |......
 +------
 
-:8,Fej,shape(2)
+:8,FIj,shape(2)
 
 
 Pattern F13
@@ -330,7 +330,7 @@
 |......
 +------
 
-:8,Fej,shape(1)
+:8,FIj,shape(1)
 
 
 Pattern F16a
@@ -1292,7 +1292,7 @@
 .......
 -------
 
-:8,Feaj
+:8,FEaj
 
 
 Pattern F602
@@ -1341,7 +1341,7 @@
 ............
 ------------
 
-:8,sFEt,shape(1)
+:8,sFIt,shape(1)
 
 X.........ab
 x....*....cd
@@ -1360,7 +1360,7 @@
 ............
 ------------
 
-:8,sFEt,shape(1)
+:8,sFIt,shape(1)
 
 x.........ab
 X....*....cd
@@ -1379,7 +1379,7 @@
 .........
 ---------
 
-:8,sFEt
+:8,sFIt
 
 
 Pattern F704
@@ -1394,7 +1394,7 @@
 .......
 -------
 
-:8,sFEt,shape(-1)
+:8,sFIt,shape(-1)
 
 ???c?d?
 ?.....?
@@ -1416,7 +1416,7 @@
 ........
 --------
 
-:8,sFEt
+:8,sFIt
 
 
 Pattern F706
@@ -1427,7 +1427,7 @@
 .......
 -------
 
-:8,sFEj
+:8,sFIj
 
 
 # tm - removed (3.1.20)
diff -ur gnugo-3.3.8/patterns/patterns.db gnugo-3.3.8iw/patterns/patterns.db
--- gnugo-3.3.8/patterns/patterns.db    Tue Sep  3 16:13:37 2002
+++ gnugo-3.3.8iw/patterns/patterns.db  Thu Oct  3 14:16:31 2002
@@ -11411,7 +11411,7 @@
 .....
 -----
 
-:8,E
+:8,I
 
 ooooo
 .oooo
@@ -11435,7 +11435,7 @@
 .....
 -----
 
-:8,E
+:8,I
 
 .....
 ..a..
@@ -11458,7 +11458,7 @@
 ......
 ------
 
-:8,E
+:8,I
 
 ......
 ..a...
diff -ur gnugo-3.3.8/patterns/patterns2.db gnugo-3.3.8iw/patterns/patterns2.db
--- gnugo-3.3.8/patterns/patterns2.db   Tue Sep  3 16:13:37 2002
+++ gnugo-3.3.8iw/patterns/patterns2.db Thu Oct  3 11:02:03 2002
@@ -480,7 +480,7 @@
 
 O*.O
 
-:8,C
+:-,C
 
 O*aO
 
diff -ur gnugo-3.3.8/regression/13x13.tst gnugo-3.3.8iw/regression/13x13.tst
--- gnugo-3.3.8/regression/13x13.tst    Tue Aug 13 20:25:01 2002
+++ gnugo-3.3.8iw/regression/13x13.tst  Thu Oct  3 16:23:56 2002
@@ -201,7 +201,9 @@
 39 gg_genmove white
 #? [H4|J4]
 
-# New failure (comparing 3.1.15 with 3.0.0)
+# CATEGORY=FOLLOWUP
+# The followup of K13 is undervalued.
+# In fact, there is none at all (3.3.8)
 loadsgf games/mertin13x13/katsunari-gnugo2.W+4.sgf 50
 40 gg_genmove white
 #? [K13]
@@ -234,13 +236,13 @@
 44 gg_genmove black
 #? [B6]
 
-#CATEGOY=ENDGAME_TUNING
+#CATEGORY=ENDGAME_TUNING
 # B4 is really huge here, appr. 20 pts.
 loadsgf games/mertin13x13/gnugo-goliath1.W+11.sgf 31
 45 gg_genmove black
 #? [B4]
 
-#CATEGOY=ENDGAME_TUNING
+#CATEGORY=ENDGAME_TUNING
 # L3 is 2pt double sente.
 loadsgf games/mertin13x13/gnugo-goliath1.W+11.sgf 85
 46 gg_genmove black




reply via email to

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