h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

checkdata.c (859B)


      1 #include "../tool.h"
      2 #include "../expected_distributions.h"
      3 
      4 char *solver, *filename;
      5 
      6 static void
      7 run(void) {
      8 	long long int size, result;
      9 	char *buf;
     10 	FILE *f;
     11 	
     12 	size = nissy_datasize(solver);
     13 
     14 	if (size <= 0) {
     15 		printf("Error in datasize\n");
     16 		return;
     17 	}
     18 
     19 	if ((f = fopen(filename, "rb")) == NULL) {
     20 		printf("Error reading file %s\n", filename);
     21 		return;
     22 	}
     23 
     24 	buf = malloc(size);
     25 	fread(buf, size, 1, f);
     26 	fclose(f);
     27 	result = nissy_checkdata(size, buf);
     28 	free(buf);
     29 
     30 	printf("checkdata %s\n", result == 0 ? "succeeded" : "failed");
     31 
     32 	/* TODO: cross-check with expected distributions? */
     33 }
     34 
     35 int main(int argc, char **argv) {
     36 	if (argc < 3) {
     37 		printf("Error: not enough arguments. "
     38 		    "A solver and a file name must be given.\n");
     39 		return 1;
     40 	}
     41 
     42 	solver = argv[1];
     43 	filename = argv[2];
     44 	nissy_setlogger(log_stderr);
     45 
     46 	timerun(run);
     47 
     48 	return 0;
     49 }