4 * Display memory usage of GNU Shogi data structures.
6 * ----------------------------------------------------------------------
7 * Copyright (c) 1993, 1994, 1995 Matthias Mutz
8 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
10 * GNU SHOGI is based on GNU CHESS
12 * Copyright (c) 1988, 1989, 1990 John Stanback
13 * Copyright (c) 1992 Free Software Foundation
15 * This file is part of GNU SHOGI.
17 * GNU Shogi is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 3 of the License,
20 * or (at your option) any later version.
22 * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
23 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * You should have received a copy of the GNU General Public License along
28 * with GNU Shogi; see the file COPYING. If not, see
29 * <http://www.gnu.org/licenses/>.
30 * ----------------------------------------------------------------------
38 struct leaf *Tree, *root;
40 short FROMsquare, TOsquare;
42 small_short ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], TesujiFlag[MAXDEPTH];
43 short Pscore[MAXDEPTH], Tscore[MAXDEPTH];
44 small_short Pindex[NO_SQUARES];
46 short mtl[2], hung[2];
47 small_short PieceCnt[2];
49 struct GameRec *GameList;
57 * In a networked enviroment gnushogi might be compiled on different hosts
58 * with different random number generators; that is not acceptable if they
59 * are going to share the same transposition table.
62 unsigned long next = 1;
69 return ((unsigned int) (next >> 16) & 0xFFFF);
74 gsrand(unsigned int seed)
81 struct hashentry *ttable[2];
82 unsigned int ttblsize;
86 extern char *binbookfile;
89 extern char *bookfile;
91 char savefile[128] = "";
92 char listfile[128] = "";
95 unsigned short *history;
98 short rpthash[2][256];
99 short TrPnt[MAXDEPTH];
100 small_short PieceList[2][NO_SQUARES];
101 small_short PawnCnt[2][NO_COLS];
102 small_short Captured[2][NO_PIECES];
103 small_short Mvboard[NO_SQUARES];
105 #if !defined SAVE_SVALUE
106 short svalue[NO_SQUARES];
111 short opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither,
113 long ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
114 long GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt,
115 HashAdd, FHashCnt, FHashAdd,
116 HashCol, THashCol, filesz, hashmask, hashbase;
117 long replus, reminus;
118 short HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
120 /*unsigned*/ short rehash; /* -1 is used as a flag --tpm */
121 short Sdepth, Game50, MaxSearchDepth;
125 struct TimeControlRec TimeControl;
127 short TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
128 short XCmoves[3], XCminutes[3], XCseconds[3], XC, XCmore;
129 const short otherside[3] = { white, black, neutral };
131 short TOflag; /* force search re-init if we backup search */
133 unsigned short killr0[MAXDEPTH], killr1[MAXDEPTH];
134 unsigned short killr2[MAXDEPTH], killr3[MAXDEPTH];
135 unsigned short PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
137 small_short HasPiece[2][NO_PIECES];
138 const short kingP[3] = { 4, 76, 0 };
140 const long control[NO_PIECES] =
141 { 0, ctlP, ctlL, ctlN, ctlS, ctlG, ctlB, ctlR,
142 ctlPp, ctlLp, ctlNp, ctlSp, ctlBp, ctlRp, ctlK };
148 unsigned int starttime;
149 short ahead = true, hash = true;
152 int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
158 /* adjust number of moves remaining in gamein games */
165 /* don't do anything til you have enough numbers */
166 if (GameCnt < (MINGAMEIN * 2))
169 /* calculate average time in sec for last MINGAMEIN moves */
170 for (i = 0; i < MINGAMEIN; i++)
172 tcompsum += timecomp[i];
173 topsum += timeopp[i];
176 topsum /= (100 * MINGAMEIN);
177 tcompsum /= (100 * MINGAMEIN);
178 /* if I have less time than opponent add another move */
179 me = TimeControl.clock[computer] / 100;
180 him = TimeControl.clock[opponent] / 100;
185 if (((him - me) > 60) || ((me < him) && (me < 120)))
188 /* if I am losing more time with each move add another */
189 /* if (!((me - him) > 60) && tcompsum > topsum) increment++; */
191 if (tcompsum > topsum)
195 else if ((TimeControl.moves[computer] < MINMOVES) && !increment)
197 /* but don't let moves go below MINMOVES */
200 else if ((me > him) && (tcompsum < topsum))
202 /* if I am doing really well use more time per move */
206 TimeControl.moves[computer] += increment;
212 main(int argc, char **argv)
218 l = (long)sizeof(struct hashentry);
219 n = (int)((l * (ttblsz + rehash) * 2) / 1000);
220 printf("ttable:\t\t%4d\tkByte\t[hashentry:%ld "
221 "* (ttblsz:%d + rehash:%d) * 2]\n",
222 n, l, ttblsz, rehash);
226 l = (long)sizeof(struct etable);
227 n = (int)((l * (size_t)ETABLE) / 1000);
232 printf("etab:\t\t%4d\tkByte\t[etable:%ld ETABLE:%d]\n",
235 l = (long)sizeof(struct leaf);
236 n = (int)(l * TREE / 1000);
237 printf("Tree:\t\t%4d\tkByte\t[leaf:%ld * TREE:%d]\n",
241 n = (int)(sizeof_history / 1000);
246 printf("history:\t%4d\tkByte\t[unsigned short:%d "
247 "* HISTORY_SIZE:%ld]\n",
248 n, sizeof(unsigned short), (long)HISTORY_SIZE);
251 l = (long)sizeof(next_array);
252 n = (int)((l * NO_PTYPE_PIECES) / 1000);
254 printf("nextpos:\t%4d\tkByte\t[next_array:%ld "
255 "* NO_PTYPE_PIECES:%d]\n",
256 n, l, NO_PTYPE_PIECES);
258 l = (long)sizeof(next_array);
259 n = (int)((l * NO_PTYPE_PIECES) / 1000);
260 printf("nextdir:\t%4d\tkByte\t[next_array:%ld "
261 "* NO_PTYPE_PIECES:%d]\n",
262 n, l, NO_PTYPE_PIECES);
265 #ifndef SAVE_DISTDATA
266 n = (int)(sizeof(distdata_array) / 1000);
267 printf("distdata:\t%4d\tkByte\n", n);
270 #ifndef SAVE_PTYPE_DISTDATA
271 l = (long)sizeof(distdata_array);
272 n = (int)((l * NO_PTYPE_PIECES) / 1000);
273 printf("ptype_distdata:\t%4d\tkByte\t[distdata_array:%ld "
274 "* NO_PTYPE_PIECES:%d]\n",
275 n, l, NO_PTYPE_PIECES);
278 l = (long)sizeof(hashcode_array);
280 printf("hashcode:\t%4d\tkByte\t[hashval:%ld]\n",
281 n, (long)sizeof(struct hashval));
283 l = (long)sizeof(drop_hashcode_array);
285 printf("drop_hashcode:\t%4d\tkByte\t[hashval:%ld]\n",
286 n, (long)sizeof(struct hashval));
288 l = (long)sizeof(value_array);
290 printf("value:\t\t%4d\tkByte\n", n);
292 l = (long)sizeof(fscore_array);
294 printf("fscore:\t\t%4d\tkByte\n", n);