[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [gnugo-devel] Proposed owl_determine_life() improvement
From: |
Portela Fernand |
Subject: |
RE: [gnugo-devel] Proposed owl_determine_life() improvement |
Date: |
Thu, 7 Nov 2002 21:25:51 +0100 |
First a note to say that my parallel idea about detecting improved eye
shapes possibilities proved difficult to implement and overall, quite
problematic. So, I'm coming back to Dan's patch.
I started by taking the code out of sniff_lunch() in order to be able to
test it from owl_determine_life() or sniff_lunch(). The difference is
that in the second case, it also influences pattern matching (through
vital_chain()). I finally left it in sniff_lunch() where it seems to be
more efficient. Else, and for a first approach, I circumvented the major
problem, kos, by ignoring them. Maybe I'll retry to work on this later,
but I'm not sure it would be worth the effort.
As a result, this version generates 3-4 PASSes and no FAILs:
strategy4:179 PASS
global:32 already solved by nando_3_12.1a
nngs3:230 passes if taken individually, but does not in the
regression batch because of persistent cache effect (which
means, it would also fail in real game play)
nngs4:30 PASS
Improvements are possible I think, I'll work on it.
/nando
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.116
diff -u -r1.116 owl.c
--- engine/owl.c 5 Nov 2002 16:28:21 -0000 1.116
+++ engine/owl.c 7 Nov 2002 20:28:20 -0000
@@ -185,6 +185,8 @@
static int owl_safe_move(int move, int color);
static void sniff_lunch(int lunch, int *min, int *probable, int *max,
struct local_owl_data *owl);
+static void eat_lunch_escape_bonus(int lunch, int *min, int *probable,
+ int *max, struct local_owl_data *owl);
static void compute_owl_escape_values(struct local_owl_data *owl);
static int owl_escape_route(struct local_owl_data *owl);
static void do_owl_analyze_semeai(int apos, int bpos,
@@ -4670,11 +4672,13 @@
*min = 2;
*probable = 2;
*max = 2;
+ return;
}
else if (size > 4) {
*min = 1;
*probable = 2;
*max = 2;
+ return;
}
else if (size > 2) {
*min = 0;
@@ -4710,9 +4714,68 @@
*max = 0;
}
}
+
+ eat_lunch_escape_bonus(lunch, min, probable, max, owl);
}
+/* Gives a bonus for a lunch capture which joins a (or some) friendly
+ * string(s) to the goal dragon and improves the escape potential at
+ * the same time. This is indicated in some situations where the owl
+ * code would stop the analysis because of various cutoffs. See
+ * do_owl_defend()
+ *
+ * The following implementation tries to get a precise idea of the
+ * escape potential improvement by calling dragon_escape() twice.
+ */
+static void
+eat_lunch_escape_bonus(int lunch, int *min, int *probable, int *max,
+ struct local_owl_data *owl)
+{
+ int adjacent[MAXCHAIN];
+ int neighbors;
+ int adjoins = 0;
+ int n;
+ /* Be very careful before touching this value.
+ * See owl_estimate_life() for details.
+ */
+ UNUSED(min);
+
+ /* Don't mess up with kos */
+ if (is_ko_point(lunch))
+ return;
+
+ neighbors = chainlinks(lunch, adjacent);
+ for (n = 0; n < neighbors; n++)
+ adjoins |= !owl->goal[adjacent[n]];
+
+ if (adjoins) {
+ int before, after;
+ before = dragon_escape(owl->goal, owl->color, owl->escape_values);
+ /* if the escape route is already large enough to be considered
+ * a WIN by the owl code, then no need for more */
+ if (before < 5) {
+ char new_goal[BOARDMAX];
+ memcpy(new_goal, owl->goal, sizeof(new_goal));
+ for (n = 0; n < neighbors; n++)
+ if (!owl->goal[adjacent[n]])
+ mark_string(adjacent[n], new_goal, 2);
+ after = dragon_escape(new_goal, owl->color, owl->escape_values);
+
+ /* Following is completely ad hoc. Another set of tests might
+ * very well get better results. */
+ if (after - before >= 3)
+ if (after >= 8 || (before == 0 && after >= 5)) {
+ *probable = 2;
+ *max = 2;
+ }
+ else if (*max < 2)
+ (*max)++;
+ }
+ }
+}
+
+
/* Conservative relative of topological_eye. Essentially the same
* algorithm is used, but only tactically safe opponent strings on
* diagonals are considered. This may underestimate the false/half eye