[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] another blunder patch
From: |
Arend Bayer |
Subject: |
[gnugo-devel] another blunder patch |
Date: |
Sun, 22 Sep 2002 13:24:53 +0200 (CEST) |
This adresses one of Gunnar's recently added FIXMEs. Now detect_owl_blunder()
is always called. It continues to call owl_confirm_safety if there is
a liberty problem, or if we play inside our own eye space, next to another
stone, which belongs to a dragon with mineyes <= 2. On the other hand I
made sure owl_confirm_safety is not called if the relevant move was
actually an owl defense.
Regression delta is one pass for blunder:22.
Arend
- mark_safe_stones() distinguishes between SAFE_STONE and OWL_SAVED_STONE
- detect_owl_blunder() revised
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.115
diff -u -r1.115 liberty.h
--- engine/liberty.h 18 Sep 2002 15:10:02 -0000 1.115
+++ engine/liberty.h 22 Sep 2002 11:03:30 -0000
@@ -531,6 +531,13 @@
#define INFLUENCE_SAVED_STONE 1
#define INFLUENCE_CAPTURED_STONE 2
+/* These values are used to communicate the status of stones when analyzing
+ * a move for potentially being a blunder.
+ */
+/* dead 0 */
+#define SAFE_STONE 1
+#define OWL_SAVED_STONE 2
+
/* This format is used when exporting the moyo segmentation. */
#define MAX_MOYOS MAX_BOARD*MAX_BOARD
Index: engine/move_reasons.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v
retrieving revision 1.93
diff -u -r1.93 move_reasons.c
--- engine/move_reasons.c 17 Sep 2002 10:15:20 -0000 1.93
+++ engine/move_reasons.c 22 Sep 2002 11:03:36 -0000
@@ -1549,16 +1549,19 @@
&& worm[pos].defend_codes[0] == 0))
safe_stones[pos] = 0;
else
- safe_stones[pos] = 1;
+ safe_stones[pos] = SAFE_STONE;
}
else if (board[pos] == color) {
- if (dragon[pos].status == DEAD
- || (dragon[pos].status == CRITICAL && !saved_dragons[pos])
- || (worm[pos].attack_codes[0] != 0
- && (worm[pos].defend_codes[0] == 0 || !saved_worms[pos])))
+ if ((worm[pos].attack_codes[0] != 0
+ && (worm[pos].defend_codes[0] == 0 || !saved_worms[pos]))
+ || dragon[pos].status == DEAD)
+ safe_stones[pos] = 0;
+ else if (saved_dragons[pos])
+ safe_stones[pos] = OWL_SAVED_STONE;
+ else if (dragon[pos].status == CRITICAL)
safe_stones[pos] = 0;
else
- safe_stones[pos] = 1;
+ safe_stones[pos] = SAFE_STONE;
}
else
safe_stones[pos] = 0;
Index: engine/utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v
retrieving revision 1.52
diff -u -r1.52 utils.c
--- engine/utils.c 18 Sep 2002 12:00:25 -0000 1.52
+++ engine/utils.c 22 Sep 2002 11:04:03 -0000
@@ -870,14 +870,10 @@
/* We start by checking whether we have accidentally killed an own
* dragon.
- *
- * FIXME: The liberties check isn't appropriate since the move may
- * reduce own eyespace regardless of the number of outer liberties.
*/
- if (liberties <= 4)
- trouble = detect_owl_blunder(move, color, defense_point,
- safe_stones, liberties,
- &return_value, save_verbose);
+ trouble = detect_owl_blunder(move, color, defense_point,
+ safe_stones, liberties,
+ &return_value, save_verbose);
/* Next we see whether the move has caused tactical complications.
@@ -926,27 +922,51 @@
int ii;
int trouble = 0;
int current_verbose = verbose;
+ int dragon_analyzed[4] = {0, 0, 0, 0};
for (k = 0; k < 4; k++) {
int bpos = move + delta[k];
- if (board[bpos] == color
- && liberties <= worm[bpos].liberties) {
+ int j;
+ /* We get worried if there is a liberty problem (and in this case
+ * there might also be tactical trouble), or if we play inside
+ * our eye space and the dragon is only just alive.
+ */
+ if (board[bpos] != color)
+ continue;
+ if (liberties <= worm[bpos].liberties
+ && liberties <= 4)
trouble = 1;
- if ((dragon[bpos].status == ALIVE
- || (safe_stones
- && safe_stones[bpos]))
- && DRAGON2(bpos).safety != INVINCIBLE
- && DRAGON2(bpos).safety != STRONGLY_ALIVE
- && !owl_confirm_safety(move, bpos, defense_point)) {
- verbose = save_verbose;
- TRACE("Dragon at %1m becomes attackable.\n", bpos);
- verbose = current_verbose;
- *return_value += 2.0 * dragon[bpos].effective_size;
- if (safe_stones)
- for (ii = BOARDMIN; ii < BOARDMAX; ii++)
- if (ON_BOARD(ii) && dragon[ii].origin == dragon[bpos].origin)
- safe_stones[ii] = 0;
- }
+ else
+ if (min_eyes(&(DRAGON2(bpos).genus)) > 2
+ || !is_proper_eye_space(move))
+ continue;
+
+ /* Don't test the same dragon twice. */
+ for (j = 0; j < k; j++)
+ if (dragon_analyzed[j] == dragon[bpos].origin)
+ break;
+ if (j < k)
+ continue;
+ dragon_analyzed[k] = dragon[bpos].origin;
+
+ /* Don't reanalyze if (move) is an owl defense for (bpos). */
+ if (safe_stones && safe_stones[bpos] == OWL_SAVED_STONE)
+ continue;
+
+ if ((dragon[bpos].status == ALIVE
+ || (safe_stones
+ && safe_stones[bpos]))
+ && DRAGON2(bpos).safety != INVINCIBLE
+ && DRAGON2(bpos).safety != STRONGLY_ALIVE
+ && !owl_confirm_safety(move, bpos, defense_point)) {
+ verbose = save_verbose;
+ TRACE("Dragon at %1m becomes attackable.\n", bpos);
+ verbose = current_verbose;
+ *return_value += 2.0 * dragon[bpos].effective_size;
+ if (safe_stones)
+ for (ii = first_worm_in_dragon(bpos); ii != NO_MOVE;
+ ii = next_worm_in_dragon(ii))
+ mark_string(ii, safe_stones, 0);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] another blunder patch,
Arend Bayer <=