Advertisement
Guest User

Untitled

a guest
Sep 29th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.57 KB | None | 0 0
  1. diff --git a/tzaarProgram/main.c b/tzaarProgram/main.c
  2. index 2c151bc..6bc70a6 100644
  3. --- a/tzaarProgram/main.c
  4. +++ b/tzaarProgram/main.c
  5. @@ -18,6 +18,7 @@ void printHelp() {
  6.     printf("Searches for the best moves in a position in Tzaar: \n");
  7.     printf("\t-a AI --ai\t AI number (1-9, 20-25, 40-42)\n");
  8.     printf("\t-b FILE --bestmove=FILE\t Search for the best moves in a position stored in FILE. This is required option.\n");
  9. +   printf("\t-o FILE --output=FILE\t File to save the best moves. This is a required option.\n");
  10.     printf("\t-e FILE --execute=FILE\t Execute the the best moves and then save the position to FILE.\n");
  11.     printf("\t-t SECONDS --timelimit=SECONDS\t Set time limit of the search to SECONDS (default is %d).\n", AI_TIME_LIMIT);
  12.  }
  13. @@ -28,6 +29,7 @@ i32 main(i32 argc, char *argv[])
  14.     i32 time = AI_TIME_LIMIT; // in seconds
  15.     char *executeFile = null;
  16.     char *fileWithPosition = null;
  17. +   char *fileBestMoves = null;
  18.     i32 c, option_index;
  19.     while ((c = getopt_long(argc, argv, options, long_options, &option_index)) >= 0) {
  20.         switch (c) {
  21. @@ -39,6 +41,10 @@ i32 main(i32 argc, char *argv[])
  22.             fileWithPosition = (char *) malloc(sizeof(char) * (strlen(optarg) + 5));
  23.             strcpy(fileWithPosition, optarg);
  24.             break;
  25. +       case 'o':
  26. +           fileBestMoves = (char *) malloc(sizeof(char) * (strlen(optarg) + 5));
  27. +           strcpy(fileBestMoves, optarg);
  28. +           break;
  29.         case 'e':
  30.             executeFile = (char *) malloc(sizeof(char) * (strlen(optarg) + 5));
  31.             strcpy(executeFile, optarg);
  32. @@ -61,8 +67,13 @@ i32 main(i32 argc, char *argv[])
  33.         printHelp();
  34.         return 0;
  35.     }
  36. +   if (fileBestMoves == null) {
  37. +       printf("Output file was not specified. Printing usage:\n");
  38. +       printHelp();
  39. +       return 0;
  40. +   }
  41.     i32 err;
  42. -   if ((err = ProcessPosition(ai, time, fileWithPosition, fileWithPosition, executeFile)) != OK) {
  43. +   if ((err = ProcessPosition(ai, time, fileWithPosition, fileBestMoves, executeFile)) != OK) {
  44.         printf("Processing the position failed with error %d.\n", err);
  45.     }
  46.     return err;
  47. diff --git a/tzaarProgram/main.h b/tzaarProgram/main.h
  48. index 106a256..f1ab8d6 100644
  49. --- a/tzaarProgram/main.h
  50. +++ b/tzaarProgram/main.h
  51. @@ -18,12 +18,13 @@ struct option long_options[] = {
  52.     {"bestmove", 1, 0, 'b'},
  53.     {"help", 1, 0, 'h'},
  54.     {"execute", 1, 0, 'e'},
  55. +   {"output", 1, 0, 'o'},
  56.     {"timelimit", 1, 0, 't'},
  57.     {0, 0, 0, 0}
  58.  };
  59.  
  60.  static __attribute__ ((unused))
  61. -const char *options = "a:t:e:b:h";
  62. +const char *options = "a:t:e:o:b:h";
  63.  
  64.  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