[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] A speedup
From: |
Portela Fernando |
Subject: |
[gnugo-devel] A speedup |
Date: |
Mon, 21 Apr 2003 21:35:17 +0200 |
A simple idea : do not try the wrong liberty in a ladder attack.
Regression breakage : none
Performance impact : -6.8% reading nodes
-9.2% trymoves
I measured a 4% speed increase over the whole regression suite, but
better timings should be done by someone else.
/nando
- don't even try the wrong liberty in simple_ladder_attack()
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.110
diff -u -r1.110 reading.c
--- engine/reading.c 1 Mar 2003 12:12:33 -0000 1.110
+++ engine/reading.c 21 Apr 2003 18:39:50 -0000
@@ -5491,10 +5491,21 @@
/* Get the two liberties of (str). */
findlib(str, 2, libs);
- for (k = 0; k < 2; k++)
- ADD_CANDIDATE_MOVE(libs[k], 0, moves, "simple_ladder_attack");
-
- order_moves(str, &moves, other, read_function_name, 0, NO_MOVE);
+ /* Kludge : If the defender can get enough liberties by playing
+ * one of these two, then we have no choice but to block there
+ * and consequently, it is unnecessary to try the other liberty.
+ */
+ if (approxlib(libs[0], color, MAXLIBS, NULL) > 3) {
+ ADD_CANDIDATE_MOVE(libs[0], 0, moves, "simple_ladder_attack");
+ }
+ else if (approxlib(libs[1], color, MAXLIBS, NULL) > 3) {
+ ADD_CANDIDATE_MOVE(libs[1], 0, moves, "simple_ladder_attack");
+ }
+ else {
+ for (k = 0; k < 2; k++)
+ ADD_CANDIDATE_MOVE(libs[k], 0, moves, "simple_ladder_attack");
+ order_moves(str, &moves, other, read_function_name, 0, NO_MOVE);
+ }
for (k = 0; k < moves.num; k++) {
int new_komaster;
- [gnugo-devel] A speedup,
Portela Fernando <=