240e3c743b7c5da009dde333de67fb6fdc67499a
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
);
47 //parse_screen(inputstream);
48 time_end_read
= clock();
50 time_start_encode
= clock();
53 if(DEBUG
) fprintf(stderr
, "Encoding coordinate based\n");
56 if(DEBUG
) fprintf(stderr
, "Encoding object based\n");
59 if(DEBUG
) fprintf(stderr
, "Encoding hybrid based\n");
62 fprintf(stderr
, "Huh?");
65 time_end_encode
= clock();
68 fprintf(stderr
, "Reading: %fs\n",
69 ((double) (time_end_read
-time_start_read
))/CLOCKS_PER_SEC
);
70 fprintf(stderr
, "Encoding: %fs\n",
71 ((double) (time_end_encode
-time_start_encode
))/CLOCKS_PER_SEC
);
74 int main(int argc
, char **argv
)
78 while((optchar
= getopt(argc
, argv
, "cdhoy")) != -1){
82 if(DEBUG
) fprintf(stderr
, "Strategy changed to Coordinate based\n");
86 if(DEBUG
) fprintf(stderr
, "Debug enabled\n");
93 if(DEBUG
) fprintf(stderr
, "Strategy changed to Object based\n");
97 if(DEBUG
) fprintf(stderr
, "Strategy changed to Hybrid\n");
101 fprintf(stderr
, "Unknown option `-%c'.\n", optopt
);
103 fprintf(stderr
, "Unknown option char `-\\x%x'.\n", optopt
);
112 fprintf(stderr
, "You have not specified a file, reading from stdin\n");
116 for(int filepathindex
= optind
; filepathindex
< argc
; filepathindex
++){
117 char *currentfilepath
= argv
[filepathindex
];
118 fprintf(stderr
, "Processing: %s\n", currentfilepath
);
119 FILE *currentfile
= fopen(currentfilepath
, "r");
120 if(DEBUG
) fprintf(stderr
, "Opening file\n");
122 if(DEBUG
) fprintf(stderr
, "Closing file\n");