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

commit 2a8d66906dde19ffb7315fb3f60a396a71612037
parent 287f6c4067a206fb1c18eb779ef8463f06c0e5e1
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Fri, 27 Oct 2023 16:25:15 +0200

Small cleanup

Diffstat:
Msrc/cube.c | 26++------------------------
Msrc/cube.h | 81++++++++++++++++++++++++++++++++++++++++---------------------------------------
2 files changed, 43 insertions(+), 64 deletions(-)

diff --git a/src/cube.c b/src/cube.c @@ -152,30 +152,8 @@ static char *transstr[] = { }; cube_t solvedcube = { - .c = { - [_c_ufr] = _c_ufr, - [_c_ubl] = _c_ubl, - [_c_dfl] = _c_dfl, - [_c_dbr] = _c_dbr, - [_c_ufl] = _c_ufl, - [_c_ubr] = _c_ubr, - [_c_dfr] = _c_dfr, - [_c_dbl] = _c_dbl - }, - .e = { - [_e_uf] = _e_uf, - [_e_ub] = _e_ub, - [_e_db] = _e_db, - [_e_df] = _e_df, - [_e_ur] = _e_ur, - [_e_ul] = _e_ul, - [_e_dl] = _e_dl, - [_e_dr] = _e_dr, - [_e_fr] = _e_fr, - [_e_fl] = _e_fl, - [_e_bl] = _e_bl, - [_e_br] = _e_br - } + .c = {0, 1, 2, 3, 4, 5, 6, 7}, + .e = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} }; static cube_t errorcube = { .e = {0}, .c = {0} }; diff --git a/src/cube.h b/src/cube.h @@ -1,4 +1,44 @@ -/* Constants *****************************************************************/ +/* Types *********************************************************************/ + +/* TODO: ifdef for different implementations */ +/* See doc/CUBE_INTERNAL.md for a description of the cube format */ +typedef struct { + uint8_t c[8]; + uint8_t e[12]; +} cube_t; + +typedef uint8_t move_t; +typedef uint8_t trans_t; + +extern cube_t solvedcube; + +/* Functions *****************************************************************/ + +/* Not all formats are supported for both read and write. */ +/* See doc/CUBE_TEXT.md for details. */ +typedef enum {H48, SRC} format_t; +cube_t readcube(format_t, char *); +void writecube(format_t, cube_t, char *); + +bool issolvable(cube_t); +bool equal(cube_t, cube_t); +bool issolved(cube_t); +bool iserror(cube_t); + +int readmoves(char *, move_t *); +void writemoves(move_t *, int, char *); + +trans_t readtrans(char *); +void writetrans(trans_t, char *); + +cube_t move(cube_t, move_t); +cube_t inverse(cube_t); +cube_t compose(cube_t, cube_t); + +/* See doc/TRANSFORMATIONS.md for how transformations are applied */ +cube_t transform(cube_t, trans_t); + +/* Constants for moves and transformations ***********************************/ /* Standard moves */ #define U 0U @@ -76,42 +116,3 @@ #define errormove 99U #define errortrans 99U -/* Types *********************************************************************/ - -/* TODO: ifdef for different implementations */ -/* See doc/CUBE_INTERNAL.md for a description of the cube format */ -typedef struct { - uint8_t c[8]; - uint8_t e[12]; -} cube_t; - -typedef uint8_t move_t; -typedef uint8_t trans_t; - -extern cube_t solvedcube; - -/* Functions *****************************************************************/ - -/* Not all formats are supported for both read and write. */ -/* See doc/CUBE_TEXT.md for details. */ -typedef enum {H48, SRC} format_t; -cube_t readcube(format_t, char *); -void writecube(format_t, cube_t, char *); - -bool issolvable(cube_t); -bool equal(cube_t, cube_t); -bool issolved(cube_t); -bool iserror(cube_t); - -int readmoves(char *, move_t *); -void writemoves(move_t *, int, char *); - -trans_t readtrans(char *); -void writetrans(trans_t, char *); - -cube_t move(cube_t, move_t); -cube_t inverse(cube_t); -cube_t compose(cube_t, cube_t); - -/* See doc/TRANSFORMATIONS.md for how transformations are applied */ -cube_t transform(cube_t, trans_t);