[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] Another reading patch
From: |
Evan Berggren Daniel |
Subject: |
[gnugo-devel] Another reading patch |
Date: |
Thu, 3 Oct 2002 21:03:51 -0400 (EDT) |
This patch applies on top of evan_3_10.1.
- defend_both now returns ko results properly.
- defend_both attempts to upgrade ko results.
- defend_both uses attack_either() instead of !attack().
- comments in attack_either and defend_both updated.
I mentioned on nngs that the defend_both patch didn't do much, and that
attempting to upgrade ko results in attack_either helped. Turns out I had
it backwards.
Things should slow down a little as a result, though I haven't
investigated how much yet. I'll post results, and maybe add some depth
constraints (give up on fancy things in defend_both below some reading
depth, give up on trying ataris in attack_either below same).
Regression delta is
13x13:40 PASS
13x13:42 PASS
Thanks
Evan Daniel
diff -u engine/reading.c engine/reading.c
--- engine/reading.c 29 Sep 2002 03:37:54 -0000
+++ engine/reading.c 4 Oct 2002 00:56:24 -0000
@@ -403,8 +403,8 @@
* stones.
*
* FIXME: The current implementation only looks for uncoordinated
- * attacks. This is insufficient to find double ataris or
- * moves such as 'a' in positions like
+ * attacks. This is insufficient to find moves such as 'a'
+ * in positions like
*
* XOOOOOOOX
* XOXXOXXOX
@@ -413,6 +413,11 @@
*
* where neither of the threatened X stones can be captured right
* out. Still either can be captured by a move down to a.
+ *
+ * This is not actually a big deal. We (currently, as of 3.3.9)
+ * don't use this function in cases like that. Fixing this
+ * generates 0 PASSes. Perhaps we should use it like that,
+ * but it's probably too expensive.
*/
int
@@ -421,6 +426,7 @@
int asuccess = 0;
int bsuccess = 0;
int color = board[astr];
+ int best = 0;
ASSERT1(IS_STONE(color) , astr);
ASSERT1(color == board[bstr], bstr);
@@ -438,9 +444,21 @@
return asuccess;
bsuccess = attack(bstr, NULL);
- if (asuccess || bsuccess) {
- return (asuccess > bsuccess) ? asuccess : bsuccess;
- }
+ if (bsuccess == WIN)
+ return bsuccess;
+
+ best = gg_max(asuccess, bsuccess);
+
+ /* We could attempt to upgrade ko results, but it doesn't
+ * seem to help any.
+ */
+ if (best != 0) return best;
+
+ /* this is to prevent a crash in case of
+ * alib == 1, blib == 2, and a snapback around a.
+ */
+ if (countlib(astr) == 1)
+ return best;
/* Try (a little) harder */
{
@@ -451,7 +469,6 @@
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.
*/
@@ -466,10 +483,10 @@
defended1 = defend_both(astr, bstr);
popgo();
}
+ best = gg_max(best, REVERSE_RESULT(gg_min(defended0, defended1)));
+ if (best == WIN) return best;
}
- 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)) {
@@ -482,12 +499,11 @@
defended1 = defend_both(astr, bstr);
popgo();
}
- return gg_max(best, REVERSE_RESULT(gg_min(defended0, defended1)));
+ best = gg_max(best, REVERSE_RESULT(gg_min(defended0, defended1)));
}
return best;
}
-
}
@@ -511,6 +527,7 @@
int b_savepos;
int acode = 0;
int dcode = 0;
+ int best = 0;
int color = board[astr];
ASSERT1(IS_STONE(color) , astr);
@@ -554,19 +571,19 @@
*/
if (trymove(a_savepos, color, "defend_both-A", astr, EMPTY, NO_MOVE)) {
- if (board[bstr] && !attack(bstr, NULL)) {
- popgo();
- return WIN;
+ if (board[bstr]) {
+ best = gg_max(best, REVERSE_RESULT(attack_either(astr, bstr)));
}
popgo();
+ if (best == WIN) return best;
}
if (trymove(b_savepos, color, "defend_both-B", bstr, EMPTY, NO_MOVE)) {
- if (board[astr] && !attack(astr, NULL)) {
- popgo();
- return WIN;
+ if (board[bstr]) {
+ best = gg_max(best, REVERSE_RESULT(attack_either(astr, bstr)));
}
popgo();
+ if (best == WIN) return best;
}
/* The next improvement is to try to attack a common adjacent string. */
@@ -598,21 +615,21 @@
if (attack(epos, &fpos)) {
if (trymove(fpos, color, "defend_both-C", astr, EMPTY, NO_MOVE)) {
- if (board[astr] && board[bstr]
- && !attack(astr, NULL)
- && !attack(bstr, NULL)) {
- popgo();
- return WIN;
+ if (board[astr] && board[bstr]) {
+ best = gg_max(best, REVERSE_RESULT(attack_either(astr, bstr)));
}
popgo();
+ if (best == WIN) return best;
}
}
}
}
}
- /* Both strings can be attacked but we have only time to defend one. */
- return 0;
+ /* We haven't found a way to guarantee defense, but we might have found
+ * a way to defend in ko.
+ */
+ return best;
}
- [gnugo-devel] Another reading patch,
Evan Berggren Daniel <=