Index: configure.in
===================================================================
RCS file: /cvsroot/gnugo/gnugo/configure.in,v
retrieving revision 1.122
diff -u -r1.122 configure.in
--- configure.in	21 Sep 2005 22:06:50 -0000	1.122
+++ configure.in	23 Sep 2005 22:26:56 -0000
@@ -100,10 +100,6 @@
  [  --enable-experimental-owl-ext      use the experimental GAIN/LOSS codes
   --disable-experimental-owl-ext     use standard owl module (default)])
 
-AC_ARG_ENABLE(experimental-reading,
- [  --enable-experimental-reading      use experimental pattern-based reading
-  --disable-experimental-reading     use standard reading (default)])
-
 AC_ARG_ENABLE(cosmic-gnugo,
  [  --enable-cosmic-gnugo              use center-oriented influence code
   --disable-cosmic-gnugo             use standard influence code (default)])
@@ -467,17 +463,6 @@
    AC_DEFINE(EXPERIMENTAL_OWL_EXT, 1)
 else
    AC_DEFINE(EXPERIMENTAL_OWL_EXT, 0)
-fi
-
-dnl ------------ Reading -------------------
-
-AH_TEMPLATE([EXPERIMENTAL_READING],
-[Experimental pattern based reading. Disabled by default.])
-
-if test "$enable_experimental_reading" = "yes" ; then
-   AC_DEFINE(EXPERIMENTAL_READING, 1)
-else
-   AC_DEFINE(EXPERIMENTAL_READING, 0)
 fi
 
 dnl ------------ Cosmic Consciousness -------------------
Index: engine/gnugo.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v
retrieving revision 1.119
diff -u -r1.119 gnugo.h
--- engine/gnugo.h	12 Jun 2005 09:34:14 -0000	1.119
+++ engine/gnugo.h	23 Sep 2005 22:26:56 -0000
@@ -238,11 +238,6 @@
 extern int mirror_stones_limit;      /* but stop at this number of stones */
 extern int gtp_version;              /* version of Go Text Protocol */
 
-#if EXPERIMENTAL_READING
-extern int defend_by_pattern;  /* use patterns for tactical reading defense */
-extern int attack_by_pattern;  /* use patterns for tactical reading attack */
-#endif
-
 /* Mandatory values of reading parameters. Normally -1, if set at 
  * these override the values derived from the level. */
 extern int mandated_depth;
Index: engine/interface.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
retrieving revision 1.54
diff -u -r1.54 interface.c
--- engine/interface.c	14 Sep 2005 18:33:20 -0000	1.54
+++ engine/interface.c	23 Sep 2005 22:26:57 -0000
@@ -51,9 +51,6 @@
 
   transformation_init();
   dfa_match_init();
-#if EXPERIMENTAL_READING
-  tree_match_init();
-#endif
 
   clear_approxlib_cache();
   clear_accuratelib_cache();
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.238
diff -u -r1.238 liberty.h
--- engine/liberty.h	12 Jun 2005 09:34:14 -0000	1.238
+++ engine/liberty.h	23 Sep 2005 22:26:57 -0000
@@ -175,8 +175,6 @@
 struct corner_db;
 struct half_eye_data;
 struct movelist;
-struct tree_node_list;
-struct match_node;
 
 /*
  * Try to match a pattern in the database to the board. Callbacks for
@@ -203,11 +201,6 @@
 void corner_matchpat(corner_matchpat_callback_fn_ptr callback, int color,
 		     struct corner_db *database);
 void dfa_match_init(void);
-void tree_match_init(void);
-void tree_initialize_pointers(struct tree_node_list *tnl,
-                              struct match_node *matches,
-                              int tnl_size,
-                              int matches_size);
 
 void reading_cache_init(int bytes);
 void reading_cache_clear(void);
Index: engine/matchpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v
retrieving revision 1.70
diff -u -r1.70 matchpat.c
--- engine/matchpat.c	14 Sep 2005 18:33:20 -0000	1.70
+++ engine/matchpat.c	23 Sep 2005 22:26:57 -0000
@@ -520,195 +520,6 @@
   }
 }
 
-#if EXPERIMENTAL_READING
-
-/**************************************************************************/
-/* Tree matcher:                                                           */
-/**************************************************************************/
-static void tree_prepare_for_match(int color);
-static void tree_matchpat_loop(matchpat_callback_fn_ptr callback, 
-			       int color, int anchor,
-			       struct pattern_db *pdb, void *callback_data,
-			       char goal[BOARDMAX], int anchor_in_goal);
-static void tree_do_matchpat(int m, int n, matchpat_callback_fn_ptr callback,
-			     int color, struct pattern_db *database,
-			     void *callback_data, char goal[BOARDMAX],
-                             int anchor_in_goal);
-
-
-void
-tree_match_init(void)
-{
-  init_tree_read_attack();
-  init_tree_read_defend();
-  init_tree_owl_attackpat();
-  init_tree_owl_defendpat();
-  init_tree_owl_vital_apat();
-}
-
-
-static void 
-tree_prepare_for_match(int color)
-{
-  UNUSED(color);
-  /* Nothing to prepare! */
-}
-
-static void 
-tree_matchpat_loop(matchpat_callback_fn_ptr callback, 
-		   int color, int anchor,
-		   struct pattern_db *pdb, void *callback_data,
-		   char goal[BOARDMAX], int anchor_in_goal)
-{
-  int i, j;
-
-  for (i = 0; i != board_size; i++)
-    for (j = 0; j != board_size; j++)
-      if (BOARD(i, j) == anchor
-          && (!anchor_in_goal || goal[POS(i, j)] != 0))
-	tree_do_matchpat(i, j, callback, color, 
-			 pdb, callback_data, goal, anchor_in_goal);
-
-}
-
-/* Possibly cheaper to pass a little less recursively.
- * Note: This could even just be static data, unless the
- * tree pattern matcher is itself used recursively.*/
-struct rec_data {
-  matchpat_callback_fn_ptr callback;
-  struct pattern_db *database;
-  void *callback_data;
-};
-
-
-/* Recursively walks the tree data structure, calling the callback
- * for all patterns matched at location (m,n).
- */
-static void 
-do_tree_matchpat_rec(int color, int m, int n, int goal_found,
-                     char goal[BOARDMAX], 
-                     struct tree_node_list *tnl, 
-                     struct rec_data *pdata)
-{
-  if (0 && !tnl)
-    return;
-
-  tnl = tnl->next;
-  while (tnl) {
-    struct tree_node *node = &(tnl->node);
-    int x = m + node->x;
-    int y = n + node->y;
-    if (ON_BOARD2(x, y)) {
-      int att = node->att;
-      int point_color = BOARD(x, y);
-      if ((att == EMPTY && point_color == EMPTY)
-          || (att == ATT_X && point_color == OTHER_COLOR(color))
-          || (att == ATT_O && point_color == color)) {
-        goal_found = goal_found || goal[POS(x, y)];
-        if (node->matches) {
-          struct match_node *match = node->matches->next;
-          while (match) {
-            struct pattern *pattern =
-	      &(pdata->database->patterns[match->patnum]);
-            int ll = match->orientation;
-	    int mi, mj, xi, xj;
-	    TRANSFORM2(pattern->mini, pattern->minj, &mi, &mj, ll);
-	    TRANSFORM2(pattern->maxi, pattern->maxj, &xi, &xj, ll);
-	    /* now do the range-check */
-            if (!goal_found
-                || !ON_BOARD2(m+mi, n+mj) 
-                || !ON_BOARD2(m+xi, n+xj)) {
-	      ;/* goal not found, or out of range */
-            }
-	    else {
-              if (0) {
-                gprintf("  P[%s, %d] matches at %m)\n",
-			pattern->name, match->orientation, x, y);
-              }
-              /* A match! */
-              pdata->callback(POS(m, n), color, pattern, ll,
-			      pdata->callback_data);
-            }
-
-            match = match->next;
-          }
-        }
-        if (node->next_list && node->next_list->next) {
-          do_tree_matchpat_rec(color, m, n, goal_found, goal,
-			       node->next_list, pdata);
-        }
-      }
-    }
-    tnl = tnl->next;
-  }
-}
-
-/* Stub for matchpat function.  Work done in recursive helper. */
-static void 
-tree_do_matchpat(int m, int n, matchpat_callback_fn_ptr callback,
-		 int color, struct pattern_db *database,
-		 void *callback_data, char goal[BOARDMAX],
-		 int anchor_in_goal)
-{
-  struct tree_node_list *tree = database->tnl;
-  struct rec_data data;
-
-  if (0) {
-    if (0)
-      showboard(0);
-    gprintf("Trying to match at %m\n", m, n);
-  }
-  data.callback = callback;
-  data.callback_data = callback_data;
-  data.database = database;
-
-  /* note: If anchor_in_goal is 0, then the goal_found parameter is
-   *   always trivially true.  This will short-circuit some array
-   *   lookups in the recursive version.
-   */
-  do_tree_matchpat_rec(color, m, n, !anchor_in_goal, goal, tree, &data);
-}
-
-/**************************************************************************/
-/* Tree initialization helper                                             */
-/**************************************************************************/
-
-/* The tree data structure is output with raw integer offsets
- * relative to a single array of tree_node_list and match_node
- * elements.  These offsets need to be added to the actual base
- * address of the list of elements for the pointers to be
- * meaningful.
- *
- * FIXME: This code is not portable. On certain platforms the size of
- *        a pointer and the size of an int differ.
- */
-void 
-tree_initialize_pointers(struct tree_node_list *tnl,
-                         struct match_node *matches,
-                         int tnl_size,
-                         int matches_size)
-{
-  struct tree_node_list *tnl_walk = tnl;
-  struct match_node *matches_walk = matches;
-
-  do {
-    if (tnl_walk->next)
-      tnl_walk->next = tnl + (int)(tnl_walk->next);
-    if (tnl_walk->node.matches)
-      tnl_walk->node.matches = matches + (int)(tnl_walk->node.matches);
-    if (tnl_walk->node.next_list)
-      tnl_walk->node.next_list = tnl + (int)(tnl_walk->node.next_list);
-  } while (++tnl_walk < tnl + tnl_size);
-
-
-  do {
-    if (matches_walk->next)
-      matches_walk->next = matches + (int)(matches_walk->next);
-  } while (++matches_walk < matches + matches_size);  
-}
-
-#endif
-
 
 /**************************************************************************/
 /* DFA matcher:                                                           */
