diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-21 15:45:22 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-21 15:45:22 +0200 |
| commit | 90fd8880f9f0db3f55335141d2f2799cea43b118 (patch) | |
| tree | bcb8ebf35b16afc837925fc413529dc292577be7 /src/alg.c | |
| parent | c0fd8668f09d1024e2e765fc6d7be212a1708ef0 (diff) | |
| download | nissy-classic-90fd8880f9f0db3f55335141d2f2799cea43b118.tar.gz nissy-classic-90fd8880f9f0db3f55335141d2f2799cea43b118.zip | |
Improved / fixed solution ordering
Diffstat (limited to '')
| -rw-r--r-- | src/alg.c | 25 |
1 files changed, 15 insertions, 10 deletions
| @@ -15,7 +15,7 @@ static void realloc_alg(Alg *alg, int n); | |||
| 15 | 15 | ||
| 16 | static int niss_type(Alg *a); | 16 | static int niss_type(Alg *a); |
| 17 | static void find_last_moves(Alg *a, bool inv, int *, int *, int *); | 17 | static void find_last_moves(Alg *a, bool inv, int *, int *, int *); |
| 18 | static int last_move_pair(Alg *a, bool inv); | 18 | static int64_t last_move_pair(Alg *a, bool inv); |
| 19 | static int compare_algs_firstmoves(Alg * a, Alg *b, bool inv); | 19 | static int compare_algs_firstmoves(Alg * a, Alg *b, bool inv); |
| 20 | static int compare_algs(const void * a, const void *b); | 20 | static 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 | ||
| 502 | static int | 502 | static int64_t |
| 503 | last_move_pair(Alg *a, bool inv) | 503 | last_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 | ||
| 521 | static int | 526 | static int |
