gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] attack_either patch


From: Evan Berggren Daniel
Subject: Re: [gnugo-devel] attack_either patch
Date: Sun, 29 Sep 2002 11:53:19 -0400 (EDT)

> > This patch makes the attack_either function in reading.c slightly less
> > stupid.  Now it tries all four possible ataris if both groups have only
> > two liberties.
>
> There was no patch in your message.

Yeah, that would help...

Also, nngs3: 670 gets a PASS that I haven't yet investigated.  There are
no other PASSes of FAILs in the remainder of the regressions.

Thanks

Evan Daniel

Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.78
diff -u -d -r1.78 reading.c
--- engine/reading.c    28 Sep 2002 14:15:26 -0000      1.78
+++ engine/reading.c    29 Sep 2002 03:37:54 -0000
@@ -444,27 +444,48 @@

   /* Try (a little) harder */
   {
-    int libs[2];
-    int alibs = findlib(astr, 2, libs);
+    int alibs[2];
+    int blibs[2];
+    int alibcount = findlib(astr, 2, alibs);
+    int blibcount = findlib(bstr, 2, blibs);
     int defended0 = WIN;
     int defended1 = WIN;
     int other = OTHER_COLOR(color);
+    int best;
     /* Let's just try the case where the group with the fewest liberties
      * has only 2, and try each atari in turn.
      */
-    if (alibs == 2) {
-      if (trymove(libs[0], other, "attack_either-A", astr, EMPTY, NO_MOVE)) {
+    if (alibcount == 2) {
+      if (trymove(alibs[0], other, "attack_either-A", astr, EMPTY, NO_MOVE)) {
        defended0 = defend_both(astr, bstr);
        popgo();
       }
       if (defended0
-         && trymove(libs[1], other, "attack_either-B", astr,
+         && trymove(alibs[1], other, "attack_either-B", astr,
                     EMPTY, NO_MOVE)) {
        defended1 = defend_both(astr, bstr);
        popgo();
       }
     }
-    return REVERSE_RESULT(gg_min(defended0, defended1));
+    best =  REVERSE_RESULT(gg_min(defended0, defended1));
+
+    if (best == WIN) return best;
+
+    if (blibcount == 2) {
+      if (trymove(blibs[0], other, "attack_either-A", astr, EMPTY, NO_MOVE)) {
+       defended0 = defend_both(astr, bstr);
+       popgo();
+      }
+      if (defended0
+         && trymove(blibs[1], other, "attack_either-B", astr,
+                    EMPTY, NO_MOVE)) {
+       defended1 = defend_both(astr, bstr);
+       popgo();
+      }
+      return gg_max(best, REVERSE_RESULT(gg_min(defended0, defended1)));
+    }
+
+    return best;
   }

 }






reply via email to

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