10 //#include <sokoban.h>
16 strategy strat
= HYBRID
;
18 void usage(char *prg
){
21 "\t%s [opts] [FILE [FILE [...]]]\n"
24 "\tAll strategies are mutually exclusive\n"
25 "\t-c coordinate based strategy\n"
26 "\t-o object based strategy\n"
27 "\t-y hybrid strategy\n"
28 // "\t-l LURD lURD verification strategy\n"
29 // "\t-r show all positions that are a valid solution\n"
31 "\t-d enable verbose debug output\n"
32 "\t-h show this help\n"
34 "Positional arguments:\n"
35 "\tFILE zero or more sokoban screens\n"
36 "\t when no file is specified stdin will be used\n", prg
);
39 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 //struct sokoban_screen *screen = parse_screen(inputstream);
45 parse_screen(inputstream
);
46 time_end_read
= clock();
48 time_start_encode
= clock();
54 fprintf(stderr
, "Huh?");
57 time_end_encode
= clock();
61 fprintf(stderr
, "Reading: %fs\n",
62 ((double) (time_end_read
-time_start_read
))/CLOCKS_PER_SEC
);
63 fprintf(stderr
, "Encoding: %fs\n",
64 ((double) (time_end_encode
-time_start_encode
))/CLOCKS_PER_SEC
);
67 int main(int argc
, char **argv
){
70 while((optchar
= getopt(argc
, argv
, "cdhoy")) != -1){
74 if(DEBUG
) fprintf(stderr
, "Strategy changed to Coordinate based\n");
78 if(DEBUG
) fprintf(stderr
, "Debug enabled\n");
85 if(DEBUG
) fprintf(stderr
, "Strategy changed to Object based\n");
89 if(DEBUG
) fprintf(stderr
, "Strategy changed to Hybrid\n");
93 fprintf(stderr
, "Unknown option `-%c'.\n", optopt
);
95 fprintf(stderr
, "Unknown option char `-\\x%x'.\n", optopt
);
104 fprintf(stderr
, "You have not specified a file, reading from stdin\n");
108 for(int filepathindex
= optind
; filepathindex
< argc
; filepathindex
++){
109 char *currentfilepath
= argv
[filepathindex
];
110 fprintf(stderr
, "Processing: %s\n", currentfilepath
);
111 if(DEBUG
) fprintf(stderr
, "Strategy: %d\n", strat
);
112 FILE *currentfile
= fopen(currentfilepath
, "r");
113 if(DEBUG
) fprintf(stderr
, "Opening file\n");
115 if(DEBUG
) fprintf(stderr
, "Closing file\n");