gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] mixed patch


From: Gunnar Farneback
Subject: [gnugo-devel] mixed patch
Date: Tue, 17 Jun 2003 17:58:09 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

This patch solves the two remaining open filllib test cases, makes
some scoring fixes, and tries to avoid a class of losing ko threats.
An example of the latter can be found in gunnar:35 where the white ko
threat at D5 loses two points since black no longer has to backfill
before filling the liberties at C7/D7/E7. Unfortunately the patch
doesn't quite solve gunnar:35 but it is effective in many similar
situations.

Regression delta:

filllib:35      PASS A8 [A8|B8]
filllib:43      PASS C6 [C6]
trevora:390     PASS A2 [A2]

- endgame_find_backfilling_dame() revised
- new global array forced_backfilling_moves[]
- find_backfilling_move in filllib.c revised
- disable revise_semeai() when doing_scoring
- no bonus for attack or defense of dead potential cutstones
  when doing_scoring
- reevaluate_ko_threats() revised to avoid playing losing ko threats
- tuning

/Gunnar

Index: engine/dragon.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v
retrieving revision 1.115
diff -u -r1.115 dragon.c
--- engine/dragon.c     9 Jun 2003 16:05:32 -0000       1.115
+++ engine/dragon.c     17 Jun 2003 15:11:40 -0000
@@ -1329,6 +1329,14 @@
        gprintf("False eye territory at %1m\n", pos);
     }
   }
+
+  /* FIXME: This initialization doesn't really belong here but must be
+   *        done somewhere within examine_position().
+   *        The array is eventually filled by the endgame() function.
+   */
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++)
+    if (ON_BOARD(pos))
+      forced_backfilling_moves[pos] = 0;
 }
 
 /* 
Index: engine/endgame.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/endgame.c,v
retrieving revision 1.5
diff -u -r1.5 endgame.c
--- engine/endgame.c    12 May 2003 08:50:42 -0000      1.5
+++ engine/endgame.c    17 Jun 2003 15:11:40 -0000
@@ -61,8 +61,7 @@
        && !worm[pos].inessential
        && worm[pos].attack_codes[0] == 0) {
       endgame_analyze_worm_liberties(pos, color);
-      if (board[pos] == color)
-       endgame_find_backfilling_dame(pos, color);
+      endgame_find_backfilling_dame(pos, color);
     }
   }
 }
@@ -387,9 +386,10 @@
  * blunders while filling dame.
  */
 static void
-endgame_find_backfilling_dame(int str, int color)
+endgame_find_backfilling_dame(int str, int color_to_move)
 {
   int k;
+  int color = board[str];
   int other = OTHER_COLOR(color);
   int essential_liberties;
   int essential_libs[MAXLIBS];
@@ -415,9 +415,10 @@
       if (board[str] == EMPTY)
        break;
       if (attack_and_defend(str, NULL, NULL, NULL, &dpos)) {
-       if (worm[dpos].color == EMPTY)
+       if (worm[dpos].color == EMPTY) 
          move = dpos;
-       trymove(move, color, "endgame", str, EMPTY, NO_MOVE);
+       forced_backfilling_moves[dpos] = 1;
+       trymove(dpos, color, "endgame", str, EMPTY, NO_MOVE);
        loop_again = 1;
        break;
       }
@@ -429,8 +430,10 @@
 
   if (move != NO_MOVE && safe_move(move, color)) {
     TRACE("  backfilling dame found at %1m for string %1m\n", move, str);
-    add_expand_territory_move(move);
-    set_minimum_territorial_value(move, 0.1);
+    if (color == color_to_move) {
+      add_expand_territory_move(move);
+      set_minimum_territorial_value(move, 0.1);
+    }
   }    
 }
 
Index: engine/filllib.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/filllib.c,v
retrieving revision 1.28
diff -u -r1.28 filllib.c
--- engine/filllib.c    22 Feb 2003 10:54:24 -0000      1.28
+++ engine/filllib.c    17 Jun 2003 15:11:40 -0000
@@ -393,7 +393,7 @@
    * filllib:17 for a position where this matters.)
    *
    * It is also necessary to take care to first attack the string with
-   * the fewest liberties, which can probably by removed the fastest.
+   * the fewest liberties, which can probably be removed the fastest.
    * See filllib:37 for an example (J5 tactically attacks K7 but the
    * correct move is H5).
    *
@@ -402,8 +402,15 @@
    * lead to moves which complete the capture but cannot be played
    * before the attacking move itself. This is not ideal but probably
    * good enough.