@@ -1066,13 +877,6 @@
     loop = dfa_matchpat_loop;
     prepare = dfa_prepare_for_match;
   }
-
-#if EXPERIMENTAL_READING
-  if (pdb->tnl) {
-    loop = tree_matchpat_loop;
-    prepare = tree_prepare_for_match;
-  }
-#endif
 
   /* select strategy */
   switch (color) {
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.160
diff -u -r1.160 reading.c
--- engine/reading.c	9 Sep 2005 21:56:01 -0000	1.160
+++ engine/reading.c	23 Sep 2005 22:26:59 -0000
@@ -29,7 +29,6 @@
 
 #include "liberty.h"
 #include "cache.h"
-#include "patterns.h"
 #include "gg_utils.h"
 
 /* If nonzero, attack() and find_defense() write all results to
@@ -51,18 +50,6 @@
 #define DUMP_ALL_RESULTS	0
 
 
-#if EXPERIMENTAL_READING
-
-/* When to use pattern-base reading */
-int defend_by_pattern = 0;
-int attack_by_pattern = 1;
-
-static int do_tactical_pat(int is_attack, int str, int *move);
-static int do_defend_pat(int str, int *move);
-static int do_attack_pat(int str, int *move);
-
-#endif
-
 /* Size of array where candidate moves are stored. */
 #define MAX_MOVES 50
 
@@ -1207,14 +1194,6 @@
     return retval;
   }
 
-#if EXPERIMENTAL_READING
-  if (defend_by_pattern) {
-    dcode = do_defend_pat(str, &xpos);
-    /* We set liberties to 0 to pass over the non-pattern code below. */
-    liberties = 0;
-  }
-#endif
-
   if (liberties == 1)
     dcode = defend1(str, &xpos);
   else if (liberties == 2)
@@ -2798,417 +2777,6 @@
 /*                       Attacking functions                        */
 /* ================================================================ */
 
