11 #define ERRPRINT(fmt, as...) fprintf(stderr, fmt, ## as);
12 #define DPRINT(fmt, as...) if(DEBUG) ERRPRINT(fmt, ## as);
14 typedef enum {OBJECT
, COORD
, HYBRID
} strategy
;
18 strategy strat
= HYBRID
;
23 "\t%s [opts] [FILE [FILE [...]]]\n"
26 "\tAll strategies are mutually exclusive\n"
27 "\t-c coordinate based strategy\n"
28 "\t-o object based strategy\n"
29 "\t-y hybrid strategy\n"
30 // "\t-l LURD lURD verification strategy\n"
31 // "\t-r show all positions that are a valid solution\n"
33 "\t-d enable verbose debug output\n"
34 "\t-h show this help\n"
36 "Positional arguments:\n"
37 "\tFILE zero or more sokoban screens\n"
38 "\t when no file is specified stdin will be used\n", prg
);
41 void solve(FILE *inputstream
)
43 clock_t time_start_read
, time_end_read
;
44 clock_t time_start_encode
, time_end_encode
;
46 time_start_read
= clock();
47 sokoban_screen
*screen
= parse_screen(inputstream
);
48 if (screen
== NULL
) printf("Something went wrong...\n");
49 sokoban_print(screen
);
52 time_end_read
= clock();
53 time_start_encode
= clock();
55 lace_init(0, 1000000);
56 lace_startup(0, NULL
, NULL
);
58 sylvan_init_package(1LL<<21, 1LL<<27, 1LL<<20, 1LL<<26);
64 DPRINT("Encoding coordinate based\n");
67 DPRINT("Encoding object based\n");
70 DPRINT("Encoding hybrid based\n");
76 time_end_encode
= clock();
80 ERRPRINT("Reading: %fs\n",
81 ((double) (time_end_read
-time_start_read
))/CLOCKS_PER_SEC
);
82 ERRPRINT("Encoding: %fs\n",
83 ((double) (time_end_encode
-time_start_encode
))/CLOCKS_PER_SEC
);
86 int main(int argc
, char **argv
)
90 while((optchar
= getopt(argc
, argv
, "cdhoy")) != -1){
94 DPRINT("Strategy changed to Coordinate based\n");
98 DPRINT("Debug enabled\n");
105 DPRINT("Strategy changed to Object based\n");
109 DPRINT("Strategy changed to Hybrid\n");
113 ERRPRINT("Unknown option `-%c'.\n", optopt
);
115 ERRPRINT("Unknown option char `-\\x%x'.\n", optopt
);
124 ERRPRINT("You have not specified a file, reading from stdin\n");
128 for(int filepathindex
= optind
; filepathindex
< argc
; filepathindex
++){
129 char *currentfilepath
= argv
[filepathindex
];
130 ERRPRINT("Processing: %s\n", currentfilepath
);
131 FILE *currentfile
= fopen(currentfilepath
, "r");
132 DPRINT("Opening file\n");
134 DPRINT("Closing file\n");