gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] small revision in find_more_owl_attack_and_defense_moves()


From: Portela Fernand
Subject: [gnugo-devel] small revision in find_more_owl_attack_and_defense_moves()
Date: Tue, 7 Jan 2003 21:52:47 +0100

Following patch solves both test cases I submitted earlier today. My box is
currently busy running a twogtp match, so I haven't run any other regression
tests. I will do and report the results asap.

/nando

- new static function revise_dragon_status()
- find_more_owl_attack_and_defense_moves() revised

Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.76
diff -u -r1.76 value_moves.c
--- engine/value_moves.c        2 Jan 2003 00:23:29 -0000       1.76
+++ engine/value_moves.c        7 Jan 2003 20:48:37 -0000
@@ -269,6 +269,37 @@
   decrease_depth_values();
 }
 
+/* Revise the status of a dragon.
+ * FIXME: Only needed here for the moment, but this function
+ *        logically belongs to dragon.c
+ */
+static void
+revise_dragon_status(int dr, int status, int safety)
+{
+  char safe_stones[BOARDMAX];
+  float strength[BOARDMAX];
+  int color = board[dr];
+  int pos;
+
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++)
+    if (ON_BOARD(pos)
+       && is_same_dragon(pos, dr))
+      dragon[pos].status = status;
+
+  DRAGON2(dr).safety = safety;
+
+  set_strength_data(OTHER_COLOR(color), safe_stones, strength);
+  compute_influence(OTHER_COLOR(color), safe_stones, strength,
+                   OPPOSITE_INFLUENCE(color),
+                   NO_MOVE, "revised dragon");
+
+  set_strength_data(color, safe_stones, strength);
+  compute_influence(color, safe_stones, strength,
+                   INITIAL_INFLUENCE(color),
+                   NO_MOVE, "revised dragon");
+
+  compute_refined_dragon_weaknesses();
+}
 
 /* Test certain moves to see whether they (too) can owl attack or
  * defend an owl critical dragon. Tested moves are
@@ -398,7 +429,8 @@
   for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
     if (IS_STONE(board[pos])
        && dragon[pos].origin == pos
-       && dragon[pos].owl_status == CRITICAL) {
+       && (dragon[pos].owl_status == CRITICAL
+            || dragon[pos].owl_status == DEAD)) {
       for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++) {
        if (board[pos2] != EMPTY)
          continue;
@@ -445,8 +477,16 @@
            if (acode >= dragon[pos].owl_attack_code) {
              if (acode == GAIN)
                add_gain_move(pos2, pos, kworm);
-             else
+              else {
                add_owl_attack_move(pos2, pos, acode);
+                /* if an owl defense has been found for a DEAD dragon
+                 * we need to revise its status to CRITICAL
+                 */
+                if (dragon[pos].owl_status == DEAD) {
+                  revise_dragon_status(pos, CRITICAL, CRITICAL);
+                  TRACE("%1m dragon status revised to CRITICAL.\n", pos);
+                }
+              }
            }
          }
        }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]