+   *
+   * In order to avoid losing unnecessary points while capturing dead
+   * stones, we try first to capture stones in atari, second defending
+   * at a liberty, and third capture stones with two or more
+   * liberties. See filllib:43 for a position where capturing dead
+   * stones (B10 or C8) loses a point compared to defending at a
+   * liberty (C6).
    */
-  for (opponent_libs = 1; opponent_libs <= 5; opponent_libs++) {
+  for (opponent_libs = 1; opponent_libs <= 1; opponent_libs++) {
     for (k = 0; k < neighbors; k++) {
       if (opponent_libs < 5 && countlib(adjs[k]) != opponent_libs)
        continue;
@@ -429,6 +436,23 @@
     }
   }
 
+  if (!found_one) {
+    for (opponent_libs = 2; opponent_libs <= 5; opponent_libs++) {
+      for (k = 0; k < neighbors; k++) {
+       if (opponent_libs < 5 && countlib(adjs[k]) != opponent_libs)
+         continue;
+       if (attack(adjs[k], &bpos) == WIN) {
+         if (liberty_of_string(bpos, adjs[k])) {
+           *backfill_move = bpos;
+           return 1;
+         }
+         else
+           saved_move = bpos;
+       }
+      }
+    }
+  }
+  
   /* If no luck so far, try with superstring liberties. */
   if (!found_one) {
     trymove(move, color, "find_backfilling_move", move, EMPTY, NO_MOVE);
Index: engine/genmove.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v
retrieving revision 1.75
diff -u -r1.75 genmove.c
--- engine/genmove.c    9 Jun 2003 16:19:16 -0000       1.75
+++ engine/genmove.c    17 Jun 2003 15:11:41 -0000
@@ -648,6 +648,9 @@
 
   if (stones_on_board(BLACK | WHITE) == 0)
     return 0;
+
+  if (doing_scoring)
+    return 0;
   
   gg_assert(dragon2 != NULL);
 
Index: engine/globals.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/globals.c,v
retrieving revision 1.50
diff -u -r1.50 globals.c
--- engine/globals.c    9 Jun 2003 16:33:19 -0000       1.50
+++ engine/globals.c    17 Jun 2003 15:11:41 -0000
@@ -168,6 +168,7 @@
 int number_close_white_worms[BOARDMAX];
 
 int false_eye_territory[BOARDMAX];
+int forced_backfilling_moves[BOARDMAX];
 
 /* Various statistics are collected here. */
 struct stats_data stats;
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.180
diff -u -r1.180 liberty.h
--- engine/liberty.h    9 Jun 2003 16:19:16 -0000       1.180
+++ engine/liberty.h    17 Jun 2003 15:11:42 -0000
@@ -855,6 +855,7 @@
 extern int number_close_white_worms[BOARDMAX];
 
 extern int false_eye_territory[BOARDMAX];
+extern int forced_backfilling_moves[BOARDMAX];
 
 struct stats_data {
   int nodes;                     /* Number of visited nodes while reading */
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.101
diff -u -r1.101 value_moves.c
--- engine/value_moves.c        9 Jun 2003 18:09:46 -0000       1.101
+++ engine/value_moves.c        17 Jun 2003 15:11:45 -0000
@@ -2042,6 +2042,9 @@
        if (worm[aa].defense_codes[0] == 0)
          break;
 
+       if (doing_scoring && dragon[aa].status == DEAD)
+         break;
+       
        /* FIXME: This is totally ad hoc, just guessing the value of
          *        potential cutting points.
         * FIXME: When worm[aa].cutstone2 == 1 we should probably add
@@ -2998,7 +3001,9 @@
              int apos;
              if (attack(pos, &apos)
                  && does_defend(apos, what)
-                 && !is_proper_eye_space(apos)) {
+                 && (forced_backfilling_moves[apos]
+                     || (!is_proper_eye_space(apos)
+                        && !false_eye_territory[apos]))) {
                threat_does_work = 0;
              }
            }
Index: patterns/patterns.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.db,v
retrieving revision 1.110
diff -u -r1.110 patterns.db
--- patterns/patterns.db        27 May 2003 08:48:24 -0000      1.110
+++ patterns/patterns.db        17 Jun 2003 15:11:47 -0000
@@ -14253,4 +14253,28 @@
 >backfill_replace(*,a)
 
 
+Pattern RE14
+# gf New pattern. (3.3.20)
+# See filllib:35.
+
++---
+|..?       fix up corner eye shape to avoid seki or worse
+|*.O
+|..O
+|O.O
+|.O?
+
+:8,O
+
++---
+|..?
+|*.O
+|b.O
+|OcO
+|aO?
+
+;olib(a)==2 && !oplay_attack(a,b,b)
+>replace(a,*)
+
+
 # END OF FILE




reply via email to

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