d8d7e2323f285f52652872c1f1e1e9e4c3136fcd
14 strategy strat
= HYBRID
;
20 "\t%s [opts] [FILE [FILE [...]]]\n"
23 "\tAll strategies are mutually exclusive\n"
24 "\t-c coordinate based strategy\n"
25 "\t-o object based strategy\n"
26 "\t-y hybrid strategy\n"
27 // "\t-l LURD lURD verification strategy\n"
28 // "\t-r show all positions that are a valid solution\n"
30 "\t-d enable verbose debug output\n"
31 "\t-h show this help\n"
33 "Positional arguments:\n"
34 "\tFILE zero or more sokoban screens\n"
35 "\t when no file is specified stdin will be used\n", prg
);
38 void solve(FILE *inputstream
)
40 clock_t time_start_read
, time_end_read
;
41 clock_t time_start_encode
, time_end_encode
;
43 time_start_read
= clock();
44 sokoban_screen
*screen
= parse_screen(inputstream
);
45 if (screen
== NULL
) printf("Something went wrong...\n");
46 sokoban_print(screen
);
48 //parse_screen(inputstream);
49 time_end_read
= clock();
51 time_start_encode
= clock();
54 if(DEBUG
) fprintf(stderr
, "Encoding coordinate based\n");
57 if(DEBUG
) fprintf(stderr
, "Encoding object based\n");
60 if(DEBUG
) fprintf(stderr
, "Encoding hybrid based\n");
63 fprintf(stderr
, "Huh?");
66 time_end_encode
= clock();
69 fprintf(stderr
, "Reading: %fs\n",
70 ((double) (time_end_read
-time_start_read
))/CLOCKS_PER_SEC
);
71 fprintf(stderr
, "Encoding: %fs\n",
72 ((double) (time_end_encode
-time_start_encode
))/CLOCKS_PER_SEC
);
75 int main(int argc
, char **argv
)
79 while((optchar
= getopt(argc
, argv
, "cdhoy")) != -1){
83 if(DEBUG
) fprintf(stderr
, "Strategy changed to Coordinate based\n");
87 if(DEBUG
) fprintf(stderr
, "Debug enabled\n");
94 if(DEBUG
) fprintf(stderr
, "Strategy changed to Object based\n");
98 if(DEBUG
) fprintf(stderr
, "Strategy changed to Hybrid\n");
102 fprintf(stderr
, "Unknown option `-%c'.\n", optopt
);
104 fprintf(stderr
, "Unknown option char `-\\x%x'.\n", optopt
);
113 fprintf(stderr
, "You have not specified a file, reading from stdin\n");
117 for(int filepathindex
= optind
; filepathindex
< argc
; filepathindex
++){
118 char *currentfilepath
= argv
[filepathindex
];
119 fprintf(stderr
, "Processing: %s\n", currentfilepath
);
120 FILE *currentfile
= fopen(currentfilepath
, "r");
121 if(DEBUG
) fprintf(stderr
, "Opening file\n");
123 if(DEBUG
) fprintf(stderr
, "Closing file\n");