-/* FIXME: These two globals should be wrapped up in accessors, at least. */
-char *rgoal;
-int goallib;
-
-#if EXPERIMENTAL_READING
-#define MAX_READING_MOVES 99
-struct reading_move_data {
-  int pos;          /* move coordinate */
-  int value;        /* value */
-  const char *name; /* name of the pattern suggesting the move */
-};
-
-
-/* reading_callback helper
- * returns 1 if the move need not be tried, because there's
- * already a move in the collected list with a higher value.
- */
-static int
-r_scan_moves(int move, int value, struct reading_move_data *moves) 
-{
-  int k;
-  for (k = 0; k < MAX_READING_MOVES; k++) {
-    if (moves[k].pos == NO_MOVE)
-      break;
-    
-    if (moves[k].pos == move) {
-      if (value <= moves[k].value)
-	return 1;
-      else
-	break;
-    }
-  }
-  
-  return 0;
-}
-
-/* reading_callback helper.
- * pushes moves onto the move list. */
-static void
-r_push_move(int move, int value, const char *name, 
-            struct reading_move_data *moves)
-{
-  int k;
-  for (k = 0; k < MAX_READING_MOVES; k++) {
-    if (!moves[k].pos) {
-      moves[k].pos = move;
-      moves[k].value = value;
-      moves[k].name = name;
-      moves[++k].pos = 0;
-      break;
-    }
-    
-    if (moves[k].value < value) {
-      int j = k;
-      while (moves[j].pos != NO_MOVE && moves[j].pos != move) 
-	j++;
-      
-      if (moves[j].pos != NO_MOVE)
-	j--;
-      
-      for (; j >= k; j--) {
-	moves[j+1].pos = moves[j].pos;
-	moves[j+1].value = moves[j].value;
-	moves[j+1].name = moves[j].name;
-      }
-      
-      moves[k].pos = move;
-      moves[k].value = value;
-      moves[k].name = name;
-      break;
-    }
-  }
-}
-
-/* Callback function for pattern-based tactical reading */
-static void
-reading_callback(int anchor, int color,
-                 struct pattern *pattern, int ll, void *data)
-{
-  int k;
-  int move;
-  int value = pattern->value;
-  struct reading_move_data *moves = data;
-  struct pattern_attribute *attribute;
-  UNUSED(data);
-  UNUSED(k);
-
-  move = AFFINE_TRANSFORM(pattern->move_offset, ll, anchor);
-
-  if (0)
-    gprintf("  Pattern %s called back at %1m (variation %d) orientation %d.\n", 
-            pattern->name, move, count_variations, ll);
-
-  for (attribute = pattern->attributes; attribute->type != LAST_ATTRIBUTE;
-       attribute++) {
-    if (attribute->type == MAX_VALUE && attribute->value > value) {
-      value = attribute->value;
-      break;
-    }
-  }
-
-  
-  if (r_scan_moves(move, value, moves))
-    return;
-
-  if (0 && !strcmp("none3", pattern->name))
-    gprintf("Pattern %s contraint to be checked at %1m (variation %d) orientation %d.\n", 
-            pattern->name, move, count_variations, ll);
-
-  /* If the pattern has a constraint, call the autohelper to see
-   * if the pattern must be rejected.
-   */
-  if (pattern->autohelper_flag & HAVE_CONSTRAINT)
-    if (!pattern->autohelper(ll, move, color, 0))
-      return;
-
-  /* If the pattern has a helper, call it.  The helper change the
-   * pattern-> value.
-   */
-  if (pattern->autohelper_flag & HAVE_ACTION)
-    pattern->autohelper(ll, move, color, 1);
-
-  /* Note: The reading code allows helper to change pattern->value */
-  value = pattern->value;
-  if (value <= 0)
-    return;
-
-  if (0)
-    gprintf("  Pattern %s MATCHED  at %1m (variation %d) orientation %d.\n", 
-            pattern->name, move, count_variations, ll);
-
-  if (r_scan_moves(move, value, moves))
-    return;
-
-  r_push_move(move, value, pattern->name, moves);
-
-}
-
-
-static void
-set_goal_worm(int str, int value, char goal[BOARDMAX])
-{
-  int k;
-  int color = board[str];
-  if (goal[str])
-    return;
-  
-  goal[str] = value;
-  for (k = 0; k < 4; k++) {
-    int pos = str + delta[k];
-    if (board[pos] == color)
-      set_goal_worm(pos, value, goal);
-  }
-}
-
-static void
-set_larger_goal_worm(int str, char goal[BOARDMAX])
-{
-  int k;
-  int color = board[str];
-  /*Note: over-ride possible 3 values here.*/
-  if (goal[str] == 1)
-    return;
-  
-  goal[str] = 1;
-  for (k = 0; k < 4; k++) {
-    int pos = str + delta[k];
-    if (board[pos] == color) {
-      set_larger_goal_worm(pos, goal);
-    }
-    else if (board[pos] == OTHER_COLOR(color) 
-	     && (stackp < (depth+4) || countlib(pos) <= 2)) {
-      set_goal_worm(pos, 2, goal);
-    }
-    else if (stackp < (12+2) && board[pos] == EMPTY) {
-      int j;
-      for (j = 0; j < 4; j++) {
-	int jpos = pos + delta[j];
-	if (board[jpos] == color) {
-	  set_goal_worm(jpos, 3, goal);
-        }
-	else if (board[jpos] == OTHER_COLOR(color)) {
-          /* Added for defense - not needed for attack (?) */
-	  set_goal_worm(jpos, 2, goal);
-        }
-      }
-    }
-  }
-}
-
-static int
-do_attack_pat(int str, int *move)
-{
-  return do_tactical_pat(1, str, move);
-}
-
-static int
-do_defend_pat(int str, int *move)
-{
-  return do_tactical_pat(0, str, move);
-}
-
-
-static int
-do_tactical_pat(int is_attack, int str, int *move)
-{
-  char goal[BOARDMAX];
-  struct reading_move_data moves[MAX_READING_MOVES];
-  int k;
-  int color = board[str];
-  int next_color = is_attack ? OTHER_COLOR(color) : color;
-  int best_other_tactic = WIN;
-  int best_move = 0;
-  int ko_move = 0;
-  int libs;
-  int skipped = 0;
-  const char *trace_str = is_attack ? "attack_pat" : "defend_pat";
-
-
-  SETUP_TRACE_INFO(trace_str, str);
-
-  ASSERT1(move != NULL, str);
-
-  if (reading_node_counter - nodes_when_called > 15000) {
-    SGFTRACE(0, 0, "Way too many variations");
-    return 0;
-  }
-
-  libs = countlib(str);
-
-  if (stackp > depth && libs > 2) {
-    SGFTRACE(0, 0, "Too deep");
-    return 0;
-  }
-
-  if (libs == 1) {
-    if (is_attack)
-      return attack1(str, move);
-    else
-      return defend1(str, move);
-  }
-
-  if (libs == 4) {
-    if (is_attack)
-      return attack4(str, move);
-    else
-      return defend4(str, move);
-  }
-
-  memset(goal, 0, BOARDMAX);
-
-  reading_node_counter++;
-  set_larger_goal_worm(str, goal);
-  moves[0].pos = 0;
-  if (verbose > 1) {
-    TRACE("Stack: "); 
-    dump_stack();
-  }
-  rgoal = goal;
-  goallib = libs;
-  if (is_attack)
-    matchpat_goal_anchor(reading_callback, OTHER_COLOR(color),
-			 &read_attack_db, moves, goal, 1);
-  else
-    matchpat_goal_anchor(reading_callback, OTHER_COLOR(color),
-			 &read_defend_db, moves, goal, 1);
-
-  if (verbose > 1) {
-    TRACE("Moves (variation %d): ", count_variations);
-    for (k = 0; k < MAX_READING_MOVES; k++) {
-      if (!moves[k].pos)
-	break;
-      TRACE("%o%s@%1m ", moves[k].name, moves[k].pos);
-    }
-    TRACE("\n");
-  }
-
-  if (sgf_dumptree) {
-    char buf[500];
-    char *pos;
-    int chars;
-    gg_snprintf(buf, 500, "Move order for %s: %n",
-		read_function_name, &chars);
-    
-    pos = buf + chars;
-    for (k = 0; k < MAX_READING_MOVES; k++) {
-      if (moves[k].pos == NO_MOVE)
-	break;
-      sprintf(pos, "%s (%s-%d) %n", location_to_string(moves[k].pos),
-              moves[k].name, moves[k].value, &chars);
-      pos += chars;
-    }
-    sgftreeAddComment(sgf_dumptree, buf);
-  }
-
-  for (k = 0; MAX_READING_MOVES; k++) {
-    char namebuf[128];
-    if (moves[k].pos == NO_MOVE)
-      break;
-
-    gg_snprintf(namebuf, 128, "%s(%d)", moves[k].name, moves[k].value);
-    if (k > 3 + skipped && k > 12 - stackp + skipped) {
-      if (sgf_dumptree) {
-        if (trymove(moves[k].pos, next_color, namebuf, str)) {
-          sgftreeAddComment(sgf_dumptree, "move trimmed to reduce variations");
-          popgo();
-        }
-      }
-      continue;
-    }
-
-    if (komaster_trymove(moves[k].pos, next_color, namebuf, str, &ko_move, 
-			 stackp <= ko_depth && best_other_tactic == WIN)) {
-      int other_tactic;
-      ASSERT1(countlib(str) >= 1, str);
-      if (sgf_dumptree) {
-        char buf[500];
-        sprintf(buf, "tactical_pat komaster: %d %d  ko_move: %d", 
-		get_komaster(), get_kom_pos(), ko_move);
-        sgftreeAddComment(sgf_dumptree, buf);
-      }
-      
-      if (stackp > 100) {
-        popgo();
-	if (0)
-	  gprintf("komaster: %d %1m  ko_move: %d\n", 
-		  get_komaster(), get_kom_pos(), ko_move);
-        continue;  /* Short circuit */
-      }
-      
-      if (is_attack)
-        other_tactic = do_find_defense(str, 0);
-      else
-        other_tactic = do_attack(str, 0);
-
-      if (is_attack && other_tactic != WIN) {
-        int same_tactic;
-        /* HINT: add 1 || here to generate stack errors in reading:60 
-         *    (not positive of problem number) */
-        if (stackp < depth + 6 || countlib(str) <= 2) {
-          if (is_attack)
-     	    same_tactic = do_attack(str, 0);
-	  else
-     	    same_tactic = do_find_defense(str, 0);
-
-	  if (!ko_move && other_tactic == 0 && same_tactic != 0) {
-	    *move = moves[k].pos;
-	    popgo();
-	    SGFTRACE(moves[k].pos, WIN,
-		     "tactic successful - no defense, ko sub-attack");
-	    return WIN;
-	  }
-        }
-	else {
-          same_tactic = 0;
-          SGFTRACE(moves[k].pos, 0, "Too deep, aborting attack");
-        }
-	/* This defense assignment may be incorrect. */
-	other_tactic = gg_max(other_tactic, REVERSE_RESULT(same_tactic));
-      }
-      if (!other_tactic) {
-	if (ko_move) {
-	  TRACE("Ko move good: %1m\n", moves[k].pos);
-	  other_tactic = KO_A;
-	  if (other_tactic < best_other_tactic) {
-	    best_move = moves[k].pos;
-	    best_other_tactic = other_tactic;
-	  }
-	}
-	else {
-	  popgo();
-          /* FIXME: add explicit attack/defense verbage here */
-	  SGFTRACE(moves[k].pos, WIN, "tactic successful - no counter.");
-	  *move = moves[k].pos;
-	  return WIN;
-	}
-      }
-      else if (other_tactic < best_other_tactic) {
-	/* May need to check ko_move in this case, too */
-	best_move = moves[k].pos;
-	best_other_tactic = other_tactic;
-      }
-      popgo();
-    }
-    else {
-      /* FIXME: Add this back to allow up to 3 legal moves when deep. */
-      /* Current implementation counts illegal moves. */
-      if (0)
-	skipped++;
-    }
-  }
-
-  if (!is_attack) {
-    /* Force attacker to capture - i.e. might be seki. */
-    int attack;
-    attack = do_attack(str, 0);
-    if (attack < best_other_tactic) {
-      best_move = PASS_MOVE;
-      best_other_tactic = attack;
-    }
-  }
-
-
-  /* FIXME: Add explicit attack/defense verbage here. */
-  SGFTRACE(best_move, REVERSE_RESULT(best_other_tactic), "No good tactic.");
-  *move = best_move;
-  return REVERSE_RESULT(best_other_tactic);
-}
-
-#endif /*EXPERIMENTAL_READING*/
-
 
 /* Like attack. If the opponent is komaster reading functions will not try
  * to take ko.
@@ -3266,14 +2834,6 @@
       *move = xpos;
     return retval;
   }
-
-#if EXPERIMENTAL_READING
-  if (attack_by_pattern) {
-    result = do_attack_pat(str, &xpos);
-    /* Set liberties to 0 to pass over the non-pattern code below. */
-    liberties = 0;
-  }
-#endif
 
   /* Treat the attack differently depending on how many liberties the 
      string at (str) has. */
