diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-11-23 16:16:31 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-11-24 16:32:11 +0100 |
| commit | 147b0c3c4615c32478a4923242909b8ae5a30d03 (patch) | |
| tree | 5294d9b3655031535085a5163c2c5b5cbe7413b1 /test/140_appendsolution | |
| parent | 78ec0d22d927bc4287aa090469d5ba5f84e8780b (diff) | |
| download | nissy-core-147b0c3c4615c32478a4923242909b8ae5a30d03.tar.gz nissy-core-147b0c3c4615c32478a4923242909b8ae5a30d03.zip | |
Fix duplicate solutions, overflow in maxsols and improve symmetry reduction for H48.
This commit fixes two bugs:
- A bug that caused duplicates solutions for symmetric scrambles.
- An overflow in the maxsols parameter for the H48 solver, which
caused it to find much fewer solutions than existed.
Moreover, the H48 solvers has been improved by reducing by symmetry not
only from the starting position, but also up to the first 4 moves.
Diffstat (limited to 'test/140_appendsolution')
| -rw-r--r-- | test/140_appendsolution/00_empty.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/01_simple_onlynormal_nounniss.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/02_simple_onlynormal_nounnis_multitrans.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/03_simple_unniss.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/04_niss_nounniss.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/05_sort_parallel.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/06_unniss_trans_sort.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/07_unniss_cancel_nosol.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/08_unniss_cancel_nosol_v2.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/09_fullinverse_niss.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/10_rotated.in | 1 | ||||
| -rw-r--r-- | test/140_appendsolution/11_multisym.in | 10 | ||||
| -rw-r--r-- | test/140_appendsolution/11_multisym.out | 7 | ||||
| -rw-r--r-- | test/140_appendsolution/appendsolution_tests.c | 26 |
14 files changed, 45 insertions, 9 deletions
diff --git a/test/140_appendsolution/00_empty.in b/test/140_appendsolution/00_empty.in index 1100b95..00546ef 100644 --- a/test/140_appendsolution/00_empty.in +++ b/test/140_appendsolution/00_empty.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | 1 | ||
| 2 | 0 | 2 | 0 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/01_simple_onlynormal_nounniss.in b/test/140_appendsolution/01_simple_onlynormal_nounniss.in index fb1eaed..84d16c0 100644 --- a/test/140_appendsolution/01_simple_onlynormal_nounniss.in +++ b/test/140_appendsolution/01_simple_onlynormal_nounniss.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | U F R D2 B' | 1 | U F R D2 B' |
| 2 | 0 | 2 | 0 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/02_simple_onlynormal_nounnis_multitrans.in b/test/140_appendsolution/02_simple_onlynormal_nounnis_multitrans.in index db5f074..15ff39e 100644 --- a/test/140_appendsolution/02_simple_onlynormal_nounnis_multitrans.in +++ b/test/140_appendsolution/02_simple_onlynormal_nounnis_multitrans.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | U F R | 1 | U F R |
| 2 | 0 | 2 | 0 |
| 3 | 1 | ||
| 3 | 4 | 4 | 4 |
| 4 | rotation UF | 5 | rotation UF |
| 5 | mirrored UR | 6 | mirrored UR |
diff --git a/test/140_appendsolution/03_simple_unniss.in b/test/140_appendsolution/03_simple_unniss.in index 2c5a331..ac6fe72 100644 --- a/test/140_appendsolution/03_simple_unniss.in +++ b/test/140_appendsolution/03_simple_unniss.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | U F B2 (R' F D) | 1 | U F B2 (R' F D) |
| 2 | 1 | 2 | 1 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/04_niss_nounniss.in b/test/140_appendsolution/04_niss_nounniss.in index b07f970..cae1328 100644 --- a/test/140_appendsolution/04_niss_nounniss.in +++ b/test/140_appendsolution/04_niss_nounniss.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | U F B2 (R' F D) | 1 | U F B2 (R' F D) |
| 2 | 0 | 2 | 0 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/05_sort_parallel.in b/test/140_appendsolution/05_sort_parallel.in index bc1cf0f..85351b5 100644 --- a/test/140_appendsolution/05_sort_parallel.in +++ b/test/140_appendsolution/05_sort_parallel.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | L R' B2 F | 1 | L R' B2 F |
| 2 | 0 | 2 | 0 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/06_unniss_trans_sort.in b/test/140_appendsolution/06_unniss_trans_sort.in index 2ffab93..e6b7897 100644 --- a/test/140_appendsolution/06_unniss_trans_sort.in +++ b/test/140_appendsolution/06_unniss_trans_sort.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | B (R2 F2) | 1 | B (R2 F2) |
| 2 | 1 | 2 | 1 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UR | 5 | rotation UR |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/07_unniss_cancel_nosol.in b/test/140_appendsolution/07_unniss_cancel_nosol.in index 6883d05..4faed6b 100644 --- a/test/140_appendsolution/07_unniss_cancel_nosol.in +++ b/test/140_appendsolution/07_unniss_cancel_nosol.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | B' F (R2 B2) | 1 | B' F (R2 B2) |
| 2 | 1 | 2 | 1 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/08_unniss_cancel_nosol_v2.in b/test/140_appendsolution/08_unniss_cancel_nosol_v2.in index 3d461f0..741687a 100644 --- a/test/140_appendsolution/08_unniss_cancel_nosol_v2.in +++ b/test/140_appendsolution/08_unniss_cancel_nosol_v2.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | F' B (R2 F2) | 1 | F' B (R2 F2) |
| 2 | 1 | 2 | 1 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/09_fullinverse_niss.in b/test/140_appendsolution/09_fullinverse_niss.in index bb2b640..e2e5f7b 100644 --- a/test/140_appendsolution/09_fullinverse_niss.in +++ b/test/140_appendsolution/09_fullinverse_niss.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | (F) | 1 | (F) |
| 2 | 0 | 2 | 0 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 0 | 6 | 0 |
diff --git a/test/140_appendsolution/10_rotated.in b/test/140_appendsolution/10_rotated.in index 5210cd5..947696f 100644 --- a/test/140_appendsolution/10_rotated.in +++ b/test/140_appendsolution/10_rotated.in | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | U2 F B L' | 1 | U2 F B L' |
| 2 | 1 | 2 | 1 |
| 3 | 1 | 3 | 1 |
| 4 | 1 | ||
| 4 | rotation UF | 5 | rotation UF |
| 5 | 7 | 6 | 7 |
diff --git a/test/140_appendsolution/11_multisym.in b/test/140_appendsolution/11_multisym.in new file mode 100644 index 0000000..947127f --- /dev/null +++ b/test/140_appendsolution/11_multisym.in | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | L U F | ||
| 2 | 0 | ||
| 3 | 2 | ||
| 4 | 2 | ||
| 5 | rotation UF | ||
| 6 | rotation UB | ||
| 7 | 2 | ||
| 8 | rotation UF | ||
| 9 | rotation DR | ||
| 10 | 0 | ||
diff --git a/test/140_appendsolution/11_multisym.out b/test/140_appendsolution/11_multisym.out new file mode 100644 index 0000000..9f1a312 --- /dev/null +++ b/test/140_appendsolution/11_multisym.out | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | L U F | ||
| 2 | L D R | ||
| 3 | R U B | ||
| 4 | R D L | ||
| 5 | Number of solutions: 4 | ||
| 6 | Shortest solution length: 3 | ||
| 7 | Used bytes: 24 | ||
diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c index d4c2a1f..f9620ab 100644 --- a/test/140_appendsolution/appendsolution_tests.c +++ b/test/140_appendsolution/appendsolution_tests.c | |||
| @@ -3,8 +3,10 @@ Input format for appendsolution tests: | |||
| 3 | 3 | ||
| 4 | moves on normal (with NISS notation) | 4 | moves on normal (with NISS notation) |
| 5 | unniss flag (0=false, 1=true) | 5 | unniss flag (0=false, 1=true) |
| 6 | number of transformations | 6 | n = maximum number of moves for transformations + 1 (at most 20) |
| 7 | transformations, one per line | 7 | n times the following: |
| 8 | number of transformations | ||
| 9 | transformations, one per line | ||
| 8 | the orientation of the cube, as a number from 0 to 23 | 10 | the orientation of the cube, as a number from 0 to 23 |
| 9 | 11 | ||
| 10 | See below for the output format. | 12 | See below for the output format. |
| @@ -18,11 +20,13 @@ int64_t readmoves(const char *, size_t n, size_t m, | |||
| 18 | void solution_moves_reset(solution_moves_t [static 1]); | 20 | void solution_moves_reset(solution_moves_t [static 1]); |
| 19 | bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); | 21 | bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); |
| 20 | int64_t appendsolution(const solution_moves_t [static 1], | 22 | int64_t appendsolution(const solution_moves_t [static 1], |
| 21 | const solution_settings_t [static 1], solution_list_t [static 1]); | 23 | size_t, const uint64_t *, const solution_settings_t [static 1], |
| 24 | solution_list_t [static 1]); | ||
| 22 | 25 | ||
| 23 | void run(void) { | 26 | void run(void) { |
| 24 | int i, ntrans; | 27 | int i, j, nnt, ntrans; |
| 25 | int64_t tot; | 28 | int64_t tot; |
| 29 | uint64_t tmask[20]; | ||
| 26 | size_t nm, np; | 30 | size_t nm, np; |
| 27 | char str[STRLENMAX], buf[STRLENMAX]; | 31 | char str[STRLENMAX], buf[STRLENMAX]; |
| 28 | solution_moves_t moves; | 32 | solution_moves_t moves; |
| @@ -32,7 +36,6 @@ void run(void) { | |||
| 32 | solution_moves_reset(&moves); | 36 | solution_moves_reset(&moves); |
| 33 | solution_list_init(&list, STRLENMAX, buf); | 37 | solution_list_init(&list, STRLENMAX, buf); |
| 34 | settings = (solution_settings_t) { | 38 | settings = (solution_settings_t) { |
| 35 | .tmask = UINT64_C(0), | ||
| 36 | .unniss = false, | 39 | .unniss = false, |
| 37 | .maxmoves = 20, | 40 | .maxmoves = 20, |
| 38 | .maxsolutions = 100, | 41 | .maxsolutions = 100, |
| @@ -49,16 +52,21 @@ void run(void) { | |||
| 49 | moves.npremoves = np; | 52 | moves.npremoves = np; |
| 50 | fgets(str, STRLENMAX, stdin); | 53 | fgets(str, STRLENMAX, stdin); |
| 51 | settings.unniss = (bool)atoi(str); | 54 | settings.unniss = (bool)atoi(str); |
| 55 | |||
| 52 | fgets(str, STRLENMAX, stdin); | 56 | fgets(str, STRLENMAX, stdin); |
| 53 | ntrans = atoi(str); | 57 | nnt = atoi(str); |
| 54 | for (i = 0; i < ntrans; i++) { | 58 | for (j = 0; j < nnt; j++) { |
| 55 | fgets(str, STRLENMAX, stdin); | 59 | fgets(str, STRLENMAX, stdin); |
| 56 | settings.tmask |= UINT64_C(1) << (uint64_t)readtrans(str); | 60 | ntrans = atoi(str); |
| 61 | for (i = 0; i < ntrans; i++) { | ||
| 62 | fgets(str, STRLENMAX, stdin); | ||
| 63 | tmask[j] |= UINT64_C(1) << (uint64_t)readtrans(str); | ||
| 64 | } | ||
| 57 | } | 65 | } |
| 58 | fgets(str, STRLENMAX, stdin); | 66 | fgets(str, STRLENMAX, stdin); |
| 59 | settings.orientation = atoi(str); | 67 | settings.orientation = atoi(str); |
| 60 | 68 | ||
| 61 | appendsolution(&moves, &settings, &list); | 69 | appendsolution(&moves, nnt, tmask, &settings, &list); |
| 62 | 70 | ||
| 63 | printf("%s", list.buf); | 71 | printf("%s", list.buf); |
| 64 | printf("Number of solutions: %" PRIu64 "\n", list.nsols); | 72 | printf("Number of solutions: %" PRIu64 "\n", list.nsols); |
