56fb6bd448059b1b5069da5590694b37c91f7272
13 strategy strat
= HYBRID
;
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_read
, time_end_read
;
38 clock_t time_start_encode
, time_end_encode
;
40 time_start_read
= clock();
41 struct sokoban_screen
*screen
= parse_screen(inputstream
);
42 while(screen
!= NULL
){
44 case FREE
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "FREE");break;
45 case WALL
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "WALL");break;
46 case BOX
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "BOX");break;
47 case TARGET
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "TARGET");break;
48 case AGENT
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "AGENT");break;
49 case TARGAGENT
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "TARGAGENT");break;
50 case TARGBOX
: printf("x = %d y = %d tile = %s\n", screen
->x
, screen
->y
, "TARGBOX");break;
52 screen
= screen
->next
;
54 //parse_screen(inputstream);
55 time_end_read
= clock();
57 time_start_encode
= clock();
60 if(DEBUG
) fprintf(stderr
, "Encoding coordinate based\n");
63 if(DEBUG
) fprintf(stderr
, "Encoding object based\n");
66 if(DEBUG
) fprintf(stderr
, "Encoding hybrid based\n");
69 fprintf(stderr
, "Huh?");
72 time_end_encode
= clock();
75 fprintf(stderr
, "Reading: %fs\n",
76 ((double) (time_end_read
-time_start_read
))/CLOCKS_PER_SEC
);
77 fprintf(stderr
, "Encoding: %fs\n",
78 ((double) (time_end_encode
-time_start_encode
))/CLOCKS_PER_SEC
);
81 int main(int argc
, char **argv
){
84 while((optchar
= getopt(argc
, argv
, "cdhoy")) != -1){
88 if(DEBUG
) fprintf(stderr
, "Strategy changed to Coordinate based\n");
92 if(DEBUG
) fprintf(stderr
, "Debug enabled\n");
99 if(DEBUG
) fprintf(stderr
, "Strategy changed to Object based\n");
103 if(DEBUG
) fprintf(stderr
, "Strategy changed to Hybrid\n");
107 fprintf(stderr
, "Unknown option `-%c'.\n", optopt
);
109 fprintf(stderr
, "Unknown option char `-\\x%x'.\n", optopt
);
118 fprintf(stderr
, "You have not specified a file, reading from stdin\n");
122 for(int filepathindex
= optind
; filepathindex
< argc
; filepathindex
++){
123 char *currentfilepath
= argv
[filepathindex
];
124 fprintf(stderr
, "Processing: %s\n", currentfilepath
);
125 FILE *currentfile
= fopen(currentfilepath
, "r");
126 if(DEBUG
) fprintf(stderr
, "Opening file\n");
128 if(DEBUG
) fprintf(stderr
, "Closing file\n");