gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] large_scale_5_1.1b


From: bump
Subject: [gnugo-devel] large_scale_5_1.1b
Date: Sun, 18 Apr 2004 20:02:09 -0700

This brings the patch large_scale_5_1.1 up to date. The orginal
patch was submitted by Stephane Nicolet back in August and never
used. However it had an impressive breakage of 22 PASS and 11 FAIL.

Ported to 3.5.5, the breakage is less favorable, with 23 PASS
and 24 FAIL. Breakage is listed below.

The patch made use of a gprintf format character %r which
would print a read result. This puzzles me since this
feature does not seem to have been implemented. It is 
obviously a useful feature, so I added it in vgprintf().

The function find_large_scale_owl_attack_moves() has a
parameter save_verbose. Evidently Stephane's intention was
that the value of verbose would be passed to this
function, but instead the parameter save_verbose is
passed by review_move_reasons, and it is not initialized.
The result is that the program talks when it shouldn't.

So this needs to be fixed. I would fix this by making
the traces of find_large_scale_owl_attack_moves contingent
on a debug flag (we could reuse DEBUG_ORACLE_STREAM
making it a synonym of DEBUG_LARGE_SCALE) but I did not
do this.

I made the large scale patch a configure option
disabled by default. So there would be no harm in adding
this patch to the CVS. We need to decide whether we
are still interested in this patch given that the breakage
is now about 50/50.

./regress.sh . nngs1.tst 
42 unexpected PASS!
./regress.sh . arion.tst 
2 unexpected FAIL: Correct 'Q18|S16', got 'S15'
6 unexpected PASS!
./regress.sh . lazarus.tst 
14 unexpected FAIL: Correct 'Q15|T5|H5', got 'S13'
./regress.sh . trevorb.tst 
120 unexpected FAIL: Correct 'N2', got 'E2'
./regress.sh . strategy2.tst 
55 unexpected PASS!
89 unexpected FAIL: Correct '(D16|B7|G13)', got 'H11'
./regress.sh . nicklas1.tst 
1107 unexpected PASS!
./regress.sh . trevor.tst 
163 unexpected FAIL: Correct 'B9', got 'C7'
1100 unexpected PASS!
./regress.sh . nngs.tst 
290 unexpected PASS!
320 unexpected FAIL: Correct 'B15|B16', got 'D17'
330 unexpected FAIL: Correct 'B15|B16', got 'D15'
490 unexpected PASS!
700 unexpected FAIL: Correct 'K17', got 'K16'
1160 unexpected PASS!
1750 unexpected PASS!
./regress.sh . trevorc.tst 
1540 unexpected FAIL: Correct 'M10', got 'M11'
./regress.sh . strategy3.tst 
114 unexpected PASS!
./regress.sh . global.tst 
22 unexpected FAIL: Correct 'F2', got 'H2'
./regress.sh . arend.tst 
9 unexpected FAIL: Correct 'S17', got 'S2'
./regress.sh . strategy4.tst 
167 unexpected PASS!
188 unexpected PASS!
202 unexpected PASS!
./regress.sh . handtalk.tst 
10 unexpected FAIL: Correct 'E9|F8', got 'G8'
./regress.sh . nngs2.tst 
110 unexpected FAIL: Correct 'B14|B13', got 'M16'
140 unexpected FAIL: Correct 'P5', got 'Q5'
600 unexpected PASS!
./regress.sh . nngs3.tst 
220 unexpected PASS!
390 unexpected FAIL: Correct 'O11', got 'O9'
470 unexpected PASS!
490 unexpected FAIL: Correct 'P15', got 'T13'
950 unexpected PASS!
960 unexpected FAIL: Correct 'L8', got 'L9'
./regress.sh . nngs4.tst 
260 unexpected FAIL: Correct 'A4', got 'D8'
650 unexpected FAIL: Correct 'Q2', got 'G12'
./regress.sh . ninestones.tst 
50 unexpected FAIL: Correct 'R13', got 'S13'
./regress.sh . gunnar.tst 
19 unexpected FAIL: Correct 'L4', got 'L3'
./regress.sh . gifu03.tst 
701 unexpected FAIL: Correct '!O19', got 'O19'
702 unexpected PASS!
./regress.sh . seki.tst 
303 unexpected PASS!
806 unexpected FAIL: Correct 'C1', got 'A2'
913 unexpected FAIL: Correct 'B3', got 'A2'
./regress.sh . 9x9.tst 
20 unexpected PASS!
320 unexpected PASS!
330 unexpected PASS!
./regress.sh . cgf2004.tst 
80 unexpected PASS!



