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

gendata.c (823B)


      1 #include "../tool.h"
      2 
      3 char *solver;
      4 
      5 static void
      6 run(void) {
      7 	int64_t size;
      8 	char filename[1024], dataid[NISSY_SIZE_DATAID];
      9 	unsigned char *buf;
     10 	
     11 	size = generatetable(solver, &buf, dataid);
     12 	switch (size) {
     13 	case -1:
     14 		return;
     15 	case -2:
     16 		goto gendata_run_finish;
     17 	default:
     18 		if (nissy_checkdata(solver, size, buf) == NISSY_OK) {
     19 			printf("\n");
     20 			printf("Generated %" PRId64 " bytes.\n", size);
     21 			sprintf(filename, "tables/%s", dataid);
     22 			writetable(buf, size, filename);
     23 		} else {
     24 			printf("Error: table generated incorrectly!\n");
     25 		}
     26 		break;
     27 	}
     28 
     29 gendata_run_finish:
     30 	free(buf);
     31 }
     32 
     33 int main(int argc, char **argv) {
     34 	if (argc < 2) {
     35 		printf("Error: not enough arguments. "
     36 		    "A solver must be given.\n");
     37 		return 1;
     38 	}
     39 
     40 	solver = argv[1];
     41 	nissy_setlogger(log_stderr, NULL);
     42 	timerun(run);
     43 
     44 	return 0;
     45 }