Bool transition: init.c and friends
[gnushogi.git] / gnushogi / globals.c
blob44b7881279c4cb858d79f84498ff09a0b86f6ba9
1 /*
2 * FILE: globals.c
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
9 * GNU SHOGI is based on GNU CHESS
11 * Copyright (c) 1988, 1989, 1990 John Stanback
12 * Copyright (c) 1992 Free Software Foundation
14 * This file is part of GNU SHOGI.
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.
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.
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 * ----------------------------------------------------------------------
33 #include "gnushogi.h"
36 bool ahead = true, hash = true; /* default values for CLI flags -a and -h */
37 char *xwin = 0;
38 char *Lang = NULL;
41 short FROMsquare, TOsquare;
43 bool ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], TesujiFlag[MAXDEPTH]; /* FIXME: turn into bitfields ? */
44 short Pscore[MAXDEPTH], Tscore[MAXDEPTH];
45 small_short Pindex[NO_SQUARES];
47 short mtl[2], hung[2];
48 small_short PieceCnt[2];
50 const char* ColorStr[2] = {"Black", "White"};
52 long znodes;
56 #ifdef BINBOOK
57 extern char *binbookfile;
58 #endif
60 extern char *bookfile;
62 unsigned long hashkey, hashbd;
64 char savefile[128];
65 char listfile[128];
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];
74 #if !defined SAVE_SVALUE
75 short svalue[NO_SQUARES];
76 #endif
78 struct flags flag;
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;
85 #ifdef INTERRUPT_TEST
86 long it, itime0;
87 #endif
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 bool Book;
99 struct TimeControlRec TimeControl;
100 int TCadd = 0;
101 short TCmoves, TCminutes, TCseconds, OperatorTime;
102 bool TCflag;
103 short XCmoves[3] = { 0, 0, 0 };
104 short XCminutes[3] = { 0, 0, 0 };
105 short XCseconds[3] = { 0, 0, 0 };
106 short XC = 0, XCmore = 0;
107 const short otherside[3] = { white, black, neutral };
108 unsigned short hint;
109 short TOflag; /* force search re-init if we backup search */
111 unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH];
112 unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH];
113 unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
115 small_short HasPiece[2][NO_PIECES];
117 const short kingP[3] =
118 { 4, 76, 0 };
120 const small_short relative_value[NO_PIECES] =
121 { 0, 1,
122 #ifndef MINISHOGI
123 3, 4,
124 #endif
125 7, 9, 10, 12,
127 #ifndef MINISHOGI
128 5, 6,
129 #endif
130 8, 11, 13, 14 };
132 const long control[NO_PIECES] =
133 { 0, ctlP,
134 #ifndef MINISHOGI
135 ctlL, ctlN,
136 #endif
137 ctlS, ctlG, ctlB, ctlR,
138 ctlPp,
139 #ifndef MINISHOGI
140 ctlLp, ctlNp,
141 #endif
142 ctlSp, ctlBp, ctlRp, ctlK };
144 short stage, stage2;
145 short balance[2];
147 #ifdef HASHFILE
148 FILE *hashfile;
149 #endif
151 unsigned int starttime;
153 int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
154 int compptr, oppptr;
157 struct leaf *Tree = NULL;
159 hashcode_array *hashcode = NULL;
160 drop_hashcode_array *drop_hashcode = NULL;
162 struct leaf *root = NULL;
164 struct GameRec *GameList = NULL;
166 value_array *value = NULL;
167 fscore_array *fscore = NULL;
169 #ifndef SAVE_DISTDATA
170 bool use_distdata = true;
171 distdata_array *distdata = NULL;
172 #endif
174 #ifndef SAVE_PTYPE_DISTDATA
175 bool use_ptype_distdata = true;
176 distdata_array *ptype_distdata[NO_PTYPE_PIECES];
177 #endif
179 #if !defined SAVE_NEXTPOS
180 next_array *nextdir[NO_PTYPE_PIECES];
181 next_array *nextpos[NO_PTYPE_PIECES];
182 bool use_nextpos = true;
183 #endif
185 #if defined HISTORY
186 bool use_history = true;
187 unsigned short *history = NULL;
188 #endif
190 #ifdef CACHE
191 bool use_etable = true;
192 etable_field *etab[2] = { NULL, NULL };
193 #endif
195 #if ttblsz
196 bool use_ttable = true;
197 unsigned int ttblsize = ttblsz;
198 struct hashentry *ttable[2] = { NULL, NULL };
199 #endif
201 char *DRAW;
202 char *DRAW_REPETITION = "Repetition";
203 char *DRAW_MAXMOVES = "Max Moves";
204 char *DRAW_JUSTDRAW = "Drawn game!";