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