c439d3096c3a942b2d327c4640c585e0f2d00e5e
15 void usage(char *prg
){
18 "\t%s [opts] [FILE [FILE [...]]]\n"
21 "\tAll strategies are mutually exclusive\n"
22 "\t-c coordinate based strategy\n"
23 "\t-o object based strategy\n"
24 "\t-y hybrid strategy\n"
25 // "\t-l LURD lURD verification strategy\n"
26 // "\t-r show all positions that are a valid solution\n"
28 "\t-d enable verbose debug output\n"
29 "\t-h show this help\n"
31 "Positional arguments:\n"
32 "\tFILE zero or more sokoban screens\n"
33 "\t when no file is specified stdin will be used\n", prg
);
36 void solve(FILE *inputstream
){
37 clock_t time_start
, time_file_read
;
41 while((buffer
= fgetc(inputstream
)) != EOF
){
45 // - Removing outside walls
48 // - tile = structure {int, int, enumtile}
50 time_file_read
= clock();
52 // Both: Encoding in both schemes
55 fprintf(stderr
, "CPU time taken: %fs\n",
56 ((double) (time_file_read
-time_start
))/CLOCKS_PER_SEC
);
59 int main(int argc
, char **argv
){
60 strategy strat
= HYBRID
;
63 while((optchar
= getopt(argc
, argv
, "cdhoy")) != -1){
67 if(DEBUG
) fprintf(stderr
, "Strategy changed to Coordinate based\n");
71 if(DEBUG
) fprintf(stderr
, "Debug enabled\n");
78 if(DEBUG
) fprintf(stderr
, "Strategy changed to Object based\n");
82 if(DEBUG
) fprintf(stderr
, "Strategy changed to Hybrid\n");
86 fprintf(stderr
, "Unknown option `-%c'.\n", optopt
);
88 fprintf(stderr
, "Unknown option char `-\\x%x'.\n", optopt
);
97 fprintf(stderr
, "You have not specified a file, reading from stdin\n");
101 for(int filepathindex
= optind
; filepathindex
< argc
; filepathindex
++){
102 char *currentfilepath
= argv
[filepathindex
];
103 fprintf(stderr
, "Processing: %s\n", currentfilepath
);
104 if(DEBUG
) fprintf(stderr
, "Strategy: %d\n", strat
);
105 FILE *currentfile
= fopen(currentfilepath
, "r");
106 if(DEBUG
) fprintf(stderr
, "Opening file\n");
108 if(DEBUG
) fprintf(stderr
, "Closing file\n");