gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] followup influence-specific constraints in barriers.db


From: Arend Bayer
Subject: [gnugo-devel] followup influence-specific constraints in barriers.db
Date: Fri, 1 Feb 2002 18:12:23 +0100 (CET)

I mentioned that I have to distinguish intrusion patterns in barriers.db
on whether the intrusion can be stopped in sente (if so, the intrusion
should be added for the opponent, but not as a followup of our own move).
This is means I usually need an additional condition for B patterns
when they are found while computing followup_influence.

Now I don't want to duplicate all these patterns. I can get around this
by misusing the action to get an additional condition. As this somewhat
misuses the action field in a way it was not intended to be used, I would
like to get a quick opinion from our maintainers whether they judge
this acceptable before I start adopting all patterns -- I will bet Gunnar
will have an opinion on that :-)

I give the changes in influence.c/patterns.h as a commented patch output
below. They allow to write a pattern like:

>Pattern Intrusion2
>
>xXx?
>...O
>!!..
>----
>
>:8,B,value(30)
>
>
>  xXx?
>  ..ab
>  !!..
>  ----
>
>  >return (!xplay_attack(a,b));

The action part of this autohelper doesn't get called from influence_callback
currently. However, it does get called from followup_influence_callback,
and if (!xplay_attack(a,b)) is true, it returns 1; this
lets followup_influence_callback to disregard this pattern if the
condition is not true.

Note that if we wanted to have an action for this pattern, say only for
not-followup influence, this could easily be achieved by writing the
action as
> if (action == FOLLOWUP_INFLUENCE_CALLBACK) 
>   return (!xplay_attack(a,b));
> do_some_action();

It's not exactly the plainest code possible, but well, autohelper actions
are double callbacks anyway, and "callbacks are evil" (L. Torvalds) :-).

No, I think it is better for maintainance than duplicating all these
patterns and adding an additional flag indicating whether they are
supposed to be used in standard or followup influence.

Arend




Index: patterns/patterns.h
===================================================================
@@ -194,6 +194,12 @@
 #define HAVE_CONSTRAINT 1
 #define HAVE_ACTION     2
 
+/* Values of the action parameter to indicate where an influence autohelper
+ * is called from.
+ */
+#define INFLUENCE_CALLBACK 1
+#define FOLLOWUP_INFLUENCE_CALLBACK 2
+
 
 typedef struct patval {
   int x;


Index: engine/influence.c
===================================================================

(This is in influence_callback:)

@@ -740,7 +743,7 @@
   /* For t patterns, everything happens in the action. */
   if ((pattern->class & CLASS_t)
       && (pattern->autohelper_flag & HAVE_ACTION)) {
-    pattern->autohelper(pattern, ll, POS(ti, tj), color, 1);
+    pattern->autohelper(pattern, ll, POS(ti, tj), color, INFLUENCE_CALLBACK);
   }


And in followup_influence_callback:

+ /* Actions in B patterns are used as followup specific constraints. */
+ if ((pattern->autohelper_flag & HAVE_ACTION)
+     && !pattern->autohelper(pattern, ll, POS(ti, tj), color,
+                             FOLLOWUP_INFLUENCE_CALLBACK))
+    return;
+
   /* First loop: We check whether a saved stone is involved. */
   for (k = 0; k < pattern->patlen; ++k) /* match each point */
     if (pattern->patn[k].att == ATT_O) {





reply via email to

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