Index: configure.in
===================================================================
RCS file: /cvsroot/gnugo/gnugo/configure.in,v
retrieving revision 1.101
diff -u -r1.101 configure.in
--- configure.in        15 Apr 2004 15:21:09 -0000      1.101
+++ configure.in        19 Apr 2004 02:12:23 -0000
@@ -103,6 +103,10 @@
  [  --enable-cosmic-gnugo              use center-oriented influence code
   --disable-cosmic-gnugo             use standard influence code (default)])
 
+AC_ARG_ENABLE(large-scale,
+ [  --enable-large-scale               look for large scale captures
+  --disable-large-scale              don't seek large scale captures 
(default)])
+
 AC_ARG_ENABLE(experimental-connections,
  [  --enable-experimental-connections  use experimental connection analysis 
                                          (default)
@@ -449,7 +453,7 @@
    AC_DEFINE(EXPERIMENTAL_READING, 0)
 fi
 
-dnl ------------ Reading -------------------
+dnl ------------ Cosmic Consciousness -------------------
 
 AH_TEMPLATE([COSMIC_GNUGO],
 [Center oriented influence. Disabled by default.])
@@ -458,6 +462,17 @@
    AC_DEFINE(COSMIC_GNUGO, 1)
 else
    AC_DEFINE(COSMIC_GNUGO, 0)
+fi
+
+dnl ------------ Large Scale -------------------
+
+AH_TEMPLATE([LARGE_SCALE],
+[Large Scale Captures. Disabled by default.])
+
+if test "$enable_large_scale" = "yes" ; then
+   AC_DEFINE(LARGE_SCALE, 1)
+else
+   AC_DEFINE(LARGE_SCALE, 0)
 fi
 
 dnl ------------ Connections -------------------
Index: engine/globals.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/globals.c,v
retrieving revision 1.61
diff -u -r1.61 globals.c
--- engine/globals.c    24 Jan 2004 04:04:56 -0000      1.61
+++ engine/globals.c    19 Apr 2004 02:12:39 -0000
@@ -124,6 +124,7 @@
 int capture_all_dead    = 0;    /* capture all dead opponent stones */
 int play_out_aftermath  = 0;    /* make everything unconditionally settled */
 int resign_allowed      = 0;    /* resign hopeless games */
+int large_scale         = 0;    /* search for large scale owl moves */
 
 int play_mirror_go      = 0;    /* try to play mirror go if possible */
 int mirror_stones_limit = -1;   /* but stop at this number of stones */
Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.106
diff -u -r1.106 gnugo.h
--- engine/gnugo.h      11 Feb 2004 12:36:27 -0000      1.106
+++ engine/gnugo.h      19 Apr 2004 02:12:39 -0000
@@ -339,6 +339,8 @@
 int get_reading_node_counter(void);
 void reset_connection_node_counter(void);
 int get_connection_node_counter(void);
+void change_owl_node_limit(int new_limit, int *old_value);
+
 
 
 /* ================================================================ */
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.212
diff -u -r1.212 liberty.h
--- engine/liberty.h    12 Apr 2004 15:28:22 -0000      1.212
+++ engine/liberty.h    19 Apr 2004 02:12:50 -0000
@@ -722,7 +722,7 @@
 extern int owl_threats;              /* compute owl threats */
 extern int experimental_break_in;    /* use experimental module breakin.c */
 extern int cosmic_gnugo;             /* use center oriented influence */
-
+extern int large_scale;              /* seek large scale captures */
 
 extern int thrashing_dragon;        /* Dead opponent's dragon trying to live */
 extern char thrashing_stone[BOARDMAX];        /* All thrashing stones. */
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.206
diff -u -r1.206 owl.c
--- engine/owl.c        15 Apr 2004 00:02:50 -0000      1.206
+++ engine/owl.c        19 Apr 2004 02:14:01 -0000
@@ -6568,6 +6568,18 @@
 }
 
 
+/* Change the owl node limit and sets it to new_limit
+ * Use *old_value to get the previous (old) limit
+ */  
+void
+change_owl_node_limit(int new_limit, int *old_value)
+{
+  if (old_value)
+    *old_value = owl_node_limit;
+  owl_node_limit = new_limit;
+}
+
+
 /*
  * Local Variables:
  * tab-width: 8
Index: engine/persistent.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/persistent.c,v
retrieving revision 1.22
diff -u -r1.22 persistent.c
--- engine/persistent.c 12 Apr 2004 15:22:42 -0000      1.22
+++ engine/persistent.c 19 Apr 2004 02:14:18 -0000
@@ -152,6 +152,7 @@
   int cpos;  /* third input coordinate */
   int result;
   int result_certain;
+  int owl_node_limit; 
   int move;  /* first result coordinate */
   int move2;  /* second result coordinate */
 };