Index: interface/main.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/main.c,v
retrieving revision 1.114
diff -u -r1.114 main.c
--- interface/main.c	12 Jun 2005 09:34:14 -0000	1.114
+++ interface/main.c	23 Sep 2005 22:27:00 -0000
@@ -148,8 +148,6 @@
       OPT_ALLOW_SUICIDE,
       OPT_CAPTURE_ALL_DEAD,
       OPT_PLAY_OUT_AFTERMATH,
-      OPT_ATTACK_BY_PATTERN,
-      OPT_DEFEND_BY_PATTERN,
       OPT_MIRROR,
       OPT_MIRROR_LIMIT,
       OPT_METAMACHINE,
@@ -292,8 +290,6 @@
   {"score",          required_argument, 0, OPT_SCORE},
   {"printsgf",       required_argument, 0, OPT_PRINTSGF},
   {"profile-patterns", no_argument,     0, OPT_PROFILE_PATTERNS},
-  {"attack-by-pattern", no_argument,    0, OPT_ATTACK_BY_PATTERN},
-  {"defend-by-pattern", no_argument,    0, OPT_DEFEND_BY_PATTERN},
   {"mirror",         no_argument,       0, OPT_MIRROR},
   {"mirror-limit",   required_argument, 0, OPT_MIRROR_LIMIT},
   {"metamachine",    no_argument,       0, OPT_METAMACHINE},
@@ -508,9 +504,6 @@
 	if (EXPERIMENTAL_OWL_EXT)
 	  fprintf(stdout,
 		  "configure option enabled: experimental GAIN/LOSS codes\n");
-	if (EXPERIMENTAL_READING)
-	  fprintf(stdout,
-		  "configure option enabled: experimental reading\n");
 	if (OWL_THREATS)
 	  fprintf(stdout,
 		  "configure option enabled: owl threats\n");
@@ -938,18 +931,6 @@
 	return EXIT_SUCCESS;
 	break;
 	
-#if EXPERIMENTAL_READING
-
-      case OPT_ATTACK_BY_PATTERN:
-        attack_by_pattern = 1;
-        break;
-
-      case OPT_DEFEND_BY_PATTERN:
-        defend_by_pattern = 1;
-        break;
-
-#endif
-
       case OPT_MIRROR:
         play_mirror_go = 1;
         break;
@@ -1614,9 +1595,6 @@
    --decide-eye <string>        evaluate the eye\n\
    --decide-combination         search for combination attack (try with -o)\n\
    --genmove <color>            generate a move for color\n\
-Other options:\n\
-   --attack-by-pattern          use pattern-based tactical reading for attack\n\
-   --defend-by-pattern          use pattern-based tactical reading for defense\n\
 "
 
 #define DEBUG_FLAGS "\
Index: patterns/Makefile.am
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.am,v
retrieving revision 1.36
diff -u -r1.36 Makefile.am
--- patterns/Makefile.am	18 Sep 2005 12:04:36 -0000	1.36
+++ patterns/Makefile.am	23 Sep 2005 22:27:00 -0000
@@ -34,8 +34,6 @@
 	fuseki13.dbz\
 	fuseki19.dbz\
 	handicap.db\
-	read_attack.db\
-	read_defend.db\
 	oracle.db
 
 mkpat_SOURCES  = mkpat.c transform.c dfa.c
@@ -73,7 +71,7 @@
                  owl_attackpat.c\
 		 owl_vital_apat.c owl_defendpat.c fusekipat.c\
                  fuseki9.c fuseki13.c fuseki19.c josekidb.c\
-		 read_attack.c read_defend.c handipat.c oraclepat.c
+		 handipat.c oraclepat.c
 
 DBBUILT = gogo.db hoshi_keima.db hoshi_other.db komoku.db sansan.db \
 	  mokuhazushi.db takamoku.db
@@ -85,7 +83,7 @@
 	    endgame.db eyes.db fuseki.db fuseki9.dbz fuseki13.dbz fuseki19.dbz\
 	    handicap.db influence.db oracle.db owl_attackpats.db\
 	    owl_defendpats.db owl_vital_apats.db patterns.db patterns2.db\
-	    read_attack.db read_defend.db $(DBBUILT)
+	    $(DBBUILT)
 
 # Remove these files here... they are created locally
 DISTCLEANFILES = $(GGBUILTSOURCES) $(DBBUILT) *~
