cube-solver/cube.c
2022-08-01 19:16:24 -05:00

530 lines
26 KiB
C

#include <stdio.h>
#include "cube.h"
// Creates cubes capable of rotating ~10,000,000 times per second on a Dell XPS
struct Cube generate_cube() {
struct Cube ret;
int i;
int j;
for (i = 0; i < FACE_COUNT; ++i) {
for (j = 0; j < INDEX_COUNT; ++j) {
ret.faces[i][j] = i;
}
}
return ret;
};
void print_cube(struct Cube* c) {
printf(
" %d%d%d \n"
" %d%d%d \n"
" %d%d%d \n"
"%d%d%d%d%d%d%d%d%d\n"
"%d%d%d%d%d%d%d%d%d\n"
"%d%d%d%d%d%d%d%d%d\n"
" %d%d%d \n"
" %d%d%d \n"
" %d%d%d \n"
" %d%d%d \n"
" %d%d%d \n"
" %d%d%d \n",
c->faces[FACE_TOP][0], c->faces[FACE_TOP][1], c->faces[FACE_TOP][2],
c->faces[FACE_TOP][3], c->faces[FACE_TOP][4], c->faces[FACE_TOP][5],
c->faces[FACE_TOP][6], c->faces[FACE_TOP][7], c->faces[FACE_TOP][8],
c->faces[FACE_LEFT][0], c->faces[FACE_LEFT][1], c->faces[FACE_LEFT][2], c->faces[FACE_FRONT][0], c->faces[FACE_FRONT][1], c->faces[FACE_FRONT][2], c->faces[FACE_RIGHT][0], c->faces[FACE_RIGHT][1], c->faces[FACE_RIGHT][2],
c->faces[FACE_LEFT][3], c->faces[FACE_LEFT][4], c->faces[FACE_LEFT][5], c->faces[FACE_FRONT][3], c->faces[FACE_FRONT][4], c->faces[FACE_FRONT][5], c->faces[FACE_RIGHT][3], c->faces[FACE_RIGHT][4], c->faces[FACE_RIGHT][5],
c->faces[FACE_LEFT][6], c->faces[FACE_LEFT][7], c->faces[FACE_LEFT][8], c->faces[FACE_FRONT][6], c->faces[FACE_FRONT][7], c->faces[FACE_FRONT][8], c->faces[FACE_RIGHT][6], c->faces[FACE_RIGHT][7], c->faces[FACE_RIGHT][8],
c->faces[FACE_BOTTOM][0], c->faces[FACE_BOTTOM][1], c->faces[FACE_BOTTOM][2],
c->faces[FACE_BOTTOM][3], c->faces[FACE_BOTTOM][4], c->faces[FACE_BOTTOM][5],
c->faces[FACE_BOTTOM][6], c->faces[FACE_BOTTOM][7], c->faces[FACE_BOTTOM][8],
c->faces[FACE_BACK][0], c->faces[FACE_BACK][1], c->faces[FACE_BACK][2],
c->faces[FACE_BACK][3], c->faces[FACE_BACK][4], c->faces[FACE_BACK][5],
c->faces[FACE_BACK][6], c->faces[FACE_BACK][7], c->faces[FACE_BACK][8]
);
}
static void transition_cube(struct Cube* cube, struct CubeTransition* transitions) {
// Should always be 20 transitions
static int old_transition_values[TRANSITIONS_PER_ROTATION];
int i;
for (i = 0; i < TRANSITIONS_PER_ROTATION; ++i) {
old_transition_values[i] =
cube->faces[transitions[i].old_face][transitions[i].old_index];
}
for (i = 0; i < TRANSITIONS_PER_ROTATION; ++i) {
cube->faces[transitions[i].new_face][transitions[i].new_index] =
old_transition_values[i];
}
}
// Generated with cube_struct_gen.py
void u(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_TOP, 0, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 1, FACE_TOP, 5 },
(struct CubeTransition){ FACE_TOP, 2, FACE_TOP, 8 },
(struct CubeTransition){ FACE_TOP, 3, FACE_TOP, 1 },
(struct CubeTransition){ FACE_TOP, 5, FACE_TOP, 7 },
(struct CubeTransition){ FACE_TOP, 6, FACE_TOP, 0 },
(struct CubeTransition){ FACE_TOP, 7, FACE_TOP, 3 },
(struct CubeTransition){ FACE_TOP, 8, FACE_TOP, 6 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_FRONT, 1, FACE_LEFT, 1 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_BACK, 8 },
(struct CubeTransition){ FACE_LEFT, 1, FACE_BACK, 7 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_BACK, 6 },
(struct CubeTransition){ FACE_BACK, 8, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_BACK, 7, FACE_RIGHT, 1 },
(struct CubeTransition){ FACE_BACK, 6, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_RIGHT, 1, FACE_FRONT, 1 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_FRONT, 2 }
};
transition_cube(cube, transitions);
}
void d(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_TOP, 0, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 1, FACE_TOP, 5 },
(struct CubeTransition){ FACE_TOP, 2, FACE_TOP, 8 },
(struct CubeTransition){ FACE_TOP, 3, FACE_TOP, 1 },
(struct CubeTransition){ FACE_TOP, 5, FACE_TOP, 7 },
(struct CubeTransition){ FACE_TOP, 6, FACE_TOP, 0 },
(struct CubeTransition){ FACE_TOP, 7, FACE_TOP, 3 },
(struct CubeTransition){ FACE_TOP, 8, FACE_TOP, 6 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_FRONT, 7, FACE_RIGHT, 7 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_BACK, 0 },
(struct CubeTransition){ FACE_RIGHT, 7, FACE_BACK, 1 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_BACK, 2 },
(struct CubeTransition){ FACE_BACK, 0, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_BACK, 1, FACE_LEFT, 7 },
(struct CubeTransition){ FACE_BACK, 2, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_LEFT, 7, FACE_FRONT, 7 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_FRONT, 8 }
};
transition_cube(cube, transitions);
}
void f(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_FRONT, 0, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_FRONT, 1, FACE_FRONT, 5 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_FRONT, 3, FACE_FRONT, 1 },
(struct CubeTransition){ FACE_FRONT, 5, FACE_FRONT, 7 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_FRONT, 7, FACE_FRONT, 3 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_TOP, 6 },
(struct CubeTransition){ FACE_LEFT, 5, FACE_TOP, 7 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_TOP, 8 },
(struct CubeTransition){ FACE_TOP, 6, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_TOP, 7, FACE_RIGHT, 3 },
(struct CubeTransition){ FACE_TOP, 8, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_BOTTOM, 2 },
(struct CubeTransition){ FACE_RIGHT, 3, FACE_BOTTOM, 1 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_BOTTOM, 0 },
(struct CubeTransition){ FACE_BOTTOM, 2, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_BOTTOM, 1, FACE_LEFT, 5 },
(struct CubeTransition){ FACE_BOTTOM, 0, FACE_LEFT, 2 }
};
transition_cube(cube, transitions);
}
void b(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_BACK, 0, FACE_BACK, 2 },
(struct CubeTransition){ FACE_BACK, 1, FACE_BACK, 5 },
(struct CubeTransition){ FACE_BACK, 2, FACE_BACK, 8 },
(struct CubeTransition){ FACE_BACK, 3, FACE_BACK, 1 },
(struct CubeTransition){ FACE_BACK, 5, FACE_BACK, 7 },
(struct CubeTransition){ FACE_BACK, 6, FACE_BACK, 0 },
(struct CubeTransition){ FACE_BACK, 7, FACE_BACK, 3 },
(struct CubeTransition){ FACE_BACK, 8, FACE_BACK, 6 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_TOP, 0 },
(struct CubeTransition){ FACE_RIGHT, 5, FACE_TOP, 1 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 0, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_TOP, 1, FACE_LEFT, 3 },
(struct CubeTransition){ FACE_TOP, 2, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_BOTTOM, 8 },
(struct CubeTransition){ FACE_LEFT, 3, FACE_BOTTOM, 7 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_BOTTOM, 6 },
(struct CubeTransition){ FACE_BOTTOM, 8, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_BOTTOM, 7, FACE_RIGHT, 5 },
(struct CubeTransition){ FACE_BOTTOM, 6, FACE_RIGHT, 2 }
};
transition_cube(cube, transitions);
}
void l(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_LEFT, 0, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_LEFT, 1, FACE_LEFT, 5 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_LEFT, 3, FACE_LEFT, 1 },
(struct CubeTransition){ FACE_LEFT, 5, FACE_LEFT, 7 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_LEFT, 7, FACE_LEFT, 3 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_TOP, 0, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_TOP, 3, FACE_FRONT, 3 },
(struct CubeTransition){ FACE_TOP, 6, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_BOTTOM, 0 },
(struct CubeTransition){ FACE_FRONT, 3, FACE_BOTTOM, 3 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_BOTTOM, 6 },
(struct CubeTransition){ FACE_BOTTOM, 0, FACE_BACK, 0 },
(struct CubeTransition){ FACE_BOTTOM, 3, FACE_BACK, 3 },
(struct CubeTransition){ FACE_BOTTOM, 6, FACE_BACK, 6 },
(struct CubeTransition){ FACE_BACK, 0, FACE_TOP, 0 },
(struct CubeTransition){ FACE_BACK, 3, FACE_TOP, 3 },
(struct CubeTransition){ FACE_BACK, 6, FACE_TOP, 6 }
};
transition_cube(cube, transitions);
}
void r(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_RIGHT, 0, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_RIGHT, 1, FACE_RIGHT, 5 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_RIGHT, 3, FACE_RIGHT, 1 },
(struct CubeTransition){ FACE_RIGHT, 5, FACE_RIGHT, 7 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_RIGHT, 7, FACE_RIGHT, 3 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_BACK, 2, FACE_BOTTOM, 2 },
(struct CubeTransition){ FACE_BACK, 5, FACE_BOTTOM, 5 },
(struct CubeTransition){ FACE_BACK, 8, FACE_BOTTOM, 8 },
(struct CubeTransition){ FACE_BOTTOM, 2, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_BOTTOM, 5, FACE_FRONT, 5 },
(struct CubeTransition){ FACE_BOTTOM, 8, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_TOP, 2 },
(struct CubeTransition){ FACE_FRONT, 5, FACE_TOP, 5 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_TOP, 8 },
(struct CubeTransition){ FACE_TOP, 2, FACE_BACK, 2 },
(struct CubeTransition){ FACE_TOP, 5, FACE_BACK, 5 },
(struct CubeTransition){ FACE_TOP, 8, FACE_BACK, 8 }
};
transition_cube(cube, transitions);
}
void up(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_TOP, 2, FACE_TOP, 0 },
(struct CubeTransition){ FACE_TOP, 5, FACE_TOP, 1 },
(struct CubeTransition){ FACE_TOP, 8, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 1, FACE_TOP, 3 },
(struct CubeTransition){ FACE_TOP, 7, FACE_TOP, 5 },
(struct CubeTransition){ FACE_TOP, 0, FACE_TOP, 6 },
(struct CubeTransition){ FACE_TOP, 3, FACE_TOP, 7 },
(struct CubeTransition){ FACE_TOP, 6, FACE_TOP, 8 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_FRONT, 1, FACE_RIGHT, 1 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_LEFT, 1, FACE_FRONT, 1 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_BACK, 8, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_BACK, 7, FACE_LEFT, 1 },
(struct CubeTransition){ FACE_BACK, 6, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_BACK, 8 },
(struct CubeTransition){ FACE_RIGHT, 1, FACE_BACK, 7 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_BACK, 6 }
};
transition_cube(cube, transitions);
}
void dp(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_TOP, 2, FACE_TOP, 0 },
(struct CubeTransition){ FACE_TOP, 5, FACE_TOP, 1 },
(struct CubeTransition){ FACE_TOP, 8, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 1, FACE_TOP, 3 },
(struct CubeTransition){ FACE_TOP, 7, FACE_TOP, 5 },
(struct CubeTransition){ FACE_TOP, 0, FACE_TOP, 6 },
(struct CubeTransition){ FACE_TOP, 3, FACE_TOP, 7 },
(struct CubeTransition){ FACE_TOP, 6, FACE_TOP, 8 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_FRONT, 7, FACE_LEFT, 7 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_RIGHT, 7, FACE_FRONT, 7 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_BACK, 0, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_BACK, 1, FACE_RIGHT, 7 },
(struct CubeTransition){ FACE_BACK, 2, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_BACK, 0 },
(struct CubeTransition){ FACE_LEFT, 7, FACE_BACK, 1 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_BACK, 2 }
};
transition_cube(cube, transitions);
}
void fp(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_FRONT, 2, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_FRONT, 5, FACE_FRONT, 1 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_FRONT, 1, FACE_FRONT, 3 },
(struct CubeTransition){ FACE_FRONT, 7, FACE_FRONT, 5 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_FRONT, 3, FACE_FRONT, 7 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_BOTTOM, 2 },
(struct CubeTransition){ FACE_LEFT, 5, FACE_BOTTOM, 1 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_BOTTOM, 0 },
(struct CubeTransition){ FACE_TOP, 6, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_TOP, 7, FACE_LEFT, 5 },
(struct CubeTransition){ FACE_TOP, 8, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_TOP, 6 },
(struct CubeTransition){ FACE_RIGHT, 3, FACE_TOP, 7 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_TOP, 8 },
(struct CubeTransition){ FACE_BOTTOM, 2, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_BOTTOM, 1, FACE_RIGHT, 3 },
(struct CubeTransition){ FACE_BOTTOM, 0, FACE_RIGHT, 6 }
};
transition_cube(cube, transitions);
}
void bp(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_BACK, 2, FACE_BACK, 0 },
(struct CubeTransition){ FACE_BACK, 5, FACE_BACK, 1 },
(struct CubeTransition){ FACE_BACK, 8, FACE_BACK, 2 },
(struct CubeTransition){ FACE_BACK, 1, FACE_BACK, 3 },
(struct CubeTransition){ FACE_BACK, 7, FACE_BACK, 5 },
(struct CubeTransition){ FACE_BACK, 0, FACE_BACK, 6 },
(struct CubeTransition){ FACE_BACK, 3, FACE_BACK, 7 },
(struct CubeTransition){ FACE_BACK, 6, FACE_BACK, 8 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_BOTTOM, 8 },
(struct CubeTransition){ FACE_RIGHT, 5, FACE_BOTTOM, 7 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_BOTTOM, 6 },
(struct CubeTransition){ FACE_TOP, 0, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_TOP, 1, FACE_RIGHT, 5 },
(struct CubeTransition){ FACE_TOP, 2, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_TOP, 0 },
(struct CubeTransition){ FACE_LEFT, 3, FACE_TOP, 1 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_TOP, 2 },
(struct CubeTransition){ FACE_BOTTOM, 8, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_BOTTOM, 7, FACE_LEFT, 3 },
(struct CubeTransition){ FACE_BOTTOM, 6, FACE_LEFT, 6 }
};
transition_cube(cube, transitions);
}
void lp(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_LEFT, 2, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_LEFT, 5, FACE_LEFT, 1 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_LEFT, 1, FACE_LEFT, 3 },
(struct CubeTransition){ FACE_LEFT, 7, FACE_LEFT, 5 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_LEFT, 3, FACE_LEFT, 7 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_TOP, 0, FACE_BACK, 0 },
(struct CubeTransition){ FACE_TOP, 3, FACE_BACK, 3 },
(struct CubeTransition){ FACE_TOP, 6, FACE_BACK, 6 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_TOP, 0 },
(struct CubeTransition){ FACE_FRONT, 3, FACE_TOP, 3 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_TOP, 6 },
(struct CubeTransition){ FACE_BOTTOM, 0, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_BOTTOM, 3, FACE_FRONT, 3 },
(struct CubeTransition){ FACE_BOTTOM, 6, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_BACK, 0, FACE_BOTTOM, 0 },
(struct CubeTransition){ FACE_BACK, 3, FACE_BOTTOM, 3 },
(struct CubeTransition){ FACE_BACK, 6, FACE_BOTTOM, 6 }
};
transition_cube(cube, transitions);
}
void rp(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_RIGHT, 2, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_RIGHT, 5, FACE_RIGHT, 1 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_RIGHT, 1, FACE_RIGHT, 3 },
(struct CubeTransition){ FACE_RIGHT, 7, FACE_RIGHT, 5 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_RIGHT, 3, FACE_RIGHT, 7 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_BACK, 2, FACE_TOP, 2 },
(struct CubeTransition){ FACE_BACK, 5, FACE_TOP, 5 },
(struct CubeTransition){ FACE_BACK, 8, FACE_TOP, 8 },
(struct CubeTransition){ FACE_BOTTOM, 2, FACE_BACK, 2 },
(struct CubeTransition){ FACE_BOTTOM, 5, FACE_BACK, 5 },
(struct CubeTransition){ FACE_BOTTOM, 8, FACE_BACK, 8 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_BOTTOM, 2 },
(struct CubeTransition){ FACE_FRONT, 5, FACE_BOTTOM, 5 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_BOTTOM, 8 },
(struct CubeTransition){ FACE_TOP, 2, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_TOP, 5, FACE_FRONT, 5 },
(struct CubeTransition){ FACE_TOP, 8, FACE_FRONT, 8 }
};
transition_cube(cube, transitions);
}
void u2(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_TOP, 0, FACE_TOP, 8 },
(struct CubeTransition){ FACE_TOP, 1, FACE_TOP, 7 },
(struct CubeTransition){ FACE_TOP, 2, FACE_TOP, 6 },
(struct CubeTransition){ FACE_TOP, 3, FACE_TOP, 5 },
(struct CubeTransition){ FACE_TOP, 5, FACE_TOP, 3 },
(struct CubeTransition){ FACE_TOP, 6, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 7, FACE_TOP, 1 },
(struct CubeTransition){ FACE_TOP, 8, FACE_TOP, 0 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_BACK, 8 },
(struct CubeTransition){ FACE_FRONT, 1, FACE_BACK, 7 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_BACK, 6 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_LEFT, 1, FACE_RIGHT, 1 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_BACK, 8, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_BACK, 7, FACE_FRONT, 1 },
(struct CubeTransition){ FACE_BACK, 6, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_RIGHT, 1, FACE_LEFT, 1 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_LEFT, 2 }
};
transition_cube(cube, transitions);
}
void d2(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_TOP, 0, FACE_TOP, 8 },
(struct CubeTransition){ FACE_TOP, 1, FACE_TOP, 7 },
(struct CubeTransition){ FACE_TOP, 2, FACE_TOP, 6 },
(struct CubeTransition){ FACE_TOP, 3, FACE_TOP, 5 },
(struct CubeTransition){ FACE_TOP, 5, FACE_TOP, 3 },
(struct CubeTransition){ FACE_TOP, 6, FACE_TOP, 2 },
(struct CubeTransition){ FACE_TOP, 7, FACE_TOP, 1 },
(struct CubeTransition){ FACE_TOP, 8, FACE_TOP, 0 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_BACK, 0 },
(struct CubeTransition){ FACE_FRONT, 7, FACE_BACK, 1 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_BACK, 2 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_RIGHT, 7, FACE_LEFT, 7 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_BACK, 0, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_BACK, 1, FACE_FRONT, 7 },
(struct CubeTransition){ FACE_BACK, 2, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_LEFT, 7, FACE_RIGHT, 7 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_RIGHT, 8 }
};
transition_cube(cube, transitions);
}
void f2(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_FRONT, 0, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_FRONT, 1, FACE_FRONT, 7 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_FRONT, 6 },
(struct CubeTransition){ FACE_FRONT, 3, FACE_FRONT, 5 },
(struct CubeTransition){ FACE_FRONT, 5, FACE_FRONT, 3 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_FRONT, 7, FACE_FRONT, 1 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_LEFT, 5, FACE_RIGHT, 3 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_TOP, 6, FACE_BOTTOM, 2 },
(struct CubeTransition){ FACE_TOP, 7, FACE_BOTTOM, 1 },
(struct CubeTransition){ FACE_TOP, 8, FACE_BOTTOM, 0 },
(struct CubeTransition){ FACE_RIGHT, 0, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_RIGHT, 3, FACE_LEFT, 5 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_BOTTOM, 2, FACE_TOP, 6 },
(struct CubeTransition){ FACE_BOTTOM, 1, FACE_TOP, 7 },
(struct CubeTransition){ FACE_BOTTOM, 0, FACE_TOP, 8 }
};
transition_cube(cube, transitions);
}
void b2(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_BACK, 0, FACE_BACK, 8 },
(struct CubeTransition){ FACE_BACK, 1, FACE_BACK, 7 },
(struct CubeTransition){ FACE_BACK, 2, FACE_BACK, 6 },
(struct CubeTransition){ FACE_BACK, 3, FACE_BACK, 5 },
(struct CubeTransition){ FACE_BACK, 5, FACE_BACK, 3 },
(struct CubeTransition){ FACE_BACK, 6, FACE_BACK, 2 },
(struct CubeTransition){ FACE_BACK, 7, FACE_BACK, 1 },
(struct CubeTransition){ FACE_BACK, 8, FACE_BACK, 0 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_RIGHT, 5, FACE_LEFT, 3 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_TOP, 0, FACE_BOTTOM, 8 },
(struct CubeTransition){ FACE_TOP, 1, FACE_BOTTOM, 7 },
(struct CubeTransition){ FACE_TOP, 2, FACE_BOTTOM, 6 },
(struct CubeTransition){ FACE_LEFT, 0, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_LEFT, 3, FACE_RIGHT, 5 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_BOTTOM, 8, FACE_TOP, 0 },
(struct CubeTransition){ FACE_BOTTOM, 7, FACE_TOP, 1 },
(struct CubeTransition){ FACE_BOTTOM, 6, FACE_TOP, 2 }
};
transition_cube(cube, transitions);
}
void l2(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_LEFT, 0, FACE_LEFT, 8 },
(struct CubeTransition){ FACE_LEFT, 1, FACE_LEFT, 7 },
(struct CubeTransition){ FACE_LEFT, 2, FACE_LEFT, 6 },
(struct CubeTransition){ FACE_LEFT, 3, FACE_LEFT, 5 },
(struct CubeTransition){ FACE_LEFT, 5, FACE_LEFT, 3 },
(struct CubeTransition){ FACE_LEFT, 6, FACE_LEFT, 2 },
(struct CubeTransition){ FACE_LEFT, 7, FACE_LEFT, 1 },
(struct CubeTransition){ FACE_LEFT, 8, FACE_LEFT, 0 },
(struct CubeTransition){ FACE_TOP, 0, FACE_BOTTOM, 0 },
(struct CubeTransition){ FACE_TOP, 3, FACE_BOTTOM, 3 },
(struct CubeTransition){ FACE_TOP, 6, FACE_BOTTOM, 6 },
(struct CubeTransition){ FACE_FRONT, 0, FACE_BACK, 0 },
(struct CubeTransition){ FACE_FRONT, 3, FACE_BACK, 3 },
(struct CubeTransition){ FACE_FRONT, 6, FACE_BACK, 6 },
(struct CubeTransition){ FACE_BOTTOM, 0, FACE_TOP, 0 },
(struct CubeTransition){ FACE_BOTTOM, 3, FACE_TOP, 3 },
(struct CubeTransition){ FACE_BOTTOM, 6, FACE_TOP, 6 },
(struct CubeTransition){ FACE_BACK, 0, FACE_FRONT, 0 },
(struct CubeTransition){ FACE_BACK, 3, FACE_FRONT, 3 },
(struct CubeTransition){ FACE_BACK, 6, FACE_FRONT, 6 }
};
transition_cube(cube, transitions);
}
void r2(struct Cube* cube) {
static struct CubeTransition transitions[TRANSITIONS_PER_ROTATION] = {
(struct CubeTransition){ FACE_RIGHT, 0, FACE_RIGHT, 8 },
(struct CubeTransition){ FACE_RIGHT, 1, FACE_RIGHT, 7 },
(struct CubeTransition){ FACE_RIGHT, 2, FACE_RIGHT, 6 },
(struct CubeTransition){ FACE_RIGHT, 3, FACE_RIGHT, 5 },
(struct CubeTransition){ FACE_RIGHT, 5, FACE_RIGHT, 3 },
(struct CubeTransition){ FACE_RIGHT, 6, FACE_RIGHT, 2 },
(struct CubeTransition){ FACE_RIGHT, 7, FACE_RIGHT, 1 },
(struct CubeTransition){ FACE_RIGHT, 8, FACE_RIGHT, 0 },
(struct CubeTransition){ FACE_BACK, 2, FACE_FRONT, 2 },
(struct CubeTransition){ FACE_BACK, 5, FACE_FRONT, 5 },
(struct CubeTransition){ FACE_BACK, 8, FACE_FRONT, 8 },
(struct CubeTransition){ FACE_BOTTOM, 2, FACE_TOP, 2 },
(struct CubeTransition){ FACE_BOTTOM, 5, FACE_TOP, 5 },
(struct CubeTransition){ FACE_BOTTOM, 8, FACE_TOP, 8 },
(struct CubeTransition){ FACE_FRONT, 2, FACE_BACK, 2 },
(struct CubeTransition){ FACE_FRONT, 5, FACE_BACK, 5 },
(struct CubeTransition){ FACE_FRONT, 8, FACE_BACK, 8 },
(struct CubeTransition){ FACE_TOP, 2, FACE_BOTTOM, 2 },
(struct CubeTransition){ FACE_TOP, 5, FACE_BOTTOM, 5 },
(struct CubeTransition){ FACE_TOP, 8, FACE_BOTTOM, 8 }
};
transition_cube(cube, transitions);
}