deba1707fb3d7c68a13a3214ffee6324e35d082d
[gnushogi.git] / gnushogi / pattern.h
1 /*
2  * FILE: pattern.h
3  *
4  * ----------------------------------------------------------------------
5  * Copyright (c) 1993, 1994, 1995 Matthias Mutz
6  * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
7  *
8  * GNU SHOGI is based on GNU CHESS
9  *
10  * Copyright (c) 1988, 1989, 1990 John Stanback
11  * Copyright (c) 1992 Free Software Foundation
12  *
13  * This file is part of GNU SHOGI.
14  *
15  * GNU Shogi is free software; you can redistribute it and/or modify it
16  * under the terms of the GNU General Public License as published by the
17  * Free Software Foundation; either version 3 of the License,
18  * or (at your option) any later version.
19  *
20  * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
21  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with GNU Shogi; see the file COPYING. If not, see
27  * <http://www.gnu.org/licenses/>.
28  * ----------------------------------------------------------------------
29  *
30  */
31
32
33 #ifndef _PATTERN_H_
34 #define _PATTERN_H_
35
36 #define MAX_NAME     16  /* maximum length of opening name */
37 #define MAX_SEQUENCE  4  /* maximum number of sequences
38                           * for an opening type */
39
40 #define CANNOT_REACH (-1)
41 #define NOT_TO_REACH (-2)
42 #define IS_REACHED   (-3)
43 #define IS_SUCCESSOR (-4)
44
45 #define END_OF_SEQUENCES (-1)
46 #define END_OF_PATTERNS  (-2)
47 #define END_OF_LINKS     (-3)
48 #define END_OF_FIELDS    (-4)
49
50 struct PatternField
51 {
52     short side;
53     short piece;
54     short square;
55 };
56
57
58 struct Pattern_rec
59 {
60     small_short visited;
61     small_short distance[2];
62     short reachedGameCnt[2];
63     short first_link;
64     short first_field;
65     short next_pattern;
66 };
67
68
69 struct OpeningSequence_rec
70 {
71     short opening_type;
72     short first_pattern[MAX_SEQUENCE];
73 };
74
75
76 extern struct Pattern_rec Pattern[];
77 extern struct OpeningSequence_rec OpeningSequence[];
78
79 extern short
80 piece_to_pattern_distance(short side, short piece,
81                           short pside, short pattern);
82
83 extern short
84 pattern_distance(short pside, short pattern);
85
86 extern short
87 board_to_pattern_distance(short pside, short osequence,
88                           short pmplty, short GameCnt);
89
90 extern short
91 locate_opening_sequence(short pside, char *s, short GameCnt);
92
93 extern void
94 DisplayPattern(FILE *fd, short first_field);
95
96 extern void
97 update_advance_bonus(short pside, short os);
98
99 extern void
100 GetOpeningPatterns(short *max_opening_sequence);
101
102 extern void
103 ShowOpeningPatterns(short max_opening_sequence);
104
105
106 extern short
107 ValueOfOpeningName(char *name);
108
109 extern small_short pattern_data[];
110
111
112 #endif /* _PATTERN_H_ */