@@ -186,12 +184,6 @@
 
 handipat.c : $(srcdir)/handicap.db mkpat$(EXEEXT)
 	./mkpat -b handipat -i $(srcdir)/handicap.db -o handipat.c
-
-read_attack.c : $(srcdir)/read_attack.db mkpat$(EXEEXT)
-	./mkpat -b read_attack -i $(srcdir)/read_attack.db -o read_attack.c
-
-read_defend.c : $(srcdir)/read_defend.db mkpat$(EXEEXT)
-	./mkpat -b read_defend -i $(srcdir)/read_defend.db -o read_defend.c
 
 
 ETAGS_ARGS = --language none --regex '/^Pattern[ \t]+[a-zA-Z0-9]+/' $(DB_TO_TAG)\
Index: patterns/Makefile.in
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.in,v
retrieving revision 1.55
diff -u -r1.55 Makefile.in
--- patterns/Makefile.in	18 Sep 2005 12:04:36 -0000	1.55
+++ patterns/Makefile.in	23 Sep 2005 22:27:00 -0000
@@ -112,8 +112,6 @@
 	fuseki13.dbz\
 	fuseki19.dbz\
 	handicap.db\
-	read_attack.db\
-	read_defend.db\
 	oracle.db
 
 
@@ -150,7 +148,7 @@
                  owl_attackpat.c\
 		 owl_vital_apat.c owl_defendpat.c fusekipat.c\
                  fuseki9.c fuseki13.c fuseki19.c josekidb.c\
-		 read_attack.c read_defend.c handipat.c oraclepat.c
+		 handipat.c oraclepat.c
 
 
 DBBUILT = gogo.db hoshi_keima.db hoshi_other.db komoku.db sansan.db \
@@ -165,7 +163,7 @@
 	    endgame.db eyes.db fuseki.db fuseki9.dbz fuseki13.dbz fuseki19.dbz\
 	    handicap.db influence.db oracle.db owl_attackpats.db\
 	    owl_defendpats.db owl_vital_apats.db patterns.db patterns2.db\
-	    read_attack.db read_defend.db $(DBBUILT)
+	    $(DBBUILT)
 
 
 # Remove these files here... they are created locally
@@ -202,8 +200,8 @@
 	aa_attackpat.$(OBJEXT) owl_attackpat.$(OBJEXT) \
 	owl_vital_apat.$(OBJEXT) owl_defendpat.$(OBJEXT) \
 	fusekipat.$(OBJEXT) fuseki9.$(OBJEXT) fuseki13.$(OBJEXT) \
-	fuseki19.$(OBJEXT) josekidb.$(OBJEXT) read_attack.$(OBJEXT) \
-	read_defend.$(OBJEXT) handipat.$(OBJEXT) oraclepat.$(OBJEXT)
+	fuseki19.$(OBJEXT) josekidb.$(OBJEXT) \
+	handipat.$(OBJEXT) oraclepat.$(OBJEXT)
 libpatterns_a_OBJECTS = $(am_libpatterns_a_OBJECTS)
 EXTRA_PROGRAMS = extract_fuseki$(EXEEXT) transpat$(EXEEXT) \
 	compress_fuseki$(EXEEXT)
@@ -267,8 +265,8 @@
 @AMDEP_TRUE@	$(DEPDIR)/oraclepat.Po $(DEPDIR)/owl_attackpat.Po \
 @AMDEP_TRUE@	$(DEPDIR)/owl_defendpat.Po \
 @AMDEP_TRUE@	$(DEPDIR)/owl_vital_apat.Po $(DEPDIR)/patlib.Po \
-@AMDEP_TRUE@	$(DEPDIR)/patterns.Po $(DEPDIR)/read_attack.Po \
-@AMDEP_TRUE@	$(DEPDIR)/read_defend.Po $(DEPDIR)/transform.Po \
+@AMDEP_TRUE@	$(DEPDIR)/patterns.Po \
+@AMDEP_TRUE@	$(DEPDIR)/transform.Po \
 @AMDEP_TRUE@	$(DEPDIR)/transpat.Po \
 @AMDEP_TRUE@	$(DEPDIR)/uncompress_fuseki.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -364,8 +362,6 @@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/owl_vital_apat.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/patlib.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/patterns.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/read_attack.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/read_defend.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/transform.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/transpat.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/uncompress_fuseki.Po@am__quote@
@@ -608,12 +604,6 @@
 
 handipat.c : $(srcdir)/handicap.db mkpat$(EXEEXT)
 	./mkpat -b handipat -i $(srcdir)/handicap.db -o handipat.c
-
-read_attack.c : $(srcdir)/read_attack.db mkpat$(EXEEXT)
-	./mkpat -b read_attack -i $(srcdir)/read_attack.db -o read_attack.c
-
-read_defend.c : $(srcdir)/read_defend.db mkpat$(EXEEXT)
-	./mkpat -b read_defend -i $(srcdir)/read_defend.db -o read_defend.c
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
Index: patterns/mkpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v
retrieving revision 1.149
diff -u -r1.149 mkpat.c
--- patterns/mkpat.c	18 Sep 2005 12:56:49 -0000	1.149
+++ patterns/mkpat.c	23 Sep 2005 22:27:02 -0000
@@ -57,7 +57,6 @@
 	-f = compile a fullboard pattern database\n\
 	-C = compile a corner pattern database\n\
 	-D = compile a DFA database (allows fast matching)\n\
-	-T = compile a tree based pattern database (even faster)\n\
 	-d <iterations> = don't generate database, but optimize a DFA\n\
 			  transformation file instead\n\
   Pattern generation options:\n\
@@ -96,7 +95,6 @@
 #define DB_FULLBOARD	((int) 'f')
 #define DB_CORNER	((int) 'C')
 #define DB_DFA		((int) 'D')
