Ticket #26: arend_7_7.1-remove-mkpat-fullboard.diff

File arend_7_7.1-remove-mkpat-fullboard.diff, 7.7 kB (added by arend, 3 years ago)

revised patch, hopefully complete now

  • patterns/Makefile.am

    RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.am,v
    retrieving revision 1.36
    diff -u -p -r1.36 Makefile.am
     
    4040 
    4141mkpat_SOURCES  = mkpat.c transform.c dfa.c 
    4242 
    43 mkpat_LDADD = ../utils/libutils.a ../engine/libboard.a ../sgf/libsgf.a 
     43mkpat_LDADD = ../utils/libutils.a 
    4444 
    4545if DFA_ENABLED 
    4646DFAFLAGS = -D -m 
  • patterns/Makefile.in

    RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.in,v
    retrieving revision 1.55
    diff -u -p -r1.55 Makefile.in
     
    119119 
    120120mkpat_SOURCES = mkpat.c transform.c dfa.c 
    121121 
    122 mkpat_LDADD = ../utils/libutils.a ../engine/libboard.a ../sgf/libsgf.a 
     122mkpat_LDADD = ../utils/libutils.a 
    123123 
    124124@DFA_ENABLED_TRUE@DFAFLAGS = -D -m 
    125125@DFA_ENABLED_FALSE@DFAFLAGS =  
     
    233233mkeyes_LDFLAGS = 
    234234am_mkpat_OBJECTS = mkpat.$(OBJEXT) transform.$(OBJEXT) dfa.$(OBJEXT) 
    235235mkpat_OBJECTS = $(am_mkpat_OBJECTS) 
    236 mkpat_DEPENDENCIES = ../utils/libutils.a ../engine/libboard.a \ 
    237         ../sgf/libsgf.a 
     236mkpat_DEPENDENCIES = ../utils/libutils.a 
    238237mkpat_LDFLAGS = 
    239238am_transpat_OBJECTS = transpat.$(OBJEXT) patlib.$(OBJEXT) \ 
    240239        transform.$(OBJEXT) 
  • patterns/mkpat.c

    RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v
    retrieving revision 1.149
    diff -u -p -r1.149 mkpat.c
     
    5454  Database type:\n\ 
    5555        -p = compile general pattern database (the default)\n\ 
    5656        -c = compile connections database\n\ 
    57         -f = compile a fullboard pattern database\n\ 
    5857        -C = compile a corner pattern database\n\ 
    5958        -D = compile a DFA database (allows fast matching)\n\ 
    6059        -T = compile a tree based pattern database (even faster)\n\ 
     
    8887#include "gg_utils.h" 
    8988 
    9089#include "dfa-mkpat.h" 
    91 #include "hash.h" 
    9290 
    9391 
    9492#define DB_GENERAL      ((int) 'p') 
    9593#define DB_CONNECTIONS  ((int) 'c') 
    96 #define DB_FULLBOARD    ((int) 'f') 
    9794#define DB_CORNER       ((int) 'C') 
    9895#define DB_DFA          ((int) 'D') 
    9996#define DB_TREE         ((int) 'T') 
     
    174171static char *prefix; 
    175172static struct pattern pattern[MAXPATNO]; /* accumulate the patterns into here */ 
    176173static char pattern_names[MAXPATNO][MAXNAME]; /* with optional names here, */ 
    177 static Hash_data pattern_hash[MAXPATNO]; 
    178174static int num_attributes; 
    179175static struct pattern_attribute attributes[MAXPATNO * NUM_ATTRIBUTES]; 
    180176static char helper_fn_names[MAXPATNO][MAXNAME]; /* helper fn names here */ 
     
    917913      cj = j; 
    918914      pattern[patno].anchored_at_X = (off == ATT_X) ? 3 : 0; 
    919915    } 
    920  
    921     /* Special limitations for fullboard patterns. */ 
    922     if (database_type == DB_FULLBOARD) 
    923       if (off == ATT_dot) 
    924         continue; 
    925916     
    926917    /* Range checking. */ 
    927918    assert(el < (int) (sizeof(elements) / sizeof(elements[0]))); 
     
    11011092    fatal_errors = 1; 
    11021093  } 
    11031094 
    1104   if (database_type == DB_FULLBOARD) { 
    1105     /* For fullboard patterns, the "anchor" is always at the mid point. */ 
    1106     ci = (maxi-1)/2; 
    1107     cj = (maxj-1)/2; 
    1108   } 
    1109   else if (database_type == DB_CORNER) { 
     1095  if (database_type == DB_CORNER) { 
    11101096    ci = 0; 
    11111097    cj = 0; 
    11121098  } 
     
    18801866    fprintf(outfile, "{%d,%d}", OFFSET(dx, dy), att); 
    18811867  } 
    18821868 
    1883   /* This may happen for fullboard patterns or if we have discarded all 
     1869  /* This may happen if we have discarded all 
    18841870   * the elements as unneeded by the matcher. 
    18851871   */ 
    18861872  if (!used_nodes) 
     
    27112697} 
    27122698 
    27132699 
    2714 /* ================================================================ */ 
    2715 /*                  Fullboard database specific functions           */ 
    2716 /* ================================================================ */ 
    2717  
    2718 static void 
    2719 fullboard_init(void) 
    2720 { 
    2721   set_random_seed(HASH_RANDOM_SEED); 
    2722   hash_init(); 
    2723 } 
    2724  
    2725 /* Compute a hash of the current fullboard pattern, where we assume 
    2726  * black stones at X and white stones at O elements. 
    2727  */ 
    2728 static void 
    2729 compute_fullboard_hash(void) 
    2730 { 
    2731   int node; 
    2732   int used_nodes = 0; 
    2733   int pos; 
    2734   Intersection pattern_board[BOARDSIZE]; 
    2735   unsigned int bs = maxi + 1; 
    2736  
    2737   assert(ci == maxi/2 && cj == maxj/2); 
    2738   assert(maxi == maxj && mini == minj && mini == 0); 
    2739  
    2740   /* Clear private board. */ 
    2741   for (pos = 0; pos < BOARDSIZE; pos++) 
    2742     if ((unsigned) I(pos) < bs && (unsigned) J(pos) < bs) { 
    2743       pattern_board[pos] = EMPTY; 
    2744     } 
    2745     else 
    2746       pattern_board[pos] = GRAY; 
    2747  
    2748   /* Populate private board. */ 
    2749   for (node = 0; node < el; node++) { 
    2750     int x = elements[node].x; 
    2751     int y = elements[node].y; 
    2752     int att = elements[node].att; 
    2753     int pos = POS(x, y); 
    2754     assert((unsigned) I(pos) < bs && (unsigned) J(pos) < bs); 
    2755  
    2756     if (att == ATT_O) 
    2757       pattern_board[pos] = WHITE; 
    2758     else 
    2759       pattern_board[pos] = BLACK; 
    2760  
    2761     used_nodes++; 
    2762   } 
    2763  
    2764   /* Compute hash. */ 
    2765   hashdata_recalc(&pattern_hash[patno], pattern_board, NO_MOVE); 
    2766  
    2767   pattern[patno].patlen = used_nodes; 
    2768 } 
    2769  
    2770  
    2771 static void 
    2772 write_fullboard_patterns(FILE *outfile) 
    2773 { 
    2774   int j, k; 
    2775  
    2776   fprintf(outfile, "struct fullboard_pattern %s[] = {\n", prefix); 
    2777  
    2778   for (j = 0; j < patno; ++j) { 
    2779     struct pattern *p = pattern + j; 
    2780     fprintf(outfile, "  {{{"); 
    2781     for (k = 0; k < NUM_HASHVALUES; k++) { 
    2782       fprintf(outfile, "0x%lx", pattern_hash[j].hashval[k]); 
    2783       if (k < NUM_HASHVALUES - 1) 
    2784         fprintf(outfile, ","); 
    2785     } 
    2786     fprintf(outfile, "}},%d,\"%s\",%d,%d},\n", 
    2787             p->patlen, pattern_names[j], p->move_offset, (int) p->value); 
    2788   } 
    2789  
    2790   fprintf(outfile, "  {{{"); 
    2791   for (k = 0; k < NUM_HASHVALUES - 1; k++) 
    2792     fprintf(outfile, "0,"); 
    2793   fprintf(outfile, "0}}, -1,NULL,0,0}\n};\n"); 
    2794 } 
    2795  
    27962700 
    27972701static void 
    27982702write_attributes(FILE *outfile) 
     
    31363040  } 
    31373041  else if (database_type == DB_CORNER) 
    31383042    corner_init(); 
    3139   else if (database_type == DB_FULLBOARD) 
    3140     fullboard_init(); 
    31413043 
    31423044  if (database_type == OPTIMIZE_DFA) { 
    31433045    if (transformations_file_name == NULL) { 
     
    33843286          } 
    33853287 
    33863288          if (attributes_needed 
    3387               && (database_type == DB_FULLBOARD || database_type == DB_TREE)) { 
    3388             fprintf(stderr, "%s(%d) : Error : attributes other than `value' are not allowed in fullboard and tree databases\n", 
     3289              && database_type == DB_TREE) { 
     3290            fprintf(stderr, "%s(%d) : Error : attributes other than `value' are not allowed in tree databases\n", 
    33893291                    current_file, current_line_number); 
    33903292            fatal_errors++; 
    33913293          } 
     
    34383340              write_to_dfa(patno); 
    34393341            if (database_type == DB_CORNER) 
    34403342              corner_add_pattern(); 
    3441             else if (database_type == DB_FULLBOARD) 
    3442               compute_fullboard_hash(); 
    34433343            else if (database_type != OPTIMIZE_DFA) 
    34443344              write_elements(output_FILE); 
    34453345          } 
     
    35333433    fprintf(stderr, "%d / %d patterns have edge-constraints\n", 
    35343434            pats_with_constraints, patno); 
    35353435 
    3536   if (database_type == DB_FULLBOARD) 
    3537     write_fullboard_patterns(output_FILE); 
    3538   else if (database_type != OPTIMIZE_DFA) { 
     3436  if (database_type != OPTIMIZE_DFA) { 
    35393437    /* Forward declaration, which autohelpers might need. */ 
    35403438    if (database_type != DB_CORNER) 
    35413439      fprintf(output_FILE, "static struct pattern %s[%d];\n\n", prefix, patno + 1);