[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] fast_defense()
From: |
Paul Pogonyshev |
Subject: |
[gnugo-devel] fast_defense() |
Date: |
15 Nov 2003 02:55:53 +0000 |
Following simple patch makes fast_defense() a little more efficient.
Since attacker gives up if the string has 4 liberties and current
depth is more than `fourlib_depth', it suffices to find a move that
gives 4 liberties at depth _equal to_ or more than `fourlib_depth' --
once it will be played the depth will be strictly more than
`fourlib_depth'.
In other words, the patch makes fast_defense() look for a move giving
4 liberties one move earlier than before. This gives a slight
decrease in nodes:
before: 1362692055 2450575 8827866
after: 1338004214 2450395 8825826
-1.8% -0.0% -0.0%
Unfortunately, the patch gives a nonzero breakage:
nicklas1:1406 FAIL B9 [B6]
manyfaces1:30 FAIL B10 [C14]
However, if you remember, when fast_defense() was first introduced by
nando, the breakage was nonzero too: it was caused by random changes
in defense moves.
I have additionally verified that the patch is correct with these
three lines put in fast_defense() inside the `if':
gg_assert(trymove(libs[k], color, "test", str, EMPTY, NO_MOVE));
gg_assert(do_attack(str, NULL, EMPTY, NO_MOVE) == 0);
popgo();
Running this through the two failed tests gave no assertion failures.
Paul
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.124
diff -u -p -r1.124 reading.c
--- engine/reading.c 9 Oct 2003 20:25:08 -0000 1.124
+++ engine/reading.c 15 Nov 2003 00:48:56 -0000
@@ -1152,28 +1152,24 @@ do_find_defense(int str, int *move, int
}
-/* Called by the defendN functions.
- * Don't think too much if there's an easy way to get enough liberties
+/* Called by the defendN functions. Don't think too much if there's
+ * an easy way to get enough liberties.
*/
-
static int
fast_defense(int str, int liberties, int *libs, int *move)
{
int color = board[str];
int k;
- int newlibs;
+ int goal_liberties = (stackp < fourlib_depth ? 5 : 4);
ASSERT1(libs != NULL, str);
ASSERT1(move != NULL, str);
for (k = 0; k < liberties; k++) {
- /* accuratelib() to be seems more effective than fastlib() here.
- * (probably because it catches more cases). And since 5 liberties
- * is enough for our purpose, no need to ask for more.
+ /* accuratelib() seems to be more efficient than fastlib() here,
+ * probably because it catches more cases.
*/
- newlibs = accuratelib(libs[k], color, 5, NULL);
- if (newlibs > 4
- || (newlibs == 4 && stackp > fourlib_depth)) {
+ if (accuratelib(libs[k], color, goal_liberties, NULL) >= goal_liberties) {
*move = libs[k];
return 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] fast_defense(),
Paul Pogonyshev <=