1
/* GNU Chess 5.0 - test.c - testing code
2
Copyright (c) 1999-2002 Free Software Foundation, Inc.
4
GNU Chess is based on the two research programs
5
Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
7
GNU Chess is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2, or (at your option)
12
GNU Chess is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with GNU Chess; see the file COPYING. If not, write to
19
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
Boston, MA 02111-1307, USA.
24
cracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net
33
void TestMoveGenSpeed (void)
34
/**************************************************************************
36
* This routine benchmarks the speed of the bitmap move generation.
37
* The test case is BK.epd, the 24 positions from the Brat-Kopec test
40
**************************************************************************/
43
struct timeval t1, t2;
50
while (ReadEPDFile ("../test/wac.epd", 0))
53
gettimeofday (&t1, NULL);
56
for (i = 0; i < 2000000; i++)
58
TreePtr[2] = TreePtr[1];
61
gettimeofday (&t2, NULL);
62
et += (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) / 1e6;
63
printf ("Time = %f\n", et);
67
printf ("No. of moves generated = %lu\n", GenCnt);
68
printf ("Time taken = %f secs\n", et);
70
printf ("Rate = %f moves/sec.\n", GenCnt / et);
75
void TestNonCaptureGenSpeed (void)
76
/**************************************************************************
78
* This routine benchmarks the speed of the bitmap move generation
79
* for non capturing moves.
80
* The test case is BK.epd, the 24 positions from the Brat-Kopec test
83
**************************************************************************/
86
struct timeval t1, t2;
91
while (ReadEPDFile ("../test/wac.epd", 0))
93
gettimeofday (&t1, NULL);
94
for (i = 0; i < 100000; i++)
96
TreePtr[2] = TreePtr[1];
99
gettimeofday (&t2, NULL);
100
et += (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) / 1e6;
101
printf ("Time = %f\n", et);
103
printf ("No. of moves generated = %lu\n", GenCnt);
104
printf ("Time taken = %f\n", et);
106
printf ("Rate = %f\n", GenCnt / et);
110
void TestCaptureGenSpeed (void)
111
/**************************************************************************
113
* This routine benchmarks the speed of the bitmap move generation
115
* The test case is BK.epd, the 24 positions from the Brat-Kopec test
118
**************************************************************************/
121
struct timeval t1, t2;
126
while (ReadEPDFile ("../test/wac.epd", 0))
128
gettimeofday (&t1, NULL);
129
for (i = 0; i < 200000; i++)
131
TreePtr[2] = TreePtr[1];
134
gettimeofday (&t2, NULL);
135
et += (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) / 1e6;
136
printf ("Time = %f\n", et);
138
printf ("No. of moves generated = %lu\n", GenCnt);
139
printf ("Time taken = %f\n", et);
141
printf ("Rate = %f\n", GenCnt / et);
145
void TestMoveList (void)
146
/****************************************************************************
148
* This routine reads in a *.epd file (EPD notation) and prints the legal
149
* moves for that position.
151
****************************************************************************/
153
while (ReadEPDFile ("TEST/GMG1.epd", 0))
157
TreePtr[2] = TreePtr[1];
159
FilterIllegalMoves (1);
161
printf ("No. of moves generated = %lu\n\n", GenCnt);
166
void TestNonCaptureList (void)
167
/****************************************************************************
169
* This routine reads in a *.epd file (EPD notation) and prints the
170
* non-capturing moves for that position.
172
****************************************************************************/
174
while (ReadEPDFile ("TEST/GMG1.epd", 0))
178
TreePtr[2] = TreePtr[1];
180
FilterIllegalMoves (1);
182
printf ("No. of moves generated = %lu\n\n", GenCnt);
187
void TestCaptureList (void)
188
/****************************************************************************
190
* This routine reads in a *.epd file (EPD notation) and prints the capture
191
* moves for that position.
193
****************************************************************************/
195
while (ReadEPDFile ("TEST/GMG1.epd", 0))
199
TreePtr[2] = TreePtr[1];
201
FilterIllegalMoves (1);
203
printf ("No. of moves generated = %lu\n\n", GenCnt);
210
void TestEvalSpeed (void)
211
/***************************************************************************
213
* This routine reads in the BK.epd and test the speed of the
214
* evaluation routines.
216
***************************************************************************/
219
struct timeval t1, t2;
224
while (ReadEPDFile ("../test/wac.epd", 0))
226
gettimeofday (&t1, NULL);
227
for (i = 0; i < NEVALS; i++)
229
(void) Evaluate (-INFINITY, INFINITY);
231
gettimeofday (&t2, NULL);
232
et += (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec)/1e6;
233
printf ("Time = %f\n", et);
235
printf ("No. of positions evaluated = %lu\n", EvalCnt);
236
printf ("Time taken = %f\n", et);
238
printf ("Rate = %f\n", EvalCnt / et);
244
/**************************************************************************
246
* To test the evaluation routines, read from the BK.epd test file.
247
* Print out the score. This can be improved by being more verbose
248
* and printing out salient features of the board, e.g. King safety,
249
* double bishops, rook on seventh rank, weak pawns, doubled pawns,
250
* bad bishops, passwd pawns, etc etc.
252
***************************************************************************/
257
while (ReadEPDFile ("../test/wac.epd", 0))
260
score = Evaluate (-INFINITY, INFINITY);
261
printf (board.side == white ? "W : " : "B : ");
262
printf ("score = %d\n\n", score);
264
CLEAR (flags, TESTT);