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

gendata_h48h0k4_tests.c (1817B)


      1 #include "../test.h"
      2 
      3 #define COCSEP_CLASSES        3393
      4 #define INFOSIZE              512
      5 #define INFO_SOLVER_STRLEN    100
      6 #define INFO_DISTRIBUTION_LEN 21
      7 
      8 typedef struct {
      9 	char solver[INFO_SOLVER_STRLEN];
     10 	uint64_t type;
     11 	uint64_t infosize;
     12 	uint64_t fullsize;
     13 	uint64_t hash;
     14 	uint64_t entries;
     15 	uint64_t classes; /* Used only by cocsepdata, for now */
     16 	uint8_t bits;
     17 	uint8_t base;
     18 	uint8_t maxvalue;
     19 	uint64_t next;
     20 	uint64_t distribution[INFO_DISTRIBUTION_LEN];
     21 } tableinfo_t;
     22 
     23 typedef struct {
     24 	uint8_t h;
     25 	uint8_t k;
     26 	uint8_t maxdepth;
     27 	tableinfo_t info;
     28 	void *buf;
     29 	void *h48buf;
     30 	uint32_t *cocsepdata;
     31 	uint64_t selfsim[COCSEP_CLASSES];
     32 	cube_t crep[COCSEP_CLASSES];
     33 } gendata_h48_arg_t;
     34 
     35 int64_t gendata_h48(gendata_h48_arg_t *);
     36 bool readtableinfo(const void *, tableinfo_t *);
     37 
     38 void run(void) {
     39 	char str[STRLENMAX];
     40 	uint8_t i;
     41 	gendata_h48_arg_t arg;
     42 	size_t result, sz;
     43 	tableinfo_t cinfo, hinfo;
     44 	void *h48buf;
     45 
     46 	fgets(str, STRLENMAX, stdin);
     47 	arg.maxdepth = atoi(str);
     48 	fgets(str, STRLENMAX, stdin);
     49 	arg.h = atoi(str);
     50 	arg.k = 4;
     51 
     52 	sz = gendata_h48(&arg); /* With buf = NULL returns data size */
     53 	arg.buf = malloc(sz);
     54 
     55 	result = gendata_h48(&arg);
     56 
     57 	if (!readtableinfo(arg.buf, &cinfo)) {
     58 		printf("Error reading cocsep info\n");
     59 		goto end;
     60 	}
     61 
     62 	h48buf = (char *)arg.buf + cinfo.next;
     63 	if (!readtableinfo(h48buf, &hinfo)) {
     64 		printf("Error reading h48 info\n");
     65 		goto end;
     66 	}
     67 
     68 	printf("%zu\n\n", result);
     69 
     70 	printf("cocsepdata:\n");
     71 	printf("Classes: %" PRIu64 "\n", cinfo.classes);
     72 	printf("Max value: %" PRIu8 "\n", cinfo.maxvalue);
     73 	for (i = 0; i <= cinfo.maxvalue; i++)
     74 		printf("%" PRIu32 ": %" PRIu64 "\n", i, cinfo.distribution[i]);
     75 
     76 	printf("\nh48:\n");
     77 	for (i = 0; i <= hinfo.maxvalue; i++)
     78 		printf("%" PRIu32 ": %" PRIu64 "\n", i, hinfo.distribution[i]);
     79 
     80 end:
     81 	free(arg.buf);
     82 }