gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Minor speedup


From: Gunnar Farneback
Subject: [gnugo-devel] Minor speedup
Date: Mon, 19 Jan 2004 20:45:34 +0100
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 has no effects on regressions except a reduction of both
owl nodes and tactical reading nodes by 0.2%.

- avoid calling owl_substantial() when not needed in aa_compute_status()

/Gunnar

Index: engine/combination.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/combination.c,v
retrieving revision 1.47
diff -u -r1.47 combination.c
--- engine/combination.c        18 Jul 2003 18:59:21 -0000      1.47
+++ engine/combination.c        19 Jan 2004 13:26:55 -0000
@@ -507,12 +507,22 @@
     if (board[pos] == other
        && worm[pos].origin == pos
        && worm[pos].liberties == 2
-       && aa_status[pos] == ALIVE
-       && !owl_substantial(pos)) {
-      int pos2;
-      for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++)
-       if (ON_BOARD(pos2) && is_worm_origin(pos2, pos))
-         aa_status[pos2] = INSUBSTANTIAL;
+       && aa_status[pos] == ALIVE) {
+      int libs[2];
+      findlib(pos, 2, libs);
+      /* Don't waste time running owl_substantial() if we can't safely
+       * atari anyway.
+       */
+      if (is_self_atari(libs[0], color)
+         && is_self_atari(libs[1], color))
+       continue;
+      
+      if (!owl_substantial(pos)) {
+       int pos2;
+       for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++)
+         if (ON_BOARD(pos2) && is_worm_origin(pos2, pos))
+           aa_status[pos2] = INSUBSTANTIAL;
+      }
     }
   }
     




reply via email to

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