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