Skip to content

Commit 7f26265

Browse files
committed
The --gearbox test case generator now includes SAN movelist.
In addition to the longmove list, include a SAN list for helping test SAN functionality in Gearbox. I eliminated the filtering logic because I wrote a separate Python program to do more sophisticated, yet much faster filtering.
1 parent 07e3c77 commit 7f26265

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/portable.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,7 @@ int MakeGearboxUnitTest(const char *inPgnFileName, const char *outFileName)
240240
Move move;
241241
UnmoveInfo unmove;
242242
int ply = 0;
243-
bool skipThisGame = false;
244-
245-
int totalGameCount = 0;
246-
int keptGameCount = 0;
247-
248-
const int MIN_ELO = 2600;
249-
const int GAME_LIMIT = 1000;
243+
int totalGameCount = 0;
250244

251245
rc = 0;
252246

@@ -257,20 +251,10 @@ int MakeGearboxUnitTest(const char *inPgnFileName, const char *outFileName)
257251
if (state == PGN_FILE_STATE_NEWGAME)
258252
{
259253
++totalGameCount;
260-
skipThisGame = (info.whiteElo < MIN_ELO || info.blackElo < MIN_ELO);
261-
if (!skipThisGame)
262-
{
263-
if (keptGameCount == GAME_LIMIT)
264-
break;
265-
++keptGameCount;
266-
ply = 0; // signals reader that we are starting a new game
267-
board.Init();
268-
}
254+
ply = 0; // signals reader that we are starting a new game
255+
board.Init();
269256
}
270257

271-
if (skipThisGame)
272-
continue;
273-
274258
MoveList legal;
275259
board.GenMoves(legal);
276260

@@ -288,8 +272,9 @@ int MakeGearboxUnitTest(const char *inPgnFileName, const char *outFileName)
288272
rc = 1;
289273
goto failure_exit;
290274
}
291-
292275
fprintf(outfile, "%d %s\n", ply, notation);
276+
277+
// Print all legal moves in longmove format.
293278
for (int i=0; i < legal.num; ++i)
294279
{
295280
if (!FormatLongMove(board.WhiteToMove(), legal.m[i], notation))
@@ -305,6 +290,17 @@ int MakeGearboxUnitTest(const char *inPgnFileName, const char *outFileName)
305290
}
306291
fprintf(outfile, "\n");
307292

293+
// Print all legal moves in SAN/PGN format.
294+
char san[MAX_MOVE_STRLEN + 1];
295+
for (int i=0; i < legal.num; ++i)
296+
{
297+
FormatChessMove(board, legal, legal.m[i], san);
298+
if (i > 0)
299+
fprintf(outfile, " ");
300+
fprintf(outfile, "%s", san);
301+
}
302+
fprintf(outfile, "\n");
303+
308304
board.MakeMove(move, unmove);
309305
++ply;
310306

@@ -330,7 +326,7 @@ int MakeGearboxUnitTest(const char *inPgnFileName, const char *outFileName)
330326
failure_exit:
331327
fclose(outfile);
332328
if (rc == 0)
333-
printf("Kept %d of %d games.\n", keptGameCount, totalGameCount);
329+
printf("Processed %d games.\n", totalGameCount);
334330
else
335331
remove(outFileName);
336332
}

0 commit comments

Comments
 (0)