aboutsummaryrefslogtreecommitdiff
path: root/src/alg.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-10-21 15:45:22 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2023-10-21 15:45:22 +0200
commit90fd8880f9f0db3f55335141d2f2799cea43b118 (patch)
treebcb8ebf35b16afc837925fc413529dc292577be7 /src/alg.c
parentc0fd8668f09d1024e2e765fc6d7be212a1708ef0 (diff)
downloadnissy-classic-90fd8880f9f0db3f55335141d2f2799cea43b118.tar.gz
nissy-classic-90fd8880f9f0db3f55335141d2f2799cea43b118.zip
Improved / fixed solution ordering
Diffstat (limited to '')
-rw-r--r--src/alg.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/alg.c b/src/alg.c
index 435954b..2b5b93f 100644
--- a/src/alg.c
+++ b/src/alg.c
@@ -15,7 +15,7 @@ static void realloc_alg(Alg *alg, int n);
15 15
16static int niss_type(Alg *a); 16static int niss_type(Alg *a);
17static void find_last_moves(Alg *a, bool inv, int *, int *, int *); 17static void find_last_moves(Alg *a, bool inv, int *, int *, int *);
18static int last_move_pair(Alg *a, bool inv); 18static int64_t last_move_pair(Alg *a, bool inv);
19static int compare_algs_firstmoves(Alg * a, Alg *b, bool inv); 19static int compare_algs_firstmoves(Alg * a, Alg *b, bool inv);
20static int compare_algs(const void * a, const void *b); 20static int compare_algs(const void * a, const void *b);
21 21
@@ -499,23 +499,28 @@ find_last_moves(Alg *a, bool inv, int *n, int *nlast, int *nslast)
499 } 499 }
500} 500}
501 501
502static int 502static int64_t
503last_move_pair(Alg *a, bool inv) 503last_move_pair(Alg *a, bool inv)
504{ 504{
505 /* The number of the move in the moves enum, or a higher number 505 /* Order: _ F*, _ B*, F* B*, ... U* D* */
506 * (working in base NMOVES) if the last two moves are parallel.
507 * -1 if there are no moves on the specified side of the alg.
508 */
509 506
510 int n, nlast, nslast; 507 static int bit[] = {
508 [F] = 16, [B] = 16,
509 [R] = 18, [L] = 18,
510 [U] = 20, [D] = 20
511 };
512 int n, nlast, nslast, last, slast;
511 513
512 find_last_moves(a, inv, &n, &nlast, &nslast); 514 find_last_moves(a, inv, &n, &nlast, &nslast);
513 515
514 if (n == 0) 516 if (n == 0)
515 return -1; 517 return -1;
516 if (nlast == 0 || !commute(a->move[nlast], a->move[nslast])) 518
517 return a->move[nlast]; 519 last = a->move[nlast];
518 return a->move[nlast] * NMOVES + a->move[nslast]; 520 slast = (nslast != -1 && commute(a->move[nlast], a->move[nslast])) ?
521 a->move[nslast] : 0;
522
523 return (slast * NMOVES + last) + (1LL << bit[base_move(last)]);
519} 524}
520 525
521static int 526static int

Generated with cgit - Back to sebastiano.tronto.net