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