Updating to version 1.3, release made by Mike Vanier (mvanier@bbb.caltech.edu).
[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 1, or (at your option) any
20  * 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, write to the Free
29  * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
30  * ----------------------------------------------------------------------
31  *
32  */
33
34 #include "version.h"
35 #include "gnushogi.h"
36 #include "pattern.h"
37
38
39 extern void ReadOpeningSequences(short *pindex);
40 extern void WriteOpeningSequences(short pindex);
41
42 /*
43
44 small_short PieceCnt[2];
45 small_short PieceList[2][NO_SQUARES];
46 small_short PieceIndex[NO_SQUARES];
47
48 small_short board[NO_SQUARES];
49 small_short color[NO_SQUARES];
50
51 */
52
53 void
54 test_distance()
55 {
56     short side, piece, f, t, d;
57
58     for (side = 0; side <= 1; side++)
59     {
60         printf("SIDE = %d\n", side);
61
62         for (piece = pawn; piece <= king; piece++)
63         {
64             printf("PIECE = %d\n", piece);
65
66             for (f = 0; f < NO_SQUARES; f++)
67             {
68                 printf("FROM %d TO ", f);
69
70                 for (t = 0; t < NO_SQUARES; t++)
71                 {
72                     d = piece_distance(side, piece, f, t);
73
74                     if (d != CANNOT_REACH)
75                         printf("%d:%d ", t, d);
76                 }
77
78                 printf("\n");
79             }
80         }
81     }
82
83 }
84
85
86
87 int
88 main(int argc, char **argv)
89
90 {
91
92     short sq, side, max_pattern_data;
93
94 #if defined(EXTLANGFILE)
95     char *Lang = NULL;
96 #endif
97
98 #ifdef TEST_DISTANCE
99     short d;
100     char  s[80];
101 #endif
102
103     display_type = DISPLAY_RAW;
104
105 #if defined(EXTLANGFILE)
106     InitConst(Lang);
107 #endif
108
109     Initialize_data();
110
111     for (sq = 0; sq < NO_SQUARES; sq++)
112     {
113         board[sq] = no_piece;
114         color[sq] = neutral;
115     }
116
117     ClearCaptured();
118
119     for (side = 0; side <= 1; side++)
120         PieceCnt[side] = -1;
121
122 #ifdef TEST_DISTANCE
123     strcpy(s, "g6i k5i g4i p9g p8g r* s3h p7g b8h B* S5f");
124
125     if (string_to_board_color(s))
126     {
127         printf("ERROR IN string_to_board_color");
128         exit(1);
129     }
130     else
131     {
132         UpdateDisplay(0, 0, 1, 0);
133     }
134
135     d = pattern_distance(black, &pattern);
136
137     printf("distance = %d\n", d);
138
139 #endif
140
141     ReadOpeningSequences(&max_pattern_data);
142     WriteOpeningSequences(max_pattern_data);
143
144     return 0;
145 }
146