nissy-classic

Stable branch of nissy
git clone https://git.tronto.net/nissy-classic
Download | Log | Files | Refs | README | LICENSE

commit 90fd8880f9f0db3f55335141d2f2799cea43b118
parent c0fd8668f09d1024e2e765fc6d7be212a1708ef0
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sat, 21 Oct 2023 15:45:22 +0200

Improved / fixed solution ordering

Diffstat:
Msrc/alg.c | 25+++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/alg.c b/src/alg.c @@ -15,7 +15,7 @@ static void realloc_alg(Alg *alg, int n); static int niss_type(Alg *a); static void find_last_moves(Alg *a, bool inv, int *, int *, int *); -static int last_move_pair(Alg *a, bool inv); +static int64_t last_move_pair(Alg *a, bool inv); static int compare_algs_firstmoves(Alg * a, Alg *b, bool inv); static int compare_algs(const void * a, const void *b); @@ -499,23 +499,28 @@ find_last_moves(Alg *a, bool inv, int *n, int *nlast, int *nslast) } } -static int +static int64_t last_move_pair(Alg *a, bool inv) { - /* The number of the move in the moves enum, or a higher number - * (working in base NMOVES) if the last two moves are parallel. - * -1 if there are no moves on the specified side of the alg. - */ + /* Order: _ F*, _ B*, F* B*, ... U* D* */ - int n, nlast, nslast; + static int bit[] = { + [F] = 16, [B] = 16, + [R] = 18, [L] = 18, + [U] = 20, [D] = 20 + }; + int n, nlast, nslast, last, slast; find_last_moves(a, inv, &n, &nlast, &nslast); if (n == 0) return -1; - if (nlast == 0 || !commute(a->move[nlast], a->move[nslast])) - return a->move[nlast]; - return a->move[nlast] * NMOVES + a->move[nslast]; + + last = a->move[nlast]; + slast = (nslast != -1 && commute(a->move[nlast], a->move[nslast])) ? + a->move[nslast] : 0; + + return (slast * NMOVES + last) + (1LL << bit[base_move(last)]); } static int