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

set_eo_tests.c (849B)


      1 #include "../test.h"
      2 
      3 int64_t coord_eo(cube_t);
      4 void set_eo(cube_t *, int64_t);
      5 void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
      6 
      7 void run(void) {
      8 	char str[STRLENMAX];
      9 	cube_t cube;
     10 	uint8_t edge[12], corner[8];
     11 	int64_t eo;
     12 
     13 	fgets(str, STRLENMAX, stdin);
     14 	cube = readcube("H48", str);
     15 	fgets(str, STRLENMAX, stdin);
     16 	eo = atoi(str);
     17 
     18 	set_eo(&cube, eo);
     19 
     20 	if (iserror(cube)) {
     21 		printf("Error setting EO\n");
     22 	} else if (!isconsistent(cube)) {
     23 		pieces(&cube, corner, edge);
     24 		fprintf(stderr, "edges: ");
     25 		for (int i = 0; i < 12; i++)
     26 			fprintf(stderr, "%d ", edge[i]);
     27 		fprintf(stderr, "\n");
     28 		for (int i = 0; i < 8; i++)
     29 			fprintf(stderr, "%d ", corner[i]);
     30 		fprintf(stderr, "\n");
     31 		printf("Setting EO resulted in inconsistent cube\n");
     32 	} else {
     33 		writecube("H48", cube, NISSY_SIZE_H48, str);
     34 		printf("%s\n", str);
     35 	}
     36 }