Fix various regression for building out of tree.
[gnushogi.git] / gnushogi / pat2inc.c
1 /*
2  * FILE: pat2inc.c
3  *
4  *     Convert GNU Shogi pattern textfile to an include file.
5  *
6  * ----------------------------------------------------------------------
7  * Copyright (c) 1993, 1994, 1995 Matthias Mutz
8  * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
9  *
10  * GNU SHOGI is based on GNU CHESS
11  *
12  * Copyright (c) 1988, 1989, 1990 John Stanback
13  * Copyright (c) 1992 Free Software Foundation
14  *
15  * This file is part of GNU SHOGI.
16  *
17  * GNU Shogi is free software; you can redistribute it and/or modify it
18  * under the terms of the GNU General Public License as published by the
19  * Free Software Foundation; either version 3 of the License,
20  * or (at your option) any later version.
21  *
22  * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
23  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25  * for more details.
26  *
27  * You should have received a copy of the GNU General Public License along
28  * with GNU Shogi; see the file COPYING. If not, see
29  * <http://www.gnu.org/licenses/>.
30  * ----------------------------------------------------------------------
31  *
32  */
33
34 #include "gnushogi.h"
35 #include "pattern.h"
36
37
38 extern void ReadOpeningSequences(short *pindex);
39 extern void WriteOpeningSequences(short pindex);
40
41 /*
42
43 small_short PieceCnt[2];
44 small_short PieceList[2][NO_SQUARES];
45 small_short PieceIndex[NO_SQUARES];
46
47 small_short board[NO_SQUARES];
48 small_short color[NO_SQUARES];
49
50 */
51
52 void
53 test_distance(void)
54 {
55     short side, piece, f, t, d;
56
57     for (side = 0; side <= 1; side++)
58     {
59         printf("SIDE = %d\n", side);
60
61         for (piece = pawn; piece <= king; piece++)
62         {
63             printf("PIECE = %d\n", piece);
64
65             for (f = 0; f < NO_SQUARES; f++)
66             {
67                 printf("FROM %d TO ", f);
68
69                 for (t = 0; t < NO_SQUARES; t++)
70                 {
71                     d = piece_distance(side, piece, f, t);
72
73                     if (d != CANNOT_REACH)
74                         printf("%d:%d ", t, d);
75                 }
76
77                 printf("\n");
78             }
79         }
80     }
81
82 }
83
84
85
86 int
87 main(int argc, char **argv)
88
89 {
90
91     short sq, side, max_pattern_data;
92
93 #ifdef TEST_DISTANCE
94     short d;
95     char  s[80];
96 #endif
97
98     display_type = DISPLAY_RAW;
99
100     Initialize_data();
101
102     for (sq = 0; sq < NO_SQUARES; sq++)
103     {
104         board[sq] = no_piece;
105         color[sq] = neutral;
106     }
107
108     ClearCaptured();
109
110     for (side = 0; side <= 1; side++)
111         PieceCnt[side] = -1;
112
113 #ifdef TEST_DISTANCE
114     strcpy(s, "g6i k5i g4i p9g p8g r* s3h p7g b8h B* S5f");
115
116     if (string_to_board_color(s))
117     {
118         printf("ERROR IN string_to_board_color");
119         exit(1);
120     }
121     else
122     {
123         UpdateDisplay(0, 0, 1, 0);
124     }
125
126     d = pattern_distance(black, &pattern);
127
128     printf("distance = %d\n", d);
129
130 #endif
131
132     ReadOpeningSequences(&max_pattern_data);
133     WriteOpeningSequences(max_pattern_data);
134
135     return 0;
136 }
137