gnugo-devel
[Top][All Lists]
Advanced

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

RE: [gnugo-devel] small revision in find_more_owl_attack_and_defe nse_mo


From: Portela Fernand
Subject: RE: [gnugo-devel] small revision in find_more_owl_attack_and_defe nse_moves()
Date: Wed, 8 Jan 2003 16:53:20 +0100

A better patch follows.

Regression breakage : 3 good PASSes and 3 apparently acceptable FAILs

viking:6      FAIL  A12 doesn't look so bad to me. Sure B17/B18 are better
                    but GG at least doesn't tenuki or blunder here (unless
                    I missed something)
strategy2:75  FAIL  F7 is said to be acceptable if Q11 is correctly valued.
                    1. F7  61.45
                    2. Q11 37.67
                    Q11 valuation didn't change, but is this acceptable ?
strategy2:76  FAIL  Same.
                    F7 is said to be acceptable if Q11 is correctly valued.
                    1. F7  61.46
                    2. Q11 42.21
                    Q11 valuation didn't change, but is this acceptable ?
strategy2:78  PASS  Good.
tactics1:106  pass  New test (not in CVS yet), now solved.
arend2:60     PASS  GG now prefers L7, good. 

I have yet to run regressions with CVS to be able to get the performance
delta. Expected is a negligible to small increase in owl nodes.

/nando


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        8 Jan 2003 15:30:25 -0000
@@ -270,6 +270,38 @@
 }
 
 
+/* 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
  * 1. Strategical attacks or defenses for the dragon.
@@ -447,6 +479,69 @@
                add_gain_move(pos2, pos, kworm);
              else
                add_owl_attack_move(pos2, pos, acode);
+           }
+         }
+       }
+      }
+    }
+  }
+
+  for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
+    if (IS_STONE(board[pos])
+       && dragon[pos].origin == pos
+       && dragon[pos].owl_status == DEAD) {
+      for (k = 0; k < DRAGON2(pos).neighbors; k++) {
+       int nd = DRAGON(DRAGON2(pos).adjacent[k]).origin;
+       if (board[nd] == board[pos]
+           || dragon[nd].owl_status != CRITICAL)
+           continue;
+         /* We found a CRITICAL dragon neighboring a DEAD opponent one.
+          * Check if an attack on the CRITICAL neighbor also saves the
+          * (maybe not so) dead one.
+          */
+       if (board[nd] == color) {
+         /* Critical (nd) dragon is ours, dead one (pos) is opponent's
+          * one. */
+         int kworm = NO_MOVE;
+         int dcode = owl_does_defend(dragon[nd].owl_attack_point, pos,
+                                     &kworm);
+         if (dcode > 0 && dcode >= dragon[pos].owl_defense_code) {
+           revise_dragon_status(pos, CRITICAL, CRITICAL);
+           TRACE("%1m dragon status revised to CRITICAL.\n", pos);
+           /* now look for defenses of my dragon which also attacks
+            * the opponent dragon */
+           for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++) {
+             if (board[pos2] != EMPTY)
+               continue;
+             if (owl_defense_move_reason_known(pos2, nd)) {
+               int acode = owl_does_attack(pos2, pos, &kworm);
+               if (acode >= dragon[pos].owl_attack_code) {
+                 if (acode == GAIN)
+                   add_gain_move(pos2, pos, kworm);
+                 else
+                   add_owl_attack_move(pos2, pos, acode);
+               }
+             }
+           }
+         }
+       }
+       else {
+         /* Dead (pos) dragon is ours, critical one (nd) is opponent's
+          * one. */
+         for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++) {
+           if (board[pos2] != EMPTY)
+             continue;
+           if (owl_attack_move_reason_known(pos2, nd)) {
+             int kworm = NO_MOVE;
+             int dcode = owl_does_defend(pos2, pos, &kworm);
+             if (dcode > 0 && dcode >= dragon[pos].owl_defense_code) {
+               revise_dragon_status(pos, CRITICAL, CRITICAL);
+               TRACE("%1m dragon status revised to CRITICAL.\n", pos);
+               if (dcode == LOSS)
+                 add_loss_move(pos2, pos, kworm);
+               else
+                 add_owl_defense_move(pos2, pos, dcode);
+             }
            }
          }
        }




reply via email to

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