@@ -1443,6 +1444,8 @@
        && persistent_owl_cache[k].apos == apos
        && persistent_owl_cache[k].bpos == bpos
        && persistent_owl_cache[k].cpos == cpos
+       && ((persistent_owl_cache[k].owl_node_limit >= owl_node_limit)
+           || persistent_owl_cache[k].result_certain)
        && verify_stored_board(persistent_owl_cache[k].board)) {
       *result = persistent_owl_cache[k].result;
       if (move)
@@ -1493,6 +1496,8 @@
   persistent_owl_cache[persistent_owl_cache_size].cpos          = cpos;
   persistent_owl_cache[persistent_owl_cache_size].result        = result;
   persistent_owl_cache[persistent_owl_cache_size].result_certain = certain;
+  persistent_owl_cache[persistent_owl_cache_size].owl_node_limit = 
+    owl_node_limit;
   persistent_owl_cache[persistent_owl_cache_size].move          = move;
   persistent_owl_cache[persistent_owl_cache_size].move2                 = 
move2;
   persistent_owl_cache[persistent_owl_cache_size].tactical_nodes =
@@ -1617,6 +1622,8 @@
   gprintf("%o(bpos)          = %1m\n", entry->bpos);
   gprintf("%o(cpos)          = %1m\n", entry->cpos);
   gprintf("%oresult          = %d\n",  entry->result);
+  gprintf("%oresult_certain  = %d\n",  entry->result_certain);
+  gprintf("%oowl_node_limit  = %d\n",  entry->owl_node_limit);
   gprintf("%o(move)          = %1m\n", entry->move);
   gprintf("%o(move2)         = %1m\n", entry->move2);
   
Index: engine/printutils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v
retrieving revision 1.44
diff -u -r1.44 printutils.c
--- engine/printutils.c 24 Jan 2004 04:04:56 -0000      1.44
+++ engine/printutils.c 19 Apr 2004 02:14:18 -0000
@@ -21,6 +21,7 @@
 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 #include "board.h"
+#include "gnugo.h"
 #include "hash.h"
 #include "gg_utils.h"
 
@@ -74,6 +75,34 @@
       {
        double f = va_arg(ap, double); /* passed as double, not float */
        fprintf(outputfile, "%.2f", f);
+       break;
+      }
+      case 'r':
+      {
+       int result = va_arg(ap, int);
+
+       switch (result) {
+       case 0:             
+         fprintf(outputfile, "%s", "0");
+         break;
+       case KO_B:          
+         fprintf(outputfile, "%s", "KO_B");
+         break;
+       case LOSS:          
+         fprintf(outputfile, "%s", "LOSS");
+         break;
+       case GAIN:          
+         fprintf(outputfile, "%s", "GAIN");
+         break;
+       case KO_A:          
+         fprintf(outputfile, "%s", "KO_A");
+         break;
+       case WIN:           
+         fprintf(outputfile, "%s", "WIN");
+         break;
+         
+       default:            fprintf(outputfile, "%s", "ERROR");
+       }
        break;
       }
       case 's':
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.121
diff -u -r1.121 value_moves.c
--- engine/value_moves.c        12 Apr 2004 15:22:44 -0000      1.121
+++ engine/value_moves.c        19 Apr 2004 02:14:54 -0000
@@ -388,7 +388,190 @@
 }
 
 
