Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/tzaarProgram/main.c b/tzaarProgram/main.c
- index 2c151bc..6bc70a6 100644
- --- a/tzaarProgram/main.c
- +++ b/tzaarProgram/main.c
- @@ -18,6 +18,7 @@ void printHelp() {
- printf("Searches for the best moves in a position in Tzaar: \n");
- printf("\t-a AI --ai\t AI number (1-9, 20-25, 40-42)\n");
- printf("\t-b FILE --bestmove=FILE\t Search for the best moves in a position stored in FILE. This is required option.\n");
- + printf("\t-o FILE --output=FILE\t File to save the best moves. This is a required option.\n");
- printf("\t-e FILE --execute=FILE\t Execute the the best moves and then save the position to FILE.\n");
- printf("\t-t SECONDS --timelimit=SECONDS\t Set time limit of the search to SECONDS (default is %d).\n", AI_TIME_LIMIT);
- }
- @@ -28,6 +29,7 @@ i32 main(i32 argc, char *argv[])
- i32 time = AI_TIME_LIMIT; // in seconds
- char *executeFile = null;
- char *fileWithPosition = null;
- + char *fileBestMoves = null;
- i32 c, option_index;
- while ((c = getopt_long(argc, argv, options, long_options, &option_index)) >= 0) {
- switch (c) {
- @@ -39,6 +41,10 @@ i32 main(i32 argc, char *argv[])
- fileWithPosition = (char *) malloc(sizeof(char) * (strlen(optarg) + 5));
- strcpy(fileWithPosition, optarg);
- break;
- + case 'o':
- + fileBestMoves = (char *) malloc(sizeof(char) * (strlen(optarg) + 5));
- + strcpy(fileBestMoves, optarg);
- + break;
- case 'e':
- executeFile = (char *) malloc(sizeof(char) * (strlen(optarg) + 5));
- strcpy(executeFile, optarg);
- @@ -61,8 +67,13 @@ i32 main(i32 argc, char *argv[])
- printHelp();
- return 0;
- }
- + if (fileBestMoves == null) {
- + printf("Output file was not specified. Printing usage:\n");
- + printHelp();
- + return 0;
- + }
- i32 err;
- - if ((err = ProcessPosition(ai, time, fileWithPosition, fileWithPosition, executeFile)) != OK) {
- + if ((err = ProcessPosition(ai, time, fileWithPosition, fileBestMoves, executeFile)) != OK) {
- printf("Processing the position failed with error %d.\n", err);
- }
- return err;
- diff --git a/tzaarProgram/main.h b/tzaarProgram/main.h
- index 106a256..f1ab8d6 100644
- --- a/tzaarProgram/main.h
- +++ b/tzaarProgram/main.h
- @@ -18,12 +18,13 @@ struct option long_options[] = {
- {"bestmove", 1, 0, 'b'},
- {"help", 1, 0, 'h'},
- {"execute", 1, 0, 'e'},
- + {"output", 1, 0, 'o'},
- {"timelimit", 1, 0, 't'},
- {0, 0, 0, 0}
- };
- static __attribute__ ((unused))
- -const char *options = "a:t:e:b:h";
- +const char *options = "a:t:e:o:b:h";
- i32 ProcessPosition(i32 ai, i32 time, const char *fileWithPosition, const char *fileBestMoves, const char *fileEorExecutedPos);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement