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

cocsep_transform_invariant.c (862B)


      1 #include "../test.h"
      2 
      3 #define COCLASS_MASK          (UINT32_C(0xFFFF) << UINT32_C(16))
      4 #define COCLASS(x)            (((x) & COCLASS_MASK) >> UINT32_C(16))
      5 
      6 #define COCSEP_CLASSES 3393
      7 
      8 size_t gendata_cocsep(void *, uint64_t *, cube_t *);
      9 cube_t transform(cube_t, uint8_t);
     10 int64_t coord_cocsep(cube_t);
     11 
     12 void run(void) {
     13 	uint8_t t;
     14 	uint32_t buf[300000];
     15 	uint64_t selfsim[COCSEP_CLASSES];
     16 	int64_t coord, tcoord;
     17 	char str[STRLENMAX];
     18 	cube_t cube, transd, rep[COCSEP_CLASSES];
     19 
     20 	fgets(str, STRLENMAX, stdin);
     21 	cube = readcube("H48", str);
     22 
     23 	gendata_cocsep(buf, selfsim, rep);
     24 
     25 	coord = (int64_t)COCLASS(buf[coord_cocsep(cube)]);
     26 	for (t = 0; t < 48; t++) {
     27 		transd = transform(cube, t);
     28 		tcoord = (int64_t)COCLASS(buf[coord_cocsep(transd)]);
     29 		if (coord != tcoord)
     30 			printf("Error: expected %" PRId64
     31 			    " but got %" PRId64 "\n", coord, tcoord);
     32 	}
     33 }