nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

checkdata.c (999B)


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