nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit 4d4d6282431c50ce6066ffc796e9d1978cb91d83
parent 5cf4ca8743c0fc995d853a19f8b3a3c03dcfd3df
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Mon,  8 May 2023 19:07:20 +0200

Lowered number of moves for solving and tables

Diffstat:
Mbuild/build.c | 4++--
Msrc/coord.c | 8++++----
Msrc/coord.h | 4++--
Msrc/cube.c | 16++++++++--------
Msrc/cube.h | 3++-
5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/build/build.c b/build/build.c @@ -40,7 +40,7 @@ gen_coord_comp(Coordinate *coord) if (ui % 100000 == 0) fprintf(stderr, "\t(%" PRIu64 " done)\n", ui); indexers_makecube(coord->i, ui, &c); - for (m = 0; m < NMOVES; m++) { + for (m = 0; m < NMOVES_HTM; m++) { copy_cube(&c, &mvd); apply_move(m, &mvd); coord->mtable[m][ui] = indexers_getind(coord->i, &mvd); @@ -116,7 +116,7 @@ gen_coord_sym(Coordinate *coord) if (ui % 100000 == 0) fprintf(stderr, "\t(%" PRIu64 " done)\n", ui); uu = coord->symrep[ui]; - for (m = 0; m < NMOVES; m++) { + for (m = 0; m < NMOVES_HTM; m++) { uj = move_coord(coord->base[0], m, uu, NULL); coord->mtable[m][ui] = coord->symclass[uj]; coord->ttrep_move[m][ui] = coord->transtorep[uj]; diff --git a/src/coord.c b/src/coord.c @@ -81,7 +81,7 @@ alloc_mtable(Coordinate *coord) { Move m; - for (m = 0; m < NMOVES; m++) + for (m = 0; m < NMOVES_HTM; m++) coord->mtable[m] = malloc(coord->max * sizeof(uint64_t)); } @@ -90,7 +90,7 @@ alloc_ttrep_move(Coordinate *coord) { Move m; - for (m = 0; m < NMOVES; m++) + for (m = 0; m < NMOVES_HTM; m++) coord->ttrep_move[m] = malloc(coord->max * sizeof(Trans)); } @@ -121,7 +121,7 @@ copy_coord_mtable(Coordinate *coord, char *buf, Copier *copy) b = 0; rowsize = coord->max * sizeof(uint64_t); - for (m = 0; m < NMOVES; m++) { + for (m = 0; m < NMOVES_HTM; m++) { copy(coord->mtable[m], &buf[b], rowsize); b += rowsize; } @@ -137,7 +137,7 @@ copy_coord_ttrep_move(Coordinate *coord, char *buf, Copier *copy) b = 0; rowsize = coord->max * sizeof(Trans); - for (m = 0; m < NMOVES; m++) { + for (m = 0; m < NMOVES_HTM; m++) { copy(coord->ttrep_move[m], &buf[b], rowsize); b += rowsize; } diff --git a/src/coord.h b/src/coord.h @@ -13,7 +13,7 @@ typedef struct coordinate { char *name; CoordType type; uint64_t max; - uint64_t *mtable[NMOVES]; + uint64_t *mtable[NMOVES_HTM]; uint64_t *ttable[NTRANS]; TransGroup *tgrp; struct coordinate *base[2]; @@ -21,7 +21,7 @@ typedef struct coordinate { uint64_t *symclass; uint64_t *symrep; Trans *transtorep; - Trans *ttrep_move[NMOVES]; + Trans *ttrep_move[NMOVES_HTM]; bool generated; Indexer *i[99]; diff --git a/src/cube.c b/src/cube.c @@ -8,12 +8,12 @@ static Move read_move(char *, int *); static void init_moves(void); static void init_trans(void); -static Cube move_array[NMOVES]; -Move moves_ttable[NTRANS][NMOVES]; +static Cube move_array[NMOVES_ALL]; +Move moves_ttable[NTRANS][NMOVES_ALL]; Trans trans_ttable[NTRANS][NTRANS]; Trans trans_itable[NTRANS]; -static char move_string[NMOVES][7] = { +static char move_string[NMOVES_ALL][7] = { [NULLMOVE] = "-", [U] = "U", [U2] = "U2", [U3] = "U\'", [D] = "D", [D2] = "D2", [D3] = "D\'", @@ -231,7 +231,7 @@ read_move(char *str, int *i) Move j, m; char upper, lower, inv; - for (j = U; j < NMOVES; j++) { + for (j = U; j < NMOVES_ALL; j++) { upper = move_string[j][0]; lower = upper - ('A' - 'a'); if (str[*i] == upper || (str[*i] == lower && j <= B)) { @@ -408,7 +408,7 @@ init_moves(void) { /* Moves are represented as cubes and applied using compose(). * Every move is translated to a an <U, x, y> alg before filling * the transition tables. */ - char equiv_alg_string[100][NMOVES] = { + char equiv_alg_string[100][NMOVES_ALL] = { [NULLMOVE] = "", [U] = " U ", @@ -493,7 +493,7 @@ init_moves(void) { move_array[x] = mcx; move_array[y] = mcy; - for (m = 0; m < NMOVES; m++) { + for (m = 0; m < NMOVES_ALL; m++) { switch (m) { case NULLMOVE: make_solved(&move_array[m]); @@ -517,11 +517,11 @@ init_trans(void) { Trans t, u, v; for (t = 0; t < NTRANS; t++) { - for (mi = 0; mi < NMOVES; mi++) { + for (mi = 0; mi < NMOVES_ALL; mi++) { make_solved(&aux); apply_move(mi, &aux); apply_trans(t, &aux); - for (move = 0; move < NMOVES; move++) { + for (move = 0; move < NMOVES_ALL; move++) { copy_cube(&aux, &cube); apply_move(inverse_move(move), &cube); if (is_solved(&cube)) { diff --git a/src/cube.h b/src/cube.h @@ -1,4 +1,5 @@ -#define NMOVES 55 +#define NMOVES_ALL 55 +#define NMOVES_HTM 19 #define NTRANS 48 #define MAX_ALG_LEN 22 #define MIN(a,b) (((a) < (b)) ? (a) : (b))