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) |
|---|
-
patterns/Makefile.am
RCS file: /cvsroot/gnugo/gnugo/patterns/Makefile.am,v retrieving revision 1.36 diff -u -p -r1.36 Makefile.am
40 40 41 41 mkpat_SOURCES = mkpat.c transform.c dfa.c 42 42 43 mkpat_LDADD = ../utils/libutils.a ../engine/libboard.a ../sgf/libsgf.a43 mkpat_LDADD = ../utils/libutils.a 44 44 45 45 if DFA_ENABLED 46 46 DFAFLAGS = -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
119 119 120 120 mkpat_SOURCES = mkpat.c transform.c dfa.c 121 121 122 mkpat_LDADD = ../utils/libutils.a ../engine/libboard.a ../sgf/libsgf.a122 mkpat_LDADD = ../utils/libutils.a 123 123 124 124 @DFA_ENABLED_TRUE@DFAFLAGS = -D -m 125 125 @DFA_ENABLED_FALSE@DFAFLAGS = … … 233 233 mkeyes_LDFLAGS = 234 234 am_mkpat_OBJECTS = mkpat.$(OBJEXT) transform.$(OBJEXT) dfa.$(OBJEXT) 235 235 mkpat_OBJECTS = $(am_mkpat_OBJECTS) 236 mkpat_DEPENDENCIES = ../utils/libutils.a ../engine/libboard.a \ 237 ../sgf/libsgf.a 236 mkpat_DEPENDENCIES = ../utils/libutils.a 238 237 mkpat_LDFLAGS = 239 238 am_transpat_OBJECTS = transpat.$(OBJEXT) patlib.$(OBJEXT) \ 240 239 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
54 54 Database type:\n\ 55 55 -p = compile general pattern database (the default)\n\ 56 56 -c = compile connections database\n\ 57 -f = compile a fullboard pattern database\n\58 57 -C = compile a corner pattern database\n\ 59 58 -D = compile a DFA database (allows fast matching)\n\ 60 59 -T = compile a tree based pattern database (even faster)\n\ … … 88 87 #include "gg_utils.h" 89 88 90 89 #include "dfa-mkpat.h" 91 #include "hash.h"92 90 93 91 94 92 #define DB_GENERAL ((int) 'p') 95 93 #define DB_CONNECTIONS ((int) 'c') 96 #define DB_FULLBOARD ((int) 'f')97 94 #define DB_CORNER ((int) 'C') 98 95 #define DB_DFA ((int) 'D') 99 96 #define DB_TREE ((int) 'T') … … 174 171 static char *prefix; 175 172 static struct pattern pattern[MAXPATNO]; /* accumulate the patterns into here */ 176 173 static char pattern_names[MAXPATNO][MAXNAME]; /* with optional names here, */ 177 static Hash_data pattern_hash[MAXPATNO];178 174 static int num_attributes; 179 175 static struct pattern_attribute attributes[MAXPATNO * NUM_ATTRIBUTES]; 180 176 static char helper_fn_names[MAXPATNO][MAXNAME]; /* helper fn names here */ … … 917 913 cj = j; 918 914 pattern[patno].anchored_at_X = (off == ATT_X) ? 3 : 0; 919 915 } 920 921 /* Special limitations for fullboard patterns. */922 if (database_type == DB_FULLBOARD)923 if (off == ATT_dot)924 continue;925 916 926 917 /* Range checking. */ 927 918 assert(el < (int) (sizeof(elements) / sizeof(elements[0]))); … … 1101 1092 fatal_errors = 1; 1102 1093 } 1103 1094 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) { 1110 1096 ci = 0; 1111 1097 cj = 0; 1112 1098 } … … 1880 1866 fprintf(outfile, "{%d,%d}", OFFSET(dx, dy), att); 1881 1867 } 1882 1868 1883 /* This may happen for fullboard patterns orif we have discarded all1869 /* This may happen if we have discarded all 1884 1870 * the elements as unneeded by the matcher. 1885 1871 */ 1886 1872 if (!used_nodes) … … 2711 2697 } 2712 2698 2713 2699 2714 /* ================================================================ */2715 /* Fullboard database specific functions */2716 /* ================================================================ */2717 2718 static void2719 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 assume2726 * black stones at X and white stones at O elements.2727 */2728 static void2729 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 else2746 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 else2759 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 void2772 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 2796 2700 2797 2701 static void 2798 2702 write_attributes(FILE *outfile) … … 3136 3040 } 3137 3041 else if (database_type == DB_CORNER) 3138 3042 corner_init(); 3139 else if (database_type == DB_FULLBOARD)3140 fullboard_init();3141 3043 3142 3044 if (database_type == OPTIMIZE_DFA) { 3143 3045 if (transformations_file_name == NULL) { … … 3384 3286 } 3385 3287 3386 3288 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 andtree databases\n",3289 && database_type == DB_TREE) { 3290 fprintf(stderr, "%s(%d) : Error : attributes other than `value' are not allowed in tree databases\n", 3389 3291 current_file, current_line_number); 3390 3292 fatal_errors++; 3391 3293 } … … 3438 3340 write_to_dfa(patno); 3439 3341 if (database_type == DB_CORNER) 3440 3342 corner_add_pattern(); 3441 else if (database_type == DB_FULLBOARD)3442 compute_fullboard_hash();3443 3343 else if (database_type != OPTIMIZE_DFA) 3444 3344 write_elements(output_FILE); 3445 3345 } … … 3533 3433 fprintf(stderr, "%d / %d patterns have edge-constraints\n", 3534 3434 pats_with_constraints, patno); 3535 3435 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) { 3539 3437 /* Forward declaration, which autohelpers might need. */ 3540 3438 if (database_type != DB_CORNER) 3541 3439 fprintf(output_FILE, "static struct pattern %s[%d];\n\n", prefix, patno + 1);
