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

inverse_trans_tests.c (881B)


      1 #include "../test.h"
      2 
      3 uint8_t readtrans(char [static NISSY_SIZE_TRANSFORMATION]);
      4 uint8_t inverse_trans(uint8_t);
      5 cube_t applymoves(cube_t, char *);
      6 cube_t applytrans(cube_t, char *);
      7 extern char *transstr[];
      8 
      9 void run(void) {
     10 	uint8_t t, tinv;
     11 	cube_t cube;
     12 
     13 	for (t = 0; t < 48; t++) {
     14 		cube = solvedcube();
     15 		cube = applymoves(cube, "R");
     16 		cube = applymoves(cube, "U");
     17 		cube = applymoves(cube, "F");
     18 
     19 		cube = applytrans(cube, transstr[t]);
     20 		tinv = inverse_trans(t);
     21 		cube = applytrans(cube, transstr[tinv]);
     22 
     23 		if (iserror(cube)) {
     24 			printf("Error transforming cube\n");
     25 		} else if (!issolvable(cube)) {
     26 			printf("Transformed cube is not solvable\n");
     27 		} else {
     28 			cube = applymoves(cube, "F'");
     29 			cube = applymoves(cube, "U'");
     30 			cube = applymoves(cube, "R'");
     31 			if (!issolved(cube))
     32 				printf("%s: Error! Got %" PRIu8 "\n",
     33 				    transstr[t], tinv);
     34 		}
     35 	}
     36 }