-/* Test certain moves to see whether they (too) can owl attack or
+/* Test all the moves to see whether they can owl-attack on
+ * a large scale . Tested moves are
+ * 1. Moves that already have a move reason. 
+ * 2. Are not too far away from a small critical dragon (<= 6 stones). 
+ *    The distance used is the Manhatan distance, and the maximum 
+ *    distance is currently 3.
+ */
+static void
+find_large_scale_owl_attack_moves(int color, int save_verbose)
+{
+  int pos;
+  int target;
+  int x, y;
+  int dx, dy;
+  int N = 0; /* number of critical dragons found */
+  int k;
+  int unstable_dragons[MAX_WORMS];
+  int x_min_dragon[MAX_WORMS];
+  int x_max_dragon[MAX_WORMS];
+  int y_min_dragon[MAX_WORMS];
+  int y_max_dragon[MAX_WORMS];
+  int maximum_distance = 3;  /* maximum Manhatan distance tried */
+  int dist;
+  int other= OTHER_COLOR(color);
+  
+  if (save_verbose)
+    gprintf("\nTrying to find large scale attack moves.\n");
+    
+    
+  /* Identify the unstable dragons and store them in a list. */
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
+    if (IS_STONE(board[pos]) 
+        && dragon[pos].origin == pos
+        && board[pos] == other) 
+      if (dragon[pos].status == CRITICAL
+        || DRAGON2(pos).owl_status == CRITICAL)
+         {
+       
+      unstable_dragons[N] = pos;
+
+      if (save_verbose)
+         gprintf("Small critical dragon found at %1m\n", pos);
+      
+      /* Find the physical extension of the dragon, and remember it */
+      /* FIXME : probably there should be a better place to calculate
+                 them, maybe a new field in the dragon2 array ? */
+      x = I(pos);
+      y = J(pos);
+      x_min_dragon[N] = x_max_dragon[N] = x;
+      y_min_dragon[N] = y_max_dragon[N] = y;
+      for (dx = 0; dx < board_size; dx++)
+        for (dy = 0; dy < board_size; dy++) {
+          
+          if (ON_BOARD2(dx, dy) 
+              && is_same_dragon(pos, POS(dx, dy)))
+            {
+            if (dx < x_min_dragon[N]) 
+              x_min_dragon[N] = dx;
+            if (dx > x_max_dragon[N]) 
+              x_max_dragon[N] = dx;
+            if (dy < y_min_dragon[N]) 
+              y_min_dragon[N] = dy;
+            if (dy > y_max_dragon[N]) 
+              y_max_dragon[N] = dy;
+            }
+         }
+       N++;
+    }
+  }
+  
+  
+  
+  /* For each unstable dragon, try to find large scale attacks.
+     We do this by first trying to find attacks at dist = 0, then
+     dist = 1, etc., up to maximum_distance */
+  for (k = 0; k < N ; k++)
+    for (dist = 0; dist <= maximum_distance; dist++)
+      for (x = x_min_dragon[k]-dist; x <= x_max_dragon[k]+dist; x++)
+        for (y = y_min_dragon[k]-dist; y <= y_max_dragon[k]+dist; y++)
+        {
+          target = unstable_dragons[k];
+          pos = POS(x,y);
+          
+          if (ON_BOARD2(x,y) && ON_BOARD1(pos) && (board[pos] == EMPTY)) {
+            int a, b;
+            a = abs(x - x_min_dragon[k]);
+            b = abs(x - x_max_dragon[k]);
+            dx = gg_min(a,b);
+            a = abs(y - y_min_dragon[k]);
+            b = abs(y - y_max_dragon[k]);
+            dy = gg_min(a, b);
+          
+            if (gg_max(dx, dy) == dist) { /* maximum Manhatan distance */
+              int has_move_reasons = 0;
+              int worth_trying = 0;
+            
+              /* See if that move has other move reasons */
+              has_move_reasons = 0;
+              for (a = 0; a < MAX_REASONS; a++) {
+                int r = move[pos].reason[a];
+                if (r < 0)
+                  break;
+                  
+                has_move_reasons = 1;
+               }
+              
+              
+              /* We try all large scale attacks on small dragons (and 
+                 only moves with other move reason) */
+              if (board[target] == other)
+                worth_trying = ((dragon[target].size <= 6) 
+                                && has_move_reasons);
+                
+  
+              if (worth_trying) {
+              
+                int owl_nodes_before;
+               int owl_nodes_used;
+               int old_node_limit;
+               int new_node_limit;
+               
+                if (save_verbose >= 2)
+                  gprintf("Trying large scale move %1m on %1m\n", pos, target);
+                           
+                           
+               /* To avoid horizon effects, we temporarily increase 
+                * the depth values to find the large scale attacks. */
+                increase_depth_values(); 
+               
+                /* To reduce the amount of aji allowed for large scale
+                 * attacks, we reduce the owl limit to 350 nodes for
+                 * attacks at distance <= 1, and 150 nodes for attacks at
+                 * distance >= 2     
+                 */
+                if (dist <= 1)
+                  new_node_limit = gg_min(350, owl_node_limit);
+                else
+                  new_node_limit = gg_min(150, owl_node_limit);
+                change_owl_node_limit(new_node_limit, &old_node_limit); 
+                
+                
+                /* Try large scale killing moves on opponent's stones */
+                owl_nodes_before = get_owl_node_counter(); 
+                if (board[target] == other
+                  && !owl_attack_move_reason_known(pos, target)) {
+                  int kworm = NO_MOVE;
+                  int acode = owl_does_attack(pos, target, &kworm);
+                  
+                  owl_nodes_used = get_owl_node_counter() - owl_nodes_before;
+                  
+                  if ((acode >= DRAGON2(target).owl_attack_code) &&
+                     (acode == WIN)) {
+                    if (acode == GAIN)
+                      add_gain_move(pos, target, kworm);
+                    else
+                      add_owl_attack_move(pos, target, kworm, acode);
+                    if (save_verbose) 
+                      gprintf("Move at %1m owl-attacks %1m on a large 
scale(%r).\n", 
+                             pos, target, acode);
+                  }
+                  else if ( save_verbose >= 2) 
+                    gprintf("Move at %1m isn't a clean large scale attack on 
%1m (%r).\n", pos, target, acode);
+                  
+                  if ( save_verbose >= 2)
+                      gprintf("  owl nodes used = %d, dist = %d\n", 
+                              owl_nodes_used, dist);
+                }
+                
+                
+                /* Restore owl node limit */
+                change_owl_node_limit(old_node_limit, NULL);
+                                  
+                /* Restore the depth values */
+                decrease_depth_values(); 
+                                                   
+                       
+             }
+           }
+         }
+       }       
+}
+
+
+/* Test certain moves to see whether they (too) can owl-attack or
  * defend an owl critical dragon. Tested moves are
  * 1. Strategical attacks or defenses for the dragon.
  * 2. Vital eye points for the dragon.
@@ -1902,7 +2085,9 @@
          && dragon[aa].size == worm[aa].size
          && worm[aa].attack_codes[0] == WIN
          && attack_move_reason_known(pos, aa) != WIN) {
-       this_value = 0.05 * (2 * worm[aa].effective_size);
+       if (large_scale)
+         this_value = (2.0 + 0.05 * (2 * worm[aa].effective_size));
+       else this_value = 0.05 * (2 * worm[aa].effective_size);
        TRACE("  %1m: -%f - suspected ineffective owl attack of worm %1m\n",
              pos, this_value, aa);
        tot_value -= this_value;
@@ -3366,8 +3551,12 @@
   
   start_timer(2);
   find_more_attack_and_defense_moves(color);
-  time_report(2, "  find_more_attack_and_defense_moves", NO_MOVE, 1.0);
+  if (large_scale && level >= 6) {
+    find_large_scale_owl_attack_moves(color, save_verbose);
+    time_report(2, "  find_large_scale_owl_attack_moves", NO_MOVE, 1.0);
+  }
 
+  time_report(2, "  find_more_attack_and_defense_moves", NO_MOVE, 1.0);
   if (level >= 6) {
     find_more_owl_attack_and_defense_moves(color);
     time_report(2, "  find_more_owl_attack_and_defense_moves", NO_MOVE, 1.0);
Index: interface/main.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/main.c,v
retrieving revision 1.93
diff -u -r1.93 main.c
--- interface/main.c    27 Feb 2004 21:18:10 -0000      1.93
+++ interface/main.c    19 Apr 2004 02:15:10 -0000
@@ -97,6 +97,8 @@
       OPT_WITHOUT_BREAK_IN,
       OPT_COSMIC_GNUGO,
       OPT_NO_COSMIC_GNUGO,
+      OPT_LARGE_SCALE,
+      OPT_NO_LARGE_SCALE,
       OPT_OPTIONS,
       OPT_STANDARD_SEMEAI,
       OPT_STANDARD_CONNECTIONS,
@@ -245,6 +247,8 @@
   {"without-break-in",  no_argument, 0, OPT_WITHOUT_BREAK_IN},
   {"cosmic-gnugo",   no_argument, 0, OPT_COSMIC_GNUGO},
   {"no-cosmic-gnugo",   no_argument, 0, OPT_NO_COSMIC_GNUGO},
+  {"large-scale",    no_argument, 0, OPT_COSMIC_GNUGO},
+  {"no-large-scale",    no_argument, 0, OPT_NO_COSMIC_GNUGO},
   {"options",        no_argument, 0, OPT_OPTIONS},
   {"allow-suicide",  no_argument,       0, OPT_ALLOW_SUICIDE},
   {"capture-all-dead",   no_argument,   0, OPT_CAPTURE_ALL_DEAD},
@@ -365,6 +369,7 @@
   experimental_semeai = EXPERIMENTAL_SEMEAI;
   experimental_connections = EXPERIMENTAL_CONNECTIONS;
   cosmic_gnugo = COSMIC_GNUGO;
+  large_scale = LARGE_SCALE;
 
   allow_suicide = 0;
   capture_all_dead = 0;
@@ -468,6 +473,9 @@
        if (COSMIC_GNUGO)
          fprintf(stderr,
                  "configure option enabled: cosmic GNU Go \n");
+       if (LARGE_SCALE)
+         fprintf(stderr,
+                 "configure option enabled: large scale captures \n");
        if (EXPERIMENTAL_CONNECTIONS)
          fprintf(stderr,
                  "configure option enabled: experimental connections\n");
@@ -600,6 +608,14 @@
        cosmic_gnugo = 0;
        break;
 
+      case OPT_LARGE_SCALE:
+       large_scale = 1;
+       break;
+
+      case OPT_NO_LARGE_SCALE:
+       large_scale = 0;
+       break;
+
       case OPT_ALLOW_SUICIDE:
        allow_suicide = 1;
        break;
@@ -1448,6 +1464,8 @@
    --without-break-in      do not use the break-in code\n\
    --cosmic-gnugo          use center oriented influence\n\
    --no-cosmic-gnugo       don't use center oriented influence\n\
+   --large-scale           look for large scale captures\n\
+   --no-large-scape        don't seek large scale captures\n\
    --nofusekidb            turn off fuseki database\n\
    --nofuseki              turn off fuseki moves entirely\n\
    --nojosekidb            turn off joseki database\n\





reply via email to

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