nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

transform_move_tests.c (1003B)


      1 #include "../test.h"
      2 
      3 #define MAXMOVES 150
      4 
      5 cube_t applytrans(cube_t, const char *);
      6 uint8_t transform_move(uint8_t, uint8_t);
      7 int64_t readmoves(const char *, size_t n, size_t m,
      8     uint64_t *, uint64_t *, uint8_t [n], uint8_t [m]);
      9 oriented_cube_t move_extended(oriented_cube_t, uint8_t);
     10 oriented_cube_t applymoves(oriented_cube_t, const char *);
     11 uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]);
     12 
     13 void run(void) {
     14 	char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX];
     15 	uint8_t t, moves[MAXMOVES];
     16 	uint64_t i, n, ninv;
     17 	int64_t tot;
     18 	oriented_cube_t cube;
     19 
     20 	fgets(transtr, STRLENMAX, stdin);
     21 	fgets(movestr, STRLENMAX, stdin);
     22 
     23 	cube = solvedcube();
     24 	tot = readmoves(movestr, MAXMOVES, 0, &n, &ninv, moves, NULL);
     25 	if (tot < 0 || ninv != 0) {
     26 		printf("Test error reading moves\n");
     27 		return;
     28 	}
     29 	t = readtrans(transtr);
     30 	for (i = 0; i < n; i++)
     31 		cube = move_extended(cube, transform_move(moves[i], t));
     32 
     33 	writecube(cube, STRLENMAX, cubestr);
     34 	printf("%s\n", cubestr);
     35 }