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_selfsim_tests.c (1139B)


      1 /*
      2  * This test is tricky, we only have two cases for now: the solved cube
      3  * and the cube that is one quarter-turn-move off (all such cases are
      4  * equivalent due to symmetry). Adding more tests requires figuring out
      5  * by hand which one is the first position in its class to be reached.
      6  * Note that the .out files need a space before each newline.
      7  */
      8 #include "../test.h"
      9 
     10 size_t gendata_cocsep(void *, uint64_t *, cube_t *);
     11 int64_t coord_cocsep(cube_t);
     12 
     13 void run(void) {
     14 	char str[STRLENMAX];
     15 	char buf[2000000];
     16 	uint32_t *cocsepdata, data;
     17 	int64_t coord, coclass;
     18 	uint64_t selfsim[COCSEP_CLASSES], sim, t;
     19 	cube_t cube, rep[COCSEP_CLASSES];
     20 
     21 	gendata_cocsep(buf, selfsim, rep);
     22 	cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
     23 
     24 	/* All cases in the same test so we do not generate data many times */
     25 
     26 	while (fgets(str, STRLENMAX, stdin) != NULL) {
     27 		cube = readcube("H48", str);
     28 		coord = coord_cocsep(cube);
     29 		data = cocsepdata[coord];
     30 		coclass = (data & (0xFFFU << 16)) >> 16;
     31 		sim = selfsim[coclass];
     32 		for (t = 0; t < 48 && sim; t++, sim >>= 1) {
     33 			if (sim & 1)
     34 				printf("%" PRId64 " ", t);
     35 		}
     36 		printf("\n");
     37 	}
     38 }