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

coorddata_drfinnoe.c (1384B)


      1 #include "../test.h"
      2 
      3 #define BOUND   100000
      4 #define TGROUP  UINT64_C(4278190335)
      5 
      6 cube_t transform(cube_t, uint8_t);
      7 uint64_t coordinate_drfinnoe_coord(cube_t, const unsigned char *);
      8 cube_t coordinate_drfinnoe_cube(uint64_t, const unsigned char *);
      9 size_t coordinate_drfinnoe_gendata(unsigned char *);
     10 
     11 void run(void) {
     12 	bool found;
     13 	uint64_t t;
     14 	char str[STRLENMAX];
     15 	unsigned char *data;
     16 	size_t size;
     17 	cube_t cube;
     18 	oriented_cube_t oc;
     19 	uint64_t coord, coord2;
     20 
     21 	size = coordinate_drfinnoe_gendata(NULL);
     22 	data = malloc(size);
     23 	coordinate_drfinnoe_gendata(data);
     24 
     25 	for (coord = 0; coord < BOUND; coord++) {
     26 		cube = coordinate_drfinnoe_cube(coord, data);
     27 
     28 		oc = (oriented_cube_t) { .cube = cube, .orientation = 0 };
     29 		if (!isconsistent(oc)) {
     30 			printf("Error: invcoord of %" PRId64
     31 			    " is not consistent\n", coord);
     32 			goto cleanup;
     33 		}
     34 
     35 		for (t = 0, found = false; t < 48; t++) {
     36 			if (!((UINT64_C(1) << t) & TGROUP))
     37 				continue;
     38 
     39 			coord2 = coordinate_drfinnoe_coord(transform(cube, t), data);
     40 			if (coord == coord2) {
     41 				found = true;
     42 				break;
     43 			}
     44 		}
     45 
     46 		if (!found) {
     47 			oc = (oriented_cube_t){.cube = cube, .orientation = 0};
     48 			printf("Error: invcoord of %" PRId64 " returns %"
     49 			    PRId64 " with cube:\n", coord, coord2);
     50 			writecube(oc, STRLENMAX, str);
     51 			printf("%s\n", str);
     52 			goto cleanup;
     53 		}
     54 	}
     55 
     56 	printf("All good\n");
     57 
     58 cleanup:
     59 	free(data);
     60 }