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 (845B)


      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 for %s generated incorrectly!\n",
     25 			    solver);
     26 		}
     27 		break;
     28 	}
     29 
     30 gendata_run_finish:
     31 	free(buf);
     32 }
     33 
     34 int main(int argc, char **argv) {
     35 	if (argc < 2) {
     36 		printf("Error: not enough arguments. "
     37 		    "A solver must be given.\n");
     38 		return 1;
     39 	}
     40 
     41 	solver = argv[1];
     42 	nissy_setlogger(log_stderr, NULL);
     43 	timerun(run);
     44 
     45 	return 0;
     46 }