gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] filllib patch


From: Gunnar Farneback
Subject: [gnugo-devel] filllib patch
Date: Fri, 26 Apr 2002 20:52:06 +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 filllib patch resolves a FIXME and test case filllib:37.

/Gunnar

Index: engine/filllib.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/filllib.c,v
retrieving revision 1.19
diff -u -r1.19 filllib.c
--- engine/filllib.c    7 Apr 2002 13:47:21 -0000       1.19
+++ engine/filllib.c    26 Apr 2002 17:45:03 -0000
@@ -364,6 +364,7 @@
   int success = 0;
   int acode;
   int saved_move = NO_MOVE;
+  int opponent_libs;
   
   /* Play (move) and identify all liberties and adjacent strings. */
   if (!trymove(move, color, "find_backfilling_move", move, EMPTY, NO_MOVE))
@@ -390,9 +391,10 @@
    * trust it but keep it around if we don't find anything else. (See
    * filllib:17 for a position where this matters.)
    *
-   * FIXME: Maybe we should take care to find the neighbor with the
-   * fewest liberties, since that string probably can be removed
-   * fastest. For the moment we assume this to be nonimportant.
+   * It is also necessary to take care to first attack the string with
+   * the fewest liberties, which can probably by removed the fastest.
+   * See filllib:37 for an example (J5 tactically attacks K7 but the
+   * correct move is H5).
    *
    * FIXME: It seems we have to return immediately when we find an
    * attacking move, because recursing for further backfilling might
@@ -400,14 +402,18 @@
    * before the attacking move itself. This is not ideal but probably
    * good enough.
    */
-  for (k = 0; k < neighbors; k++) {
-    if (attack(adjs[k], &bpos) == WIN) {
-      if (liberty_of_string(bpos, adjs[k])) {
-       *backfill_move = bpos;
-       return 1;
+  for (opponent_libs = 1; 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;
       }
-      else
-       saved_move = bpos;
     }
   }
   



reply via email to

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