void DebugAnalysisTest(S_BOARD *pos, S_SEARCHINFO *info) { FILE *file; file = fopen("lct2.epd","r"); char lineIn [1024]; info->depth = MAXDEPTH; info->timeset = TRUE; int time = 1140000; if(file == NULL) { printf("File Not Found\n"); return; } else { while(fgets (lineIn , 1024 , file) != NULL) { info->starttime = GetTimeMs(); info->stoptime = info->starttime + time; ClearHashTable(pos->HashTable); ParseFen(lineIn, pos); printf("\n%s\n",lineIn); printf("time:%d start:%d stop:%d depth:%d timeset:%d\n", time,info->starttime,info->stoptime,info->depth,info->timeset); SearchPosition(pos, info); memset(&lineIn[0], 0, sizeof(lineIn)); } } }
// Test that our search finds example mates in one. char* TestMatesInTwo() { char *fen; Game game; int i, dummyVal; Move actual, expected; uint64_t dummy = 0; StringBuilder builder = NewStringBuilder(); for(i = 0; i < COUNT; i++) { fen = fens[i]; expected = ParseMove(mates[i]); game = ParseFen(fen); actual = Search(&game, &dummy, &dummyVal, 3); if(actual != expected) { AppendString(&builder, "Search failed mate-in-two for:-\n\n" "%s\n" "Expected move %s, engine selected %s.\n\n", StringChessSet(&game.ChessSet), StringMove(expected), StringMove(actual)); } } return builder.Length == 0 ? NULL : BuildString(&builder, true); }
void MirrorEvalTest(S_BOARD *pos) { FILE *file; char lineIn [1024]; int ev1 = 0; int ev2 = 0; int positions = 0; file = fopen("mirror.epd","r"); if(file == NULL) { printf("File Not Found\n"); return; } else { while(fgets (lineIn, 1024, file) != NULL) { ParseFen(lineIn, pos); positions++; ev1 = EvalPosition(pos); MirrorBoard(pos); ev2 = EvalPosition(pos); if(ev1 != ev2) { printf("\n\n\n"); ParseFen(lineIn, pos); PrintBoard(pos); MirrorBoard(pos); PrintBoard(pos); printf("\n\nMirror Fail:\n%s\n", lineIn); getchar(); return; } if((positions % 1000) == 0) { printf("position %d\n", positions); } memset(&lineIn[0], 0, sizeof(lineIn)); } } }
int main(int argc, char **argv) { Game game; uint64_t perftVal; int depth; SetUnbufferedOutput(); if(argc == 2 && strcmp(argv[1], "--version") == 0) { printf("Weak %s.\n", version); return EXIT_SUCCESS; } if(argc < 3) { fprintf(stderr, "Usage: %s [fen] [depth]\n", argv[0]); return EXIT_FAILURE; } if((depth = atoi(argv[2])) < 1) { fprintf(stderr, "Invalid depth '%s'.\n", argv[2]); return EXIT_FAILURE; } // Initialise prng. randk_seed(); randk_warmup(KISS_WARMUP_ROUNDS); InitEngine(); game = ParseFen(argv[1]); perftVal = QuickPerft(&game, depth); printf("%lu\n", perftVal); return EXIT_SUCCESS; }