skeleton updated
[mc1516pa.git] / modelchecker / main.c
1 #include <stdio.h>
2 #include <stdbool.h>
3 #include <ctype.h>
4 #include <time.h>
5
6 #include <sylvan.h>
7 #include "mc.h"
8
9 //#include <sokoban.h>
10 //#include <object.h>
11 //#include <coord.h>
12
13 bool DEBUG = false;
14
15 void usage(char *prg){
16 fprintf(stderr,
17 "Usage:\n"
18 "\t%s [opts] [FILE [FILE [...]]]\n"
19 "\n"
20 "Options:\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"
27 "\n"
28 "\t-d enable verbose debug output\n"
29 "\t-h show this help\n"
30 "\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);
34 }
35
36 void solve(FILE *inputstream){
37 clock_t time_start, time_file_read;
38 int buffer;
39
40 time_start = clock();
41 while((buffer = fgetc(inputstream)) != EOF){
42 printf("%c", buffer);
43 // Alex:
44 // Screen reading
45 // - Removing outside walls
46 // - Bucket fill
47 // - [tile]
48 // - tile = structure {int, int, enumtile}
49 }
50 time_file_read = clock();
51
52 // Both: Encoding in both schemes
53
54 // Future: SMC
55 fprintf(stderr, "CPU time taken: %fs\n",
56 ((double) (time_file_read-time_start))/CLOCKS_PER_SEC);
57 }
58
59 int main(int argc, char **argv){
60 strategy strat = HYBRID;
61 int optchar;
62
63 while((optchar = getopt(argc, argv, "cdhoy")) != -1){
64 switch(optchar){
65 case 'c':
66 strat = COORD;
67 if(DEBUG) fprintf(stderr, "Strategy changed to Coordinate based\n");
68 break;
69 case 'd':
70 DEBUG = true;
71 if(DEBUG) fprintf(stderr, "Debug enabled\n");
72 break;
73 case 'h':
74 usage(argv[0]);
75 return 0;
76 case 'o':
77 strat = OBJECT;
78 if(DEBUG) fprintf(stderr, "Strategy changed to Object based\n");
79 break;
80 case 'y':
81 strat = HYBRID;
82 if(DEBUG) fprintf(stderr, "Strategy changed to Hybrid\n");
83 break;
84 case '?':
85 if(isprint(optopt)){
86 fprintf(stderr, "Unknown option `-%c'.\n", optopt);
87 } else {
88 fprintf(stderr, "Unknown option char `-\\x%x'.\n", optopt);
89 }
90 return 2;
91 default:
92 break;
93 }
94 }
95
96 if(optind == argc){
97 fprintf(stderr, "You have not specified a file, reading from stdin\n");
98 solve(stdin);
99 }
100
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");
107 solve(currentfile);
108 if(DEBUG) fprintf(stderr, "Closing file\n");
109 fclose(currentfile);
110 }
111 return 0;
112 }