Index: engine/value_moves.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/value_moves.c,v
retrieving revision 1.171
diff -u -p -r1.171 value_moves.c
--- engine/value_moves.c	11 Jan 2007 20:35:48 -0000	1.171
+++ engine/value_moves.c	24 Apr 2007 23:23:25 -0000
@@ -2977,12 +2977,30 @@ estimate_strategical_value(int pos, int 
 	|| (owl_move_reason_known(pos, aa)
 	    && dragon[aa].status == CRITICAL)
 	|| move_reason_known(pos, SEMEAI_MOVE, aa)) {
+      float excess_value;
+      int our_dragon = (color == worm[aa].color);
+      float dragon_ter_val = 2 * DRAGON2(aa).strategic_size;
+
+      if ((our_dragon && defense_move_known(pos, aa) == WIN)
+	  || (!our_dragon && attack_move_known(pos, aa) == WIN)) {
+	excess_value = dragon_ter_val - move[pos].territorial_value;
+	if (excess_value > 0.0) {
+	  /* We haven't counted all the territorial value, the most probably
+	   * because of ko situations - repair it here.
+	   * FIXME: We should count values of all ko threats to know how
+	   * much we really gain. As for now 0.75 factor is used. */
+	  excess_value *= 0.75;
+	  TRACE("  %1m: %f - territory underestimation bonus for %1m\n", pos,
+		excess_value, aa);
+	  tot_value += excess_value;
+	}
+      }
+
       /* But if the strategical value was larger than the territorial
        * value (e.g. because connecting to strong dragon) we award the
        * excess value as a bonus.
        */
-      float excess_value = (dragon_value[aa] - 
-			    2 * DRAGON2(aa).strategic_size);
+      excess_value = (dragon_value[aa] - dragon_ter_val);
       if (excess_value > 0.0) {
 	TRACE("  %1m: %f - strategic bonus for %1m\n", pos, excess_value, aa);
 	tot_value += excess_value;
