Initial commit based on GNU Shogi 1.2 patchlevel 3.
[gnushogi.git] / src / globals.c
1 /*
2  * globals.c - C source for GNU SHOGI
3  *
4  * Copyright (c) 1993, 1994, 1995 Matthias Mutz
5  *
6  * GNU SHOGI is based on GNU CHESS
7  *
8  * Copyright (c) 1988,1989,1990 John Stanback
9  * Copyright (c) 1992 Free Software Foundation
10  *
11  * This file is part of GNU SHOGI.
12  *
13  * GNU Shogi is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 1, or (at your option)
16  * any later version.
17  *
18  * GNU Shogi is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with GNU Shogi; see the file COPYING.  If not, write to
25  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26  */
27  
28 #include "gnushogi.h"
29
30
31 short int ahead = true, hash = true;
32 char far *xwin = 0;
33 char far *Lang = NULL;
34
35
36 short FROMsquare, TOsquare;
37
38 small_short ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], TesujiFlag[MAXDEPTH];
39 short Pscore[MAXDEPTH], Tscore[MAXDEPTH];
40 small_short Pindex[NO_SQUARES];
41
42 short mtl[2], hung[2];
43 small_short PieceCnt[2];
44
45 char ColorStr[2][10];
46
47 long znodes;
48
49
50
51 #ifdef BINBOOK
52 extern char *binbookfile;
53 #endif
54 extern char *bookfile;
55
56 unsigned long hashkey, hashbd;
57
58 char savefile[128];
59 char listfile[128];
60
61 short rpthash[2][256];
62 short TrPnt[MAXDEPTH];
63 small_short PieceList[2][NO_SQUARES];
64 small_short PawnCnt[2][NO_COLS];
65 small_short Captured[2][NO_PIECES];
66 small_short Mvboard[NO_SQUARES];
67 #if !defined SAVE_SVALUE
68 short svalue[NO_SQUARES];
69 #endif
70 struct flags flag;
71
72 short opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither,
73   INCscore;
74 long ResponseTime=0, ExtraTime=0, MaxResponseTime=0, et=0, et0=0, time0=0, ft=0;
75 #ifdef INTERRUPT_TEST
76 long it, itime0;
77 #endif
78 long GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd,
79   HashCol, THashCol, filesz, hashmask, hashbase;
80 long replus, reminus;
81 short HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
82 short player, xwndw;
83 short rehash = -1;
84 short Sdepth, Game50, MaxSearchDepth;
85 short GameCnt = 0;
86 short contempt;
87 int Book;
88 struct TimeControlRec TimeControl;
89 int TCadd = 0;
90 short TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
91 short XCmoves[3]={0,0,0};
92 short XCminutes[3]={0,0,0};
93 short XCseconds[3]={0,0,0};
94 short XC=0, XCmore=0;
95 const short otherside[3] = 
96 {white, black, neutral};
97 unsigned short hint;
98 short int TOflag;               /* force search re-init if we backup search */
99
100 unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH];
101 unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH];
102 unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
103
104 small_short HasPiece[2][NO_PIECES]; 
105
106 const short kingP[3] =
107 {4, 76, 0};  
108
109 const small_short relative_value[NO_PIECES] =
110 {0, 1,       3,       4,       7,       9,       10,      12, 
111     2,       5,       6,       8,       11,      13,      14};
112     
113 const long control[NO_PIECES] =
114 {0, ctlP, ctlL, ctlN, ctlS, ctlG, ctlB, ctlR,
115     ctlPp, ctlLp, ctlNp, ctlSp, ctlBp, ctlRp, ctlK };
116
117 short stage, stage2;
118 short balance[2];
119
120 #ifdef HASHFILE
121 FILE *hashfile;
122 #endif
123
124 unsigned int starttime;
125
126 int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
127 int compptr, oppptr;
128
129
130 struct leaf far *Tree = NULL;
131
132 hashcode_array far *hashcode = NULL;
133 drop_hashcode_array far *drop_hashcode = NULL;
134
135 struct leaf far *root = NULL;
136
137 struct GameRec far *GameList = NULL;
138
139 value_array far *value = NULL;
140 fscore_array far *fscore = NULL;
141
142 #ifndef SAVE_DISTDATA
143 short use_distdata = true;
144 distdata_array far *distdata = NULL;
145 #endif
146
147 #ifndef SAVE_PTYPE_DISTDATA
148 short use_ptype_distdata = true;
149 distdata_array far *ptype_distdata[NO_PTYPE_PIECES];
150 #endif
151
152 #if !defined SAVE_NEXTPOS
153 next_array far *nextdir[NO_PTYPE_PIECES];
154 next_array far *nextpos[NO_PTYPE_PIECES];
155 short use_nextpos = true;
156 #endif
157
158 #if defined HISTORY
159 short use_history = true;
160 unsigned short far *history = NULL;
161 #endif
162
163 #ifdef CACHE
164 short use_etable = true;
165 etable_field far *etab[2] = {NULL,NULL};
166 #endif
167
168 #if ttblsz
169 short use_ttable = true;
170 unsigned int ttblsize = ttblsz;
171 struct hashentry far *ttable[2] = {NULL,NULL};
172 #endif
173
174
175
176