-#define DB_TREE 	((int) 'T')
 #define OPTIMIZE_DFA	((int) 'd')
 
 /* code assumes that ATT_O and ATT_X are 1 and 2 (in either order)
@@ -1769,35 +1767,6 @@
     - order[((const struct patval_b *)b)->att];
 }
 
-#if EXPERIMENTAL_READING
-
-/* For the tree-based algorithm, it works best to sort the elements
- * by distance from the anchor, making the search tree smaller.
- * Similarly, it's best to match the most common elements first.
- * Note: This will therefore not work for the connections database
- */
-
-static int
-compare_elements_closest(const void *a, const void *b)
-{
-  const struct patval_b *pa = (const struct patval_b *)a;
-  const struct patval_b *pb = (const struct patval_b *)b;
-
-  int ax = pa->x - ci;
-  int bx = pb->x - ci;
-  int ay = pa->y - cj;
-  int by = pb->y - cj;
-  int metric = (ax*ax + ay*ay) - (bx*bx + by*by);
-  if (metric == 0)
-    return -compare_elements(a, b);
-  else
-    return metric;
-}
-
-static void tree_push_pattern(void);
-
-#endif
-
 struct element_node {
   struct patval_b e;
   struct element_node *next;
@@ -1864,8 +1833,6 @@
       /* DFA pattern matcher doesn't itself need these elements at all. But
        * they might be needed for goal checking or by callback function, so
        * we check it before discarding an element.
-       *
-       * FIXME: What about tree matcher?
        */
       if (database_type == DB_DFA)
 	continue;
@@ -1889,468 +1856,10 @@
     fprintf(outfile, "\n};\n\n");
 
   pattern[patno].patlen = used_nodes;
-
-#if EXPERIMENTAL_READING
-  if (database_type == DB_TREE)
-    tree_push_pattern();
-#endif
-}
-
-#if EXPERIMENTAL_READING
-
-struct tree_node graph[2];
-int tree_next = 0;
-
-/* The elements of a "simplified" pattern, which has already been
- * copied in the following ways:
- *  1) All rotations
- *  2) All ATT_x & ATT_o elements reduced to ATT_dot, ATT_X, and ATT_O
- * 
- * This simplification allows for very simple searching of the
- * pre-digested patterns.  
- *
- * For example, a pattern with 8 symmetry and one ATT_x element will
- * have 16 copies located in various places throughout the tree.
- * This function adds only one of the 16 copies.
- */
-static void
-tree_push_elements(struct element_node *elist,
-		   struct tree_node *tree_start, int ll)
-{
-  struct tree_node_list *grptr;
-  struct element_node *elist_next;
-  struct element_node *elist_prev;
-
-   if (!tree_start->next_list) {
-     tree_start->next_list = malloc(sizeof(*(tree_start->next_list)));
-     tree_start->next_list->next = 0;
-   }
-
-    elist_prev = elist_next = elist;
-    while (elist_next->next) {
-      elist_prev = elist_next;
-      elist_next = elist_next->next;
-      for (grptr = tree_start->next_list; grptr != 0; grptr = grptr->next) {
-        if (elist_next->e.x == grptr->node.x
-	    && elist_next->e.y == grptr->node.y
-	    && elist_next->e.att == grptr->node.att)
-        {
-          if (verbose) 
-            fprintf(stderr, "  element matched.\n");
-          elist_prev->next = elist_next->next;
-          tree_push_elements(elist, &(grptr->node), ll);
-          return;
-        }
-      }
-    }
-
-    if (elist->next) {
-      /* Still elements to add to tree */
-      for (grptr = tree_start->next_list;
-	   grptr->next != NULL;
-	   grptr = grptr->next)
-	;
-      
-      grptr->next = malloc(sizeof(*(grptr->next)));
-      grptr = grptr->next;
-      grptr->node.matches = 0;
-      grptr->node.att = elist->next->e.att;
-      if (!(grptr->node.att == ATT_dot
-	    || grptr->node.att == ATT_X
-	    || grptr->node.att == ATT_O)) {
-        fprintf(stderr,
-		"%s(%d) : error : Internal error; unexpected att = %d\n",
-                current_file, current_line_number, grptr->node.att);
-        fatal_errors++;
-      }
-      grptr->node.x = elist->next->e.x;
-      grptr->node.y = elist->next->e.y;
-      grptr->node.next_list = 0;
-      grptr->next = 0;
-      elist->next = elist->next->next;
-      if (verbose) {
-        fprintf(stderr, "  Added node %c, x=%2d, y=%2d\n", 
-		*(VALID_PATTERN_CHARS + grptr->node.att),
-		grptr->node.x, grptr->node.y);
-      }
-      tree_push_elements(elist, &grptr->node, ll);
-    }
-    else {
-      /* patten matches here! */
-      struct match_node *matches;
-      if (verbose)
-        fprintf(stderr, "  pattern complete.\n");
-      matches = tree_start->matches;
-      
-      if (!matches) {
-        matches = malloc(sizeof(*matches));
-        matches->next = 0;
-        tree_start->matches = matches;
-      }
-      
-      while (matches->next != NULL)
-        matches = matches->next;
-
-      matches->next = malloc(sizeof(*(matches->next)));
-      matches = matches->next;
-      matches->patnum = patno;
-      matches->next = 0;
-      matches->orientation = ll;
-    }
-}
-
-
-/* By this point, the pattern is rotated.  Now, recursively
- * copy the entries as necessary, expanding o & x to ., O, & X
- */
-static void
-tree_push_pattern_DOX(struct element_node *elist, int ll)
-{
-  struct element_node *elist_next = 0;
-  struct element_node *elist_prev = 0;
-  int need_copy = 0;
-
-  elist_next = elist->next;
-  while (elist_next) {
-    if (elist_next->e.att == ATT_o 
-        || elist_next->e.att == ATT_x) {
-      need_copy = 1;
-      break;
-    }
-    elist_next = elist_next->next;
-  }
-    
-  if (need_copy) {
-    struct element_node *elist_copy1 = malloc(sizeof(*elist_copy1));
-    struct element_node *elist_copy2 = malloc(sizeof(*elist_copy2));
-    struct element_node *elist1_next = elist_copy1;
-    struct element_node *elist2_next = elist_copy2;
-    int found_copy_element = 0;
-    
-    elist_next = elist->next;
-    while (elist_next) {
-      elist1_next->next = malloc(sizeof(*(elist1_next->next)));
-      elist1_next = elist1_next->next;
-      elist1_next->e = elist_next->e;
-      elist2_next->next = malloc(sizeof(*(elist2_next->next)));
-      elist2_next = elist2_next->next;
-      elist2_next->e = elist_next->e;
-      if (!found_copy_element) {
-        if (elist_next->e.att == ATT_o
-            || elist_next->e.att == ATT_x) {
-          found_copy_element = 1;
-          elist1_next->e.att = ATT_dot;
-          elist2_next->e.att = (elist_next->e.att == ATT_o ? ATT_O : ATT_X);
-        }
-      }
-      elist1_next->next = 0;
-      elist2_next->next = 0;
-      elist_next = elist_next->next;
-    }
-    assert(found_copy_element);
-    tree_push_pattern_DOX(elist_copy1, ll);
-    tree_push_pattern_DOX(elist_copy2, ll);
-    return;
-  }
-
-  {
-    if (verbose)
-      fprintf(stderr, "P[%s %d]:\n", pattern_names[patno], ll);
-    elist_prev = elist_next = elist;
-    while (elist_next->next) {
-      int i;
-      elist_prev = elist_next;
-      elist_next = elist_next->next;
-      for (i = 0; i <= 1; i++) {
-        if (elist_next->e.x == graph[i].x
-            && elist_next->e.y == graph[i].y
-            && elist_next->e.att == graph[i].att)
-        {
-          elist_prev->next = elist_next->next;
-          tree_push_elements(elist, &graph[i], ll);
-          assert(!elist->next);  /* Element list should get exhausted */
-          return;
-        }
-      }
-    }
-  }
-  assert(0 && "Anchor not matched.");
-}
-
-/* Rotate the pattern and push it onto the tree once for each
- * appropriate rotation.
- */
-static void 
-tree_push_pattern_rot(int ll)
-{
-  struct element_node *elist = 0;
-  struct element_node *elist_next = 0;
-  int i;
-  
-  elist = malloc(sizeof(*elist));
-  elist_next = elist;
-  for (i = 0; i < el; i++) {
-    elist_next->next = malloc(sizeof(*(elist_next->next))); /*or die*/
-    elist_next = elist_next->next;
-    elist_next->e.att = elements[i].att;
-    /* or continue if we don't need this transformation */
-    TRANSFORM2(elements[i].x - ci, elements[i].y - cj, 
-               &(elist_next->e.x), &(elist_next->e.y), ll);
-    elist_next->next = 0;
-  }
-  tree_push_pattern_DOX(elist, ll);
-}
-
-/* For each pattern, this is the entry point to add the pattern
- * to the tree-based pattern matching data structure.
- *
- * The pattern will be rotated and copied possibly many times,
- * as explained in tree_push_elements().
- * 
- * Conceptually, each node of the tree corresponds to either
- * ATT_dot, ATT_X, or ATT_O, with an x and y coordinate relative
- * to the anchor.  When the pattern matcher is run, if 
- * board[POS(node.x, node.y)] == node.att, then proceed to the
- * next node.  If you find a node with a match_node pointer,
- * then a pattern has matched (with a given orientation).
- */
-static void
-tree_push_pattern(void)
-{
-  static int init = 0;
-  int ll;
-  int start_transformation = 0;
-  int end_transformation;
-
-  if (!init) {
-    memset(graph, 0, sizeof(struct tree_node));
-    graph[0].att = ATT_X;
-    graph[1].att = ATT_O;
-    graph[0].next_list = 0;
-    graph[1].next_list = 0;
-    tree_next = 2;
-    init = 1;
-  }
-
-  if (pattern->trfno == 5) {
-    start_transformation = 2;
-    end_transformation = 6;
-  }
-
-  end_transformation = pattern[patno].trfno;
-
-  /* sort the elements so that MOST likely elements are tested first. */
-  gg_sort(elements, el, sizeof(struct patval_b), compare_elements_closest);
-
-  if (0) {
-  int i;
-    for (i = 0; i < el; i++) {
-      fprintf(stderr, "E[%d, %d, %c]\n",
-	      elements[i].x - ci, elements[i].y - cj, 
-	      *(VALID_PATTERN_CHARS + elements[i].att));
-    }
-    fprintf(stderr, "\n");
-  }
-
-  for (ll = start_transformation; ll < end_transformation; ++ll)
-    tree_push_pattern_rot(ll);
 }
 
 
 /* ================================================================ */
