diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-17 07:57:18 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-17 07:57:18 +0200 |
| commit | 5e741a00a1350477c7d8778cb466c8efa27b152d (patch) | |
| tree | 37d3ab4b00f1b735f5da3b8f0065f1f19e920678 | |
| parent | 37dc364aaf751a14ff8c7e74e6bae59128c558df (diff) | |
| download | nissy-core-5e741a00a1350477c7d8778cb466c8efa27b152d.tar.gz nissy-core-5e741a00a1350477c7d8778cb466c8efa27b152d.zip | |
Working drslice (same results as nissy-classic)
Diffstat (limited to '')
| -rw-r--r-- | src/arch/arch.h | 3 | ||||
| -rw-r--r-- | src/arch/coordinates_unoptimized.h | 55 | ||||
| -rw-r--r-- | src/solvers/coord/common.h | 6 | ||||
| -rw-r--r-- | src/solvers/coord/coord.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/drslice.h | 129 | ||||
| -rw-r--r-- | src/solvers/coord/list.h | 1 |
6 files changed, 195 insertions, 0 deletions
diff --git a/src/arch/arch.h b/src/arch/arch.h index a9f6e03..2c418a6 100644 --- a/src/arch/arch.h +++ b/src/arch/arch.h | |||
| @@ -7,6 +7,7 @@ typedef __m256i cube_t; | |||
| 7 | #if !defined(TEST_H) | 7 | #if !defined(TEST_H) |
| 8 | #include "common.h" | 8 | #include "common.h" |
| 9 | #include "avx2.h" | 9 | #include "avx2.h" |
| 10 | #include "coordinates_unoptimized.h" | ||
| 10 | #endif | 11 | #endif |
| 11 | 12 | ||
| 12 | #elif defined(NEON) | 13 | #elif defined(NEON) |
| @@ -22,6 +23,7 @@ typedef struct { | |||
| 22 | #if !defined(TEST_H) | 23 | #if !defined(TEST_H) |
| 23 | #include "common.h" | 24 | #include "common.h" |
| 24 | #include "neon.h" | 25 | #include "neon.h" |
| 26 | #include "coordinates_unoptimized.h" | ||
| 25 | #endif | 27 | #endif |
| 26 | 28 | ||
| 27 | #else | 29 | #else |
| @@ -36,6 +38,7 @@ typedef struct { | |||
| 36 | #if !defined(TEST_H) | 38 | #if !defined(TEST_H) |
| 37 | #include "common.h" | 39 | #include "common.h" |
| 38 | #include "portable.h" | 40 | #include "portable.h" |
| 41 | #include "coordinates_unoptimized.h" | ||
| 39 | #endif | 42 | #endif |
| 40 | 43 | ||
| 41 | #endif | 44 | #endif |
diff --git a/src/arch/coordinates_unoptimized.h b/src/arch/coordinates_unoptimized.h new file mode 100644 index 0000000..c553b2b --- /dev/null +++ b/src/arch/coordinates_unoptimized.h | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | STATIC_INLINE int64_t coord_cp(cube_t); | ||
| 2 | STATIC_INLINE cube_t invcoord_cp(int64_t); | ||
| 3 | STATIC_INLINE int64_t coord_epud(cube_t); | ||
| 4 | STATIC_INLINE cube_t invcoord_epud(int64_t); | ||
| 5 | |||
| 6 | STATIC_INLINE int64_t | ||
| 7 | coord_cp(cube_t cube) | ||
| 8 | { | ||
| 9 | int i; | ||
| 10 | uint8_t c[8], e[12]; | ||
| 11 | |||
| 12 | pieces(&cube, c, e); | ||
| 13 | for (i = 0; i < 8; i++) | ||
| 14 | c[i] &= PBITS; | ||
| 15 | |||
| 16 | return permtoindex(8, c); | ||
| 17 | } | ||
| 18 | |||
| 19 | STATIC_INLINE cube_t | ||
| 20 | invcoord_cp(int64_t i) | ||
| 21 | { | ||
| 22 | uint8_t c[8]; | ||
| 23 | |||
| 24 | indextoperm(i, 8, c); | ||
| 25 | |||
| 26 | return STATIC_CUBE(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], | ||
| 27 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); | ||
| 28 | } | ||
| 29 | |||
| 30 | STATIC_INLINE int64_t | ||
| 31 | coord_epud(cube_t cube) | ||
| 32 | { | ||
| 33 | int i; | ||
| 34 | uint8_t c[8], e[12]; | ||
| 35 | |||
| 36 | pieces(&cube, c, e); | ||
| 37 | DBG_ASSERT(isperm(8, e), -1, | ||
| 38 | "Cannot compute epud coordinate: edges not separated"); | ||
| 39 | |||
| 40 | for (i = 0; i < 8; i++) | ||
| 41 | e[i] &= PBITS; | ||
| 42 | |||
| 43 | return permtoindex(8, e); | ||
| 44 | } | ||
| 45 | |||
| 46 | STATIC_INLINE cube_t | ||
| 47 | invcoord_epud(int64_t i) | ||
| 48 | { | ||
| 49 | uint8_t e[8]; | ||
| 50 | |||
| 51 | indextoperm(i, 8, e); | ||
| 52 | |||
| 53 | return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7, | ||
| 54 | e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], 8, 9, 10, 11); | ||
| 55 | } | ||
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index c512b33..d000ce9 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -160,6 +160,12 @@ solution_lastqt_cw(const solution_moves_t s[static 1]) | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | STATIC bool | 162 | STATIC bool |
| 163 | solution_always_valid(const solution_moves_t s[static 1]) | ||
| 164 | { | ||
| 165 | return true; | ||
| 166 | } | ||
| 167 | |||
| 168 | STATIC bool | ||
| 163 | coord_can_switch( | 169 | coord_can_switch( |
| 164 | const coord_t coord[static 1], | 170 | const coord_t coord[static 1], |
| 165 | const unsigned char *data, | 171 | const unsigned char *data, |
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h index da93439..7716078 100644 --- a/src/solvers/coord/coord.h +++ b/src/solvers/coord/coord.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include "eo.h" | 3 | #include "eo.h" |
| 4 | #include "dr.h" | 4 | #include "dr.h" |
| 5 | #include "dreo.h" | 5 | #include "dreo.h" |
| 6 | #include "drslice.h" | ||
| 6 | #include "list.h" | 7 | #include "list.h" |
| 7 | #include "utils.h" | 8 | #include "utils.h" |
| 8 | #include "gendata.h" | 9 | #include "gendata.h" |
diff --git a/src/solvers/coord/drslice.h b/src/solvers/coord/drslice.h new file mode 100644 index 0000000..63aaa88 --- /dev/null +++ b/src/solvers/coord/drslice.h | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | #define CLASSES_CP_16 2768 | ||
| 2 | |||
| 3 | STATIC uint64_t coordinate_cp_coord(cube_t); | ||
| 4 | STATIC cube_t coordinate_cp_cube(uint64_t); | ||
| 5 | STATIC uint64_t coordinate_epud_coord(cube_t); | ||
| 6 | STATIC cube_t coordinate_epud_cube(uint64_t); | ||
| 7 | STATIC cube_t coordinate_drslice_merge(cube_t, cube_t); | ||
| 8 | |||
| 9 | STATIC uint64_t coordinate_drslice_coord(cube_t, const unsigned char *); | ||
| 10 | STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *); | ||
| 11 | STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *); | ||
| 12 | STATIC size_t coordinate_drslice_gendata(unsigned char *); | ||
| 13 | |||
| 14 | STATIC bool is_drslice_solvable(cube_t); | ||
| 15 | |||
| 16 | STATIC coord_t coordinate_drslice = { | ||
| 17 | .name = "DRSLICE", | ||
| 18 | .coord = &coordinate_drslice_coord, | ||
| 19 | .cube = &coordinate_drslice_cube, | ||
| 20 | .isnasty = &coordinate_drslice_isnasty, | ||
| 21 | .gendata = coordinate_drslice_gendata, | ||
| 22 | .max = CLASSES_CP_16 * FACT_8, | ||
| 23 | .trans_mask = TM_UDFIX, | ||
| 24 | .moves_mask = MM18_DR, | ||
| 25 | .axistrans = { | ||
| 26 | [AXIS_UD] = TRANS_UFr, | ||
| 27 | [AXIS_RL] = TRANS_RFr, | ||
| 28 | [AXIS_FB] = TRANS_FDr, | ||
| 29 | }, | ||
| 30 | .is_admissible = &solution_always_valid, | ||
| 31 | .is_solvable = &is_drslice_solvable, | ||
| 32 | .pruning_distribution = { | ||
| 33 | /* TODO: copied from nissy-classic, to be verified */ | ||
| 34 | [0] = 1, | ||
| 35 | [1] = 3, | ||
| 36 | [2] = 10, | ||
| 37 | [3] = 52, | ||
| 38 | [4] = 285, | ||
| 39 | [5] = 1318, | ||
| 40 | [6] = 5671, | ||
| 41 | [7] = 26502, | ||
| 42 | [8] = 115467, | ||
| 43 | [9] = 470846, | ||
| 44 | [10] = 1853056, | ||
| 45 | [11] = 6535823, | ||
| 46 | [12] = 18349792, | ||
| 47 | [13] = 32843350, | ||
| 48 | [14] = 34118883, | ||
| 49 | [15] = 0, /* TODO: unknown, why does nissy-classic not have | ||
| 50 | have this value? */ | ||
| 51 | }, | ||
| 52 | .pruning_max = 15, /* TODO - either 14 or 15 */ | ||
| 53 | .sym = { | ||
| 54 | .classes = CLASSES_CP_16, | ||
| 55 | .max = FACT_8, | ||
| 56 | .coord = &coordinate_cp_coord, | ||
| 57 | .cube = &coordinate_cp_cube, | ||
| 58 | .max2 = FACT_8, | ||
| 59 | .coord2 = &coordinate_epud_coord, | ||
| 60 | .cube2 = &coordinate_epud_cube, | ||
| 61 | .merge = &coordinate_drslice_merge, | ||
| 62 | }, | ||
| 63 | }; | ||
| 64 | |||
| 65 | STATIC uint64_t | ||
| 66 | coordinate_cp_coord(cube_t c) | ||
| 67 | { | ||
| 68 | return coord_cp(c); | ||
| 69 | } | ||
| 70 | |||
| 71 | STATIC cube_t | ||
| 72 | coordinate_cp_cube(uint64_t i) | ||
| 73 | { | ||
| 74 | return invcoord_cp(i); | ||
| 75 | } | ||
| 76 | |||
| 77 | STATIC uint64_t | ||
| 78 | coordinate_epud_coord(cube_t c) | ||
| 79 | { | ||
| 80 | return coord_epud(c); | ||
| 81 | } | ||
| 82 | |||
| 83 | STATIC cube_t | ||
| 84 | coordinate_epud_cube(uint64_t i) | ||
| 85 | { | ||
| 86 | return invcoord_epud(i); | ||
| 87 | } | ||
| 88 | |||
| 89 | STATIC cube_t | ||
| 90 | coordinate_drslice_merge(cube_t c1, cube_t c2) | ||
| 91 | { | ||
| 92 | cube_t merged; | ||
| 93 | |||
| 94 | merged = c1; | ||
| 95 | copy_edges(&merged, c2); | ||
| 96 | |||
| 97 | return merged; | ||
| 98 | } | ||
| 99 | |||
| 100 | STATIC uint64_t | ||
| 101 | coordinate_drslice_coord(cube_t cube, const unsigned char *data) | ||
| 102 | { | ||
| 103 | return coord_coord_generic(&coordinate_drslice, cube, data); | ||
| 104 | } | ||
| 105 | |||
| 106 | STATIC cube_t | ||
| 107 | coordinate_drslice_cube(uint64_t i, const unsigned char *data) | ||
| 108 | { | ||
| 109 | return coord_cube_generic(&coordinate_drslice, i, data); | ||
| 110 | } | ||
| 111 | |||
| 112 | STATIC bool | ||
| 113 | coordinate_drslice_isnasty(uint64_t i, const unsigned char *data) | ||
| 114 | { | ||
| 115 | return coord_isnasty_generic(&coordinate_drslice, i, data); | ||
| 116 | } | ||
| 117 | |||
| 118 | STATIC size_t | ||
| 119 | coordinate_drslice_gendata(unsigned char *data) | ||
| 120 | { | ||
| 121 | return coord_gendata_generic(&coordinate_drslice, data); | ||
| 122 | } | ||
| 123 | |||
| 124 | STATIC bool | ||
| 125 | is_drslice_solvable(cube_t cube) { | ||
| 126 | return coord_eo(cube) == 0 && | ||
| 127 | coord_eo(transform_edges(cube, TRANS_URr)) == 0 && | ||
| 128 | coord_co(cube) == 0; | ||
| 129 | } | ||
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h index 9409bb6..3badc8f 100644 --- a/src/solvers/coord/list.h +++ b/src/solvers/coord/list.h | |||
| @@ -2,5 +2,6 @@ coord_t *all_coordinates[] = { | |||
| 2 | &coordinate_eo, | 2 | &coordinate_eo, |
| 3 | &coordinate_dr, | 3 | &coordinate_dr, |
| 4 | &coordinate_dreo, | 4 | &coordinate_dreo, |
| 5 | &coordinate_drslice, | ||
| 5 | NULL | 6 | NULL |
| 6 | }; | 7 | }; |
