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


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