-/*         stuff to write out the stored pattern structures         */
-/* ================================================================ */
-
-static int mn_count;
-static int tnl_count;
-
-struct tree_node_list *tnl_dump;
-struct match_node *matches_dump;
-
-#define PASS_COUNT 1
-#define PASS_FILL 2
-
-
-/* Note: Currently the tree_node_list & match_node lists contain
- * dummy headers in their lists, which isn't at all necessary when
- * being used by GNU Go, but are very handy when building them up 
- * in mkpat.  Probably can strip these out when writing out the
- * final data structure.
- *
- * Does the hard work to outputs the tree data structure data as C code 
- * for GNU Go.
- */
-static void
-dump_tree_node(FILE *outfile, struct tree_node *gn, int depth, int pass)
-{
-  static int as_text = 0;
-  struct tree_node_list *gl;
-  tnl_count++;
-
-  if (as_text) {
-    if (depth > 0)
-      fprintf(stderr, "%.*s", depth*2, "                                             ");
-    fprintf(stderr, "GN[att=%c, x=%d, y=%d",
-	    *(VALID_PATTERN_CHARS + gn->att), gn->x, gn->y);
-  }
-  
-  if (pass == PASS_FILL) {
-    tnl_dump[tnl_count].node.att = gn->att;
-    tnl_dump[tnl_count].node.x = gn->x;
-    tnl_dump[tnl_count].node.y = gn->y;
-  }
-
-  if (gn->matches) {
-    struct match_node *m = gn->matches->next;
-    if (pass == PASS_FILL) {
-      tnl_dump[tnl_count].node.matches = (void *) mn_count;
-      matches_dump[mn_count].patnum = -1; /*Unused*/
-      matches_dump[mn_count].orientation = 0; /*Unused*/
-      matches_dump[mn_count].next = (void *) (mn_count + 1);
-    }
-    
-    if (as_text)
-      fprintf(stderr, ", matches[%d]: ", mn_count);
-
-    mn_count++;
-    while (m) {
-      if (pass == PASS_FILL) {
-        matches_dump[mn_count].patnum = m->patnum;
-        matches_dump[mn_count].orientation = m->orientation;
-        if (m->next)
-          matches_dump[mn_count].next = (void *) (mn_count + 1);
-	else
-          matches_dump[mn_count].next = 0;
-      }
-      
-      if (as_text)
-        fprintf(stderr, "P[%s, %d]", pattern_names[m->patnum],
-		m->orientation);
-
-      mn_count++;
-      m = m->next;
-    }
-  }
-  else {
-    if (pass == PASS_FILL)
-      tnl_dump[tnl_count].node.matches = 0;
-  }
-
-  if (as_text)
-    fprintf(stderr, "]\n");
-
-  gl = gn->next_list;
-  if (gl) {
-    int prev_tnl_count = tnl_count;
-    if (pass == PASS_FILL) {
-      tnl_dump[tnl_count].node.next_list = (void *) (tnl_count + 1);
-      /*tnl_dump[tnl_count+1].node data is unused.*/
-      tnl_dump[tnl_count+1].node.matches = 0;   /*Unused*/
-      tnl_dump[tnl_count+1].node.att = -1;      /*Unused*/
-      tnl_dump[tnl_count+1].node.x = -99;       /*Unused*/
-      tnl_dump[tnl_count+1].node.y = -99;       /*Unused*/
-      tnl_dump[tnl_count+1].node.next_list = 0; /*Unused*/
-
-    }
-    prev_tnl_count = tnl_count;
-    tnl_count++;
-    while (gl->next) {
-      if (pass == PASS_FILL)
-        tnl_dump[prev_tnl_count+1].next = (void *) (tnl_count + 1);
-
-      prev_tnl_count = tnl_count;
-      dump_tree_node(outfile, &gl->next->node, depth + 1, pass);
-      gl = gl->next;
-    }
-    if (pass == PASS_FILL)
-      tnl_dump[prev_tnl_count + 1].next = 0;
-  }
-  else {
-    if (pass == PASS_FILL) {
-      assert(0 && "Strange bug here");
-      /* This may be where we crash if we're missing an anchor color
-       * in the database */
-      if (0)
-	fprintf(outfile, "  tnl[%d].node.next_list = 0;\n", tnl_count);
-    }
-  }
-
-
-}
-  
-/*
- * Outputs the tree data structure data as C code for GNU Go.
- */
-static void
-tree_write_patterns(FILE *outfile)
-{
-  int oanchor_index = 0;
-  int i;
-  fprintf(outfile, "#include \"patterns.h\"\n\n");
-
-  mn_count = 1;
-  tnl_count = 0;
-  dump_tree_node(outfile, &graph[0], 0, PASS_COUNT);
-
-  oanchor_index = tnl_count+1;
-  dump_tree_node(outfile, &graph[1], 0, PASS_COUNT);
-
-  tnl_dump = malloc(sizeof(*tnl_dump) * tnl_count);
-  matches_dump = malloc(sizeof(*matches_dump) * mn_count);
-
-  tnl_dump[0].next = (void *) 1;  /* X anchor node */
-  tnl_dump[0].node.att = -1;    /* Not used */
-  tnl_dump[0].node.matches = 0; /* Not used */
-  tnl_dump[0].node.x = -99;     /* Not used */
-  tnl_dump[0].node.y = -99;     /* Not used */
-  tnl_dump[0].node.next_list = 0; /* Not used */
-  tnl_dump[1].next = (void *) oanchor_index;
-  tnl_dump[oanchor_index].next = 0;
-  
-  mn_count = 1;
-  tnl_count = 0;
-  dump_tree_node(outfile, &graph[0], 0, PASS_FILL);
-  dump_tree_node(outfile, &graph[1], 0, PASS_FILL);
-
-  fprintf(outfile, "struct tree_node_list tnl_%s[] =\n{\n", prefix);
-  for (i = 0; i < tnl_count+1; i++) {
-    fprintf(outfile,
-	    "  { {(void *)%d, %d, %d, %d, (void *)%d}, (void *)%d}, /*#%d*/\n",
-	    (int)tnl_dump[i].node.matches,
-	    tnl_dump[i].node.att,
-	    tnl_dump[i].node.x,
-	    tnl_dump[i].node.y,
-	    (int)tnl_dump[i].node.next_list,
-	    (int)tnl_dump[i].next,
-	    i);
-  }
-  fprintf(outfile, "};\n\n");
-
-  fprintf(outfile, "struct match_node matches_%s[] = \n{\n", prefix);
-  for (i = 0; i < mn_count; i++) {
-    fprintf(outfile, "  {%d, %d, (void *)%d}, /*#%d*/\n",
-	    matches_dump[i].patnum,
-	    matches_dump[i].orientation,
-	    (int) matches_dump[i].next,
-	    i);
-  }
-  fprintf(outfile, "};\n\n");
-
-  fprintf(outfile, "void\ninit_tree_%s(void)\n{\n", prefix);
-  fprintf(outfile, "  gg_assert(sizeof(tnl_%s) / sizeof(struct tree_node_list) == %d);\n", 
-	  prefix, tnl_count+1);
-  fprintf(outfile, "  gg_assert(sizeof(matches_%s) / sizeof(struct match_node) == %d);\n",
-	  prefix, mn_count);
-  fprintf(outfile,
-	  "  tree_initialize_pointers(tnl_%s, matches_%s, %d, %d);\n",
-	  prefix, prefix, tnl_count+1, mn_count+1);
-  fprintf(outfile, "}\n\n");
-}
-
-#endif
-
-
-/* ================================================================ */
 /*		    Corner database creation stuff		    */
 /* ================================================================ */
 
