XBoard: split printing of the features line for clarity.
[gnushogi.git] / gnushogi / globals.c
1 /*
2  * FILE: globals.c
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 #include "gnushogi.h"
34
35
36 short ahead = true, hash = true;
37 char  *xwin = 0;
38 char  *Lang = NULL;
39
40
41 short FROMsquare, TOsquare;
42
43 small_short ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], TesujiFlag[MAXDEPTH];
44 short Pscore[MAXDEPTH], Tscore[MAXDEPTH];
45 small_short Pindex[NO_SQUARES];
46
47 short mtl[2], hung[2];
48 small_short PieceCnt[2];
49
50 char ColorStr[2][10];
51
52 long znodes;
53
54
55
56 #ifdef BINBOOK
57 extern char *binbookfile;
58 #endif
59
60 extern char *bookfile;
61
62 unsigned long hashkey, hashbd;
63
64 char savefile[128];
65 char listfile[128];
66
67 short rpthash[2][256];
68 short TrPnt[MAXDEPTH];
69 small_short PieceList[2][NO_SQUARES];
70 small_short PawnCnt[2][NO_COLS];
71 small_short Captured[2][NO_PIECES];
72 small_short Mvboard[NO_SQUARES];
73
74 #if !defined SAVE_SVALUE
75 short svalue[NO_SQUARES];
76 #endif
77
78 struct flags flag;
79
80 short opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither,
81     INCscore = 0;
82 long ResponseTime = 0, ExtraTime = 0, MaxResponseTime = 0,
83     et = 0, et0 = 0, time0 = 0, ft = 0;
84
85 #ifdef INTERRUPT_TEST
86 long it, itime0;
87 #endif
88
89 long  GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd,
90     FHashCnt, FHashAdd, HashCol, THashCol, filesz, hashmask, hashbase;
91 long  replus, reminus;
92 short HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
93 short player, xwndw;
94 short rehash = -1;
95 short Sdepth, Game50, MaxSearchDepth;
96 short GameCnt = 0;
97 short contempt;
98 int   Book;
99 struct TimeControlRec TimeControl;
100 int   TCadd = 0;
101 short TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
102 short XCmoves[3]   = { 0, 0, 0 };
103 short XCminutes[3] = { 0, 0, 0 };
104 short XCseconds[3] = { 0, 0, 0 };
105 short XC = 0, XCmore = 0;
106 const short otherside[3] = { white, black, neutral };
107 unsigned short hint;
108 short TOflag;       /* force search re-init if we backup search */
109
110 unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH];
111 unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH];
112 unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
113
114 small_short HasPiece[2][NO_PIECES];
115
116 const short kingP[3] =
117 { 4, 76, 0 };
118
119 const small_short relative_value[NO_PIECES] =
120 { 0,  1,
121 #ifndef MINISHOGI
122   3,  4,
123 #endif
124   7,  9,  10,  12,
125   2,
126 #ifndef MINISHOGI
127   5,  6,
128 #endif
129 8, 11, 13,  14 };
130
131 const long control[NO_PIECES] =
132 { 0,  ctlP,
133 #ifndef MINISHOGI
134   ctlL,  ctlN,
135 #endif
136   ctlS,  ctlG, ctlB, ctlR,
137   ctlPp,
138 #ifndef MINISHOGI
139   ctlLp, ctlNp,
140 #endif
141   ctlSp, ctlBp, ctlRp, ctlK };
142
143 short stage, stage2;
144 short balance[2];
145
146 #ifdef HASHFILE
147 FILE *hashfile;
148 #endif
149
150 unsigned int starttime;
151
152 int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
153 int compptr, oppptr;
154
155
156 struct leaf  *Tree = NULL;
157
158 hashcode_array       *hashcode      = NULL;
159 drop_hashcode_array  *drop_hashcode = NULL;
160
161 struct leaf  *root = NULL;
162
163 struct GameRec  *GameList = NULL;
164
165 value_array   *value  = NULL;
166 fscore_array  *fscore = NULL;
167
168 #ifndef SAVE_DISTDATA
169 short use_distdata = true;
170 distdata_array  *distdata = NULL;
171 #endif
172
173 #ifndef SAVE_PTYPE_DISTDATA
174 short use_ptype_distdata = true;
175 distdata_array  *ptype_distdata[NO_PTYPE_PIECES];
176 #endif
177
178 #if !defined SAVE_NEXTPOS
179 next_array  *nextdir[NO_PTYPE_PIECES];
180 next_array  *nextpos[NO_PTYPE_PIECES];
181 short use_nextpos = true;
182 #endif
183
184 #if defined HISTORY
185 short use_history = true;
186 unsigned short  *history = NULL;
187 #endif
188
189 #ifdef CACHE
190 short use_etable = true;
191 etable_field  *etab[2] = { NULL, NULL };
192 #endif
193
194 #if ttblsz
195 short use_ttable = true;
196 unsigned int ttblsize = ttblsz;
197 struct hashentry  *ttable[2] = { NULL, NULL };
198 #endif
199
200 char *DRAW;
201 char *DRAW_REPETITION = "Repetition";
202 char *DRAW_MAXMOVES = "Max Moves";
203 char *DRAW_JUSTDRAW = "Drawn game!";