gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] arend_3_7.2: Don't trust owl defense more than tactical an


From: Arend Bayer
Subject: [gnugo-devel] arend_3_7.2: Don't trust owl defense more than tactical analysis
Date: Sat, 17 Aug 2002 11:00:21 +0200 (CEST)

This patch changes the policy for OWL_DEFEND_MOVE(...) move reasons. Now
only those parts of the affected dragon are marked saved which are either
tactically stable or tactically defended by this move. To avoid further
bloating estimate_territorial_value() with this stuff, I have moved it to
a separate function in move_reasons.c.

I had hoped to catch two blunders in the Many Faces-game with this, but
century2002:160 isn't solved yet. Instead of the ineffective owl defense at
B8 for D6 GNU Go now plays A8 as connecting D6 to the upper group. This
can be seen as a non-transitivity problem; but it could also be solved by
the same heuristic (i.e. award strategic connection bonus only to those
parts of the dragon that are tactically stable after this move).

Finally, I feel it would help to have a list of worms belonging to each
dragon. This could be done by circularly linking the worm origins, starting
at the dragon origin.

Arend

- new function mark_changed_dragon in move_reasons.c
- Only consider owl-defended stones as safe if they are also tactically safe.

Breakage after this patch (arend_3_7.1 had no effect on regressions;
auto_gen tests not yet included):

./regress.sh . nngs.tst
600 unexpected PASS!
1910 unexpected PASS!
./regress.sh . global.tst
38 unexpected PASS!
./regress.sh . nngs2.tst
1 unexpected PASS!
60 unexpected PASS!
./regress.sh . century-2002.tst
150 unexpected PASS!

Index: engine/move_reasons.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v
retrieving revision 1.89
diff -u -r1.89 move_reasons.c
--- engine/move_reasons.c       3 Jun 2002 15:00:59 -0000       1.89
+++ engine/move_reasons.c       17 Aug 2002 08:45:06 -0000
@@ -1427,6 +1427,65 @@
   }
 }

+/* This function marks all stones whose status is changed by an owl move
+ * reason according to the following rules:
+ * 1. For an owl attack, all stones belonging to the attacked dragon are
+ *    marked as INFLUENCE_CAPTURED_STONE
+ * 2. For an owl defense, all stones belonging to the defended dragon are
+ *    markes as INFLUENCE_SAVED_STONE if they are also tactically stable.
+ *
+ * In effective_size, the sum of the effective size of the changed worms
+ * is returned (unless it is a NULL pointer).
+ */
+void
+mark_changed_dragon(int pos, int affected_dragon, int move_reason_type,
+                   char changed_stones[BOARDMAX], float *effective_size)
+{
+  int ii;
+  char new_status = INFLUENCE_SAVED_STONE;
+
+  ASSERT1(board[pos] == EMPTY, pos);
+  ASSERT1(IS_STONE(board[affected_dragon]), pos);
+
+  if (effective_size != NULL)
+    *effective_size = 0.0;
+
+  switch (move_reason_type) {
+    case OWL_ATTACK_MOVE:
+    case OWL_ATTACK_MOVE_GOOD_KO:
+    case OWL_ATTACK_MOVE_BAD_KO:
+      new_status = INFLUENCE_CAPTURED_STONE;
+      if (effective_size != NULL)
+       *effective_size = dragon[affected_dragon].effective_size;
+      break;
+    case OWL_DEFEND_MOVE:
+    case OWL_DEFEND_MOVE_GOOD_KO:
+    case OWL_DEFEND_MOVE_BAD_KO:
+      break;
+    default:
+      /* mark_changed_dragon() called with invalid move reason. */
+      ASSERT1(0, pos);
+  }
+
+  for (ii = BOARDMIN; ii < BOARDMAX; ii++) {
+    if (IS_STONE(board[ii]) && is_same_dragon(ii, affected_dragon)) {
+      if (new_status == INFLUENCE_CAPTURED_STONE)
+       changed_stones[ii] = new_status;
+      else if (worm[ii].origin == ii
+              && (worm[ii].attack_codes[0] == 0
+                  || defense_move_reason_known(pos, find_worm(ii))
+                  || does_defend(pos, ii))) {
+       /* This string can now be considered safe. Hence we mark the
+        * whole string as such:
+        */
+       mark_string(ii, changed_stones, new_status);
+        if (effective_size != NULL)
+          *effective_size += worm[ii].effective_size;
+      }
+    }
+  }
+}
+

 /* Find dragons rescued by a move at (pos). */
 void
Index: engine/move_reasons.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.h,v
retrieving revision 1.21
diff -u -r1.21 move_reasons.h
--- engine/move_reasons.h       11 Aug 2002 12:13:02 -0000      1.21
+++ engine/move_reasons.h       17 Aug 2002 08:45:07 -0000
@@ -195,6 +195,8 @@
 void discard_redundant_move_reasons(int pos);
 void list_move_reasons(int color);

+void mark_changed_dragon(int pos, int affected_dragon, int move_reason_type,
+                        char changed_stones[BOARDMAX], float *effective_size);

 /*
  * Local Variables:
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.48
diff -u -r1.48 value_moves.c
--- engine/value_moves.c        15 Aug 2002 19:59:39 -0000      1.48
+++ engine/value_moves.c        17 Aug 2002 08:45:18 -0000
@@ -585,6 +585,9 @@
       case OWL_DEFEND_MOVE:
       case OWL_DEFEND_MOVE_GOOD_KO:
       case OWL_DEFEND_MOVE_BAD_KO:
+               /* FIXME: The above imply not necessarily a safe move, if the
+        * defending move is not connected to the dragon defended.
+        */
       case MY_ATARI_ATARI_MOVE:
       case EITHER_MOVE:         /* FIXME: More advanced handling? */
       case ALL_MOVE:            /* FIXME: More advanced handling? */
@@ -1544,19 +1547,11 @@
        break;
       }

-      {
-       int ii;
-       for (ii = BOARDMIN; ii < BOARDMAX; ii++) {
-         if (IS_STONE(board[ii]) && is_same_dragon(ii, aa)) {
-           if (move_reasons[r].type == OWL_ATTACK_MOVE
-               || move_reasons[r].type == OWL_ATTACK_MOVE_GOOD_KO
-               || move_reasons[r].type == OWL_ATTACK_MOVE_BAD_KO)
-             saved_stones[ii] = INFLUENCE_CAPTURED_STONE;
-           else
-             saved_stones[ii] = INFLUENCE_SAVED_STONE;
-         }
-       }
-      }
+      /* Mark the affected dragon for use in the territory analysis. */
+      mark_changed_dragon(pos, aa, move_reasons[r].type, saved_stones,
+                         &this_value);
+      this_value *= 2.0;
+
       TRACE("  %1m: owl attack/defend for %1m\n", pos, aa);

       /* FIXME: How much should we reduce the value for ko attacks? */





reply via email to

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