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