[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] does_attack() and does_defend() revisions
From: |
Gunnar Farnebäck |
Subject: |
[gnugo-devel] does_attack() and does_defend() revisions |
Date: |
Mon, 06 Dec 2004 05:55:57 +0100 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI) |
Currently does_attack() and does_defend() consult the worm data if
stackp == 0. That made a lot of sense long ago before we had caching
of tactical reading results. Today it's only an unnecessary code
complication and an annoyance that you have to run make_worms() before
calling those functions at stackp == 0, e.g. from the gtp interface.
This patch removes the worm data dependency. Zero breakage and
negligible node changes (+0.0018% -0.0022% -0.016%).
- stop using worm data at stackp==0 in does_attack() and does_defend()
/Gunnar
Index: engine/utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.102
diff -u -r1.102 utils.c
--- engine/utils.c 20 Nov 2004 18:57:09 -0000 1.102
+++ engine/utils.c 29 Nov 2004 03:55:11 -0000
@@ -101,17 +101,9 @@
int dcode = 0;
int spos = NO_MOVE;
- if (stackp == 0) {
- if (worm[str].attack_codes[0] != 0
- && worm[str].defense_codes[0] == 0)
- return 0;
- spos = worm[str].defense_points[0];
- }
- else {
- attack_and_defend(str, &acode, NULL, &dcode, &spos);
- if (acode != 0 && dcode == 0)
- return 0;
- }
+ attack_and_defend(str, &acode, NULL, &dcode, &spos);
+ if (acode != 0 && dcode == 0)
+ return 0;
if (trymove(move, other, "does_attack-A", str)) {
if (!board[str])
@@ -156,13 +148,7 @@
int result = 0;
int spos = NO_MOVE;
- if (stackp == 0) {
- if (worm[str].attack_codes[0] == 0)
- return 0;
- else
- spos = worm[str].attack_points[0];
- }
- else if (!attack(str, &spos))
+ if (!attack(str, &spos))
return 0;
gg_assert(spos != NO_MOVE);
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.160
diff -u -r1.160 play_gtp.c
--- interface/play_gtp.c 19 Nov 2004 04:30:09 -0000 1.160
+++ interface/play_gtp.c 29 Nov 2004 03:55:12 -0000
@@ -1356,9 +1361,6 @@
if (BOARD(i, j) == EMPTY)
return gtp_failure("string vertex must not be empty");
- if (stackp == 0)
- silent_examine_position(EXAMINE_WORMS);
-
/* to get the variations into the sgf file, clear the reading cache */
if (sgf_dumptree)
reading_cache_clear();
@@ -1397,9 +1399,6 @@
if (BOARD(i, j) == EMPTY)
return gtp_failure("string vertex must not be empty");
- if (stackp == 0)
- silent_examine_position(EXAMINE_WORMS);
-
/* to get the variations into the sgf file, clear the reading cache */
if (sgf_dumptree)
reading_cache_clear();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] does_attack() and does_defend() revisions,
Gunnar Farnebäck <=