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