gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] remove special case in matchpat.c


From: Arend Bayer
Subject: [gnugo-devel] remove special case in matchpat.c
Date: Mon, 23 Aug 2004 00:59:13 +0200 (CEST)


- remove special handling of class C patterns in matchpat.c

When used with a goal, matchpat() would ignore all class C patterns unless
_every_ stone in the pattern belongs to the goal. This is undocumented and
unused and is thus removed below. (CVS history doesnt help as it was there
from the first cvs version.)

Arend

Index: engine/matchpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v
retrieving revision 1.64
diff -u -p -r1.64 matchpat.c
--- engine/matchpat.c   24 Jan 2004 04:04:56 -0000      1.64
+++ engine/matchpat.c   22 Aug 2004 22:56:12 -0000
@@ -363,7 +363,7 @@ do_matchpat(int anchor, matchpat_callbac
       int end_transformation;
       int ll;   /* Iterate over transformations (rotations or reflections)  */
       int k;    /* Iterate over elements of pattern */
-      int found_goal, found_nongoal;
+      int found_goal;
   
       /* We can check the color of the anchor stone now.
        * Roughly half the patterns are anchored at each
@@ -467,7 +467,6 @@ do_matchpat(int anchor, matchpat_callbac
 
        /* Now iterate over the elements of the pattern. */
        found_goal = 0;
-       found_nongoal = 0;
        for (k = 0; k < pattern->patlen; ++k) { /* match each point */
          int pos; /* absolute coords of (transformed) pattern element */
          int att = pattern->patn[k].att;  /* what we are looking for */
@@ -483,12 +482,8 @@ do_matchpat(int anchor, matchpat_callbac
          if ((board[pos] & and_mask[color-1][att]) != val_mask[color-1][att])
            goto match_failed;
 
-         if (goal != NULL && board[pos] != EMPTY) {
-           if (goal[pos])
-             found_goal = 1;
-           else if (board[pos] == color)
-             found_nongoal = 1;
-         }
+         if (goal != NULL && board[pos] != EMPTY && goal[pos])
+           found_goal = 1;
          
          /* Check out the class_X, class_O, class_x, class_o
           * attributes - see patterns.db and above.
@@ -501,12 +496,10 @@ do_matchpat(int anchor, matchpat_callbac
 
 
 #if GRID_OPT == 2
-
        /* Make sure the grid optimisation wouldn't have 
            rejected this pattern */
        ASSERT2((merged_val & pattern->and_mask[ll])
                == pattern->val_mask[ll], m, n);
-
 #endif /* we don't trust the grid optimisation */
 
 
@@ -514,14 +507,9 @@ do_matchpat(int anchor, matchpat_callbac
        ++totals[4];
 #endif
 
-
        /* Make it here ==> We have matched all the elements to the board. */
        if ((goal != NULL) && !found_goal)
          goto match_failed;
-       if ((goal != NULL) && ((pattern->class) & CLASS_C) && !found_nongoal)
-         goto match_failed;
-       
-
 
 #ifdef PROFILE_MATCHER
        ++totals[5];
@@ -983,7 +971,6 @@ check_pattern_light(int anchor, matchpat
 {
   int k;                       /* Iterate over elements of pattern */
   int found_goal = 0;
-  int found_nongoal = 0;
   
 #if PROFILE_PATTERNS
   int nodes_before;
@@ -1020,12 +1007,8 @@ check_pattern_light(int anchor, matchpat
 
     if (!anchor_in_goal) { 
       /* goal check */
-      if (goal != NULL && board[pos] != EMPTY) {
-        if (goal[pos])
-         found_goal = 1;
-        else if (board[pos] == color)
-         found_nongoal = 1;
-      }
+      if (goal != NULL && board[pos] != EMPTY && goal[pos])
+       found_goal = 1;
     }
 
     /* class check */
@@ -1039,8 +1022,6 @@ check_pattern_light(int anchor, matchpat
   if (!anchor_in_goal) { 
     if (goal != NULL && !found_goal)
       goto match_failed;
-    if (goal != NULL && (pattern->class & CLASS_C) && !found_nongoal)
-      goto match_failed;
   }
 
 #ifdef PROFILE_MATCHER




reply via email to

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