@@ -2836,15 +2345,6 @@
 {
   int j;
 
-#if EXPERIMENTAL_READING
-  if (database_type == DB_TREE)
-    tree_write_patterns(outfile);
-  else
-    fprintf(outfile, "\nvoid\ninit_tree_%s(void)\n{\n"
-	    "  /* nothing to do - tree option not compiled */\n"
-	    "}\n\n", prefix);
-#endif
-
   /* Write out the patterns. */
   if (database_type == DB_CORNER)
     fprintf(outfile, "static struct corner_pattern %s[] = {\n", prefix);
@@ -2979,12 +2479,6 @@
     fprintf(outfile, " ,& dfa_%s\n", prefix); /* pointer to the wired dfa */
   else
     fprintf(outfile, " , NULL\n"); /* pointer to a possible dfa */
-#if EXPERIMENTAL_READING
-  if (database_type == DB_TREE)
-    fprintf(outfile, " , tnl_%s", prefix);
-  else
-    fprintf(outfile, " , NULL\n");
-#endif
 
   fprintf(outfile, "};\n");
 }
@@ -3013,13 +2507,13 @@
     int multiple_anchor_options = 0;
 
     /* Parse command-line options */
-    while ((i = gg_getopt(argc, argv, "i:o:t:vV:pcfCDTd:A:OXbma")) != EOF) {
+    while ((i = gg_getopt(argc, argv, "i:o:t:vV:pcfCDd:A:OXbma")) != EOF) {
       switch (i) {
       case 'i': 
 	if (input_files == MAX_INPUT_FILE_NAMES) {
 	  fprintf(stderr, "Error : Too many input files (maximum %d supported)\n",
 	    MAX_INPUT_FILE_NAMES);
-	  return 1;
+	  return EXIT_FAILURE;
         }
 	input_file_names[input_files++] = gg_optarg;
 	break;
@@ -3034,29 +2528,20 @@
       case 'f':
       case 'C':
       case 'D':
-      case 'T':
       case 'd':
 	if (database_type) {
 	  fprintf(stderr, "Error : More than one database type specified (-%c and -%c)\n",
 		  database_type, i);
	  return 1;
 	}
 	database_type = i;
 	if (i == 'd') {
 	  iterations = strtol(gg_optarg, NULL, 10);
 	  if (iterations < 0) {
 	    fprintf(stderr, "Error : Expected a non-negative number of iterations\n");
 	    return 1;
 	  }
 	}
-
-#if EXPERIMENTAL_READING == 0
-	if (i == 'T') {
-	  fprintf(stderr, "Error : Tree based matcher is unsupported in this configuration\n");
-	  fprintf(stderr, "        Try `configure --enable-experimental-reading'\n");
-	  return 1;
-	}
-#endif
 	break;
 
       case 'O':
@@ -3384,8 +2869,8 @@
 	  }
 
 	  if (attributes_needed
-	      && (database_type == DB_FULLBOARD || database_type == DB_TREE)) {
-	    fprintf(stderr, "%s(%d) : Error : attributes other than `value' are not allowed in fullboard and tree databases\n",
+	      && database_type == DB_FULLBOARD) {
+	    fprintf(stderr, "%s(%d) : Error : attributes other than `value' are not allowed in fullboard databases\n",
 		    current_file, current_line_number);
 	    fatal_errors++;
 	  }
Index: patterns/patterns.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v
retrieving revision 1.70
diff -u -r1.70 patterns.h
--- patterns/patterns.h	16 Sep 2005 22:53:40 -0000	1.70
+++ patterns/patterns.h	23 Sep 2005 22:27:02 -0000
@@ -275,18 +275,11 @@
 };
 
 
-#if EXPERIMENTAL_READING
-struct tree_node_list;
-#endif
-
 struct pattern_db {
   int fixed_for_size;
   const int fixed_anchor;
   struct pattern *patterns;
   struct dfa_rt *pdfa;
-#if EXPERIMENTAL_READING
-  struct tree_node_list *tnl; /* For tree-based pattern matching */
-#endif
 };
 
 
@@ -334,23 +327,6 @@
 int break_mirror_helper(int str, int color);
 
 
-void init_tree_conn(void);
-void init_tree_pat(void);
-void init_tree_attpat(void);
-void init_tree_defpat(void);
-void init_tree_influencepat(void);
-void init_tree_barrierspat(void);
-void init_tree_endpat(void);
-void init_tree_aa_attackpat(void);
-void init_tree_owl_attackpat(void);
-void init_tree_owl_vital_apat(void);
-void init_tree_owl_defendpat(void);
-void init_tree_fusekipat(void);
-void init_tree_joseki(void);
-void init_tree_read_attack(void);
-void init_tree_read_defend(void);
-void init_tree_oracle(void);
-
 /* pattern arrays themselves */
 extern struct pattern_db pat_db;
 extern struct pattern_db aa_attackpat_db;
@@ -372,40 +348,6 @@
 extern struct fullboard_pattern fuseki19[];
 extern struct fullboard_pattern fuseki13[];
 extern struct fullboard_pattern fuseki9[];
-
-#if EXPERIMENTAL_READING
-
-/* Experimental reading */
-extern struct pattern_db read_attack_db;
-extern struct pattern_db read_defend_db;
-
-#endif
-
-/* Tree-based pattern matching structures*/
-
-struct match_node;
-struct tree_node_list;
-
-struct match_node {
-  int patnum;
-  int orientation;
-  struct match_node *next;
-};
-
-
-struct tree_node {
-  struct match_node *matches;
-  int att;
-  int x;
-  int y;
-  struct tree_node_list *next_list;
-};
-
-struct tree_node_list {
-  struct tree_node node;
-  struct tree_node_list *next;
-};
-
 
 struct corner_db;
 struct corner_variation;
