nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

commit 5e741a00a1350477c7d8778cb466c8efa27b152d
parent 37dc364aaf751a14ff8c7e74e6bae59128c558df
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Thu, 17 Jul 2025 07:57:18 +0200

Working drslice (same results as nissy-classic)

Diffstat:
Msrc/arch/arch.h | 3+++
Asrc/arch/coordinates_unoptimized.h | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/solvers/coord/common.h | 6++++++
Msrc/solvers/coord/coord.h | 1+
Asrc/solvers/coord/drslice.h | 129+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/solvers/coord/list.h | 1+
6 files changed, 195 insertions(+), 0 deletions(-)

diff --git a/src/arch/arch.h b/src/arch/arch.h @@ -7,6 +7,7 @@ typedef __m256i cube_t; #if !defined(TEST_H) #include "common.h" #include "avx2.h" +#include "coordinates_unoptimized.h" #endif #elif defined(NEON) @@ -22,6 +23,7 @@ typedef struct { #if !defined(TEST_H) #include "common.h" #include "neon.h" +#include "coordinates_unoptimized.h" #endif #else @@ -36,6 +38,7 @@ typedef struct { #if !defined(TEST_H) #include "common.h" #include "portable.h" +#include "coordinates_unoptimized.h" #endif #endif diff --git a/src/arch/coordinates_unoptimized.h b/src/arch/coordinates_unoptimized.h @@ -0,0 +1,55 @@ +STATIC_INLINE int64_t coord_cp(cube_t); +STATIC_INLINE cube_t invcoord_cp(int64_t); +STATIC_INLINE int64_t coord_epud(cube_t); +STATIC_INLINE cube_t invcoord_epud(int64_t); + +STATIC_INLINE int64_t +coord_cp(cube_t cube) +{ + int i; + uint8_t c[8], e[12]; + + pieces(&cube, c, e); + for (i = 0; i < 8; i++) + c[i] &= PBITS; + + return permtoindex(8, c); +} + +STATIC_INLINE cube_t +invcoord_cp(int64_t i) +{ + uint8_t c[8]; + + indextoperm(i, 8, c); + + return STATIC_CUBE(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); +} + +STATIC_INLINE int64_t +coord_epud(cube_t cube) +{ + int i; + uint8_t c[8], e[12]; + + pieces(&cube, c, e); + DBG_ASSERT(isperm(8, e), -1, + "Cannot compute epud coordinate: edges not separated"); + + for (i = 0; i < 8; i++) + e[i] &= PBITS; + + return permtoindex(8, e); +} + +STATIC_INLINE cube_t +invcoord_epud(int64_t i) +{ + uint8_t e[8]; + + indextoperm(i, 8, e); + + return STATIC_CUBE(0, 1, 2, 3, 4, 5, 6, 7, + e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], 8, 9, 10, 11); +} diff --git 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]) } STATIC bool +solution_always_valid(const solution_moves_t s[static 1]) +{ + return true; +} + +STATIC bool coord_can_switch( const coord_t coord[static 1], const unsigned char *data, diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h @@ -3,6 +3,7 @@ #include "eo.h" #include "dr.h" #include "dreo.h" +#include "drslice.h" #include "list.h" #include "utils.h" #include "gendata.h" diff --git a/src/solvers/coord/drslice.h b/src/solvers/coord/drslice.h @@ -0,0 +1,129 @@ +#define CLASSES_CP_16 2768 + +STATIC uint64_t coordinate_cp_coord(cube_t); +STATIC cube_t coordinate_cp_cube(uint64_t); +STATIC uint64_t coordinate_epud_coord(cube_t); +STATIC cube_t coordinate_epud_cube(uint64_t); +STATIC cube_t coordinate_drslice_merge(cube_t, cube_t); + +STATIC uint64_t coordinate_drslice_coord(cube_t, const unsigned char *); +STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *); +STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *); +STATIC size_t coordinate_drslice_gendata(unsigned char *); + +STATIC bool is_drslice_solvable(cube_t); + +STATIC coord_t coordinate_drslice = { + .name = "DRSLICE", + .coord = &coordinate_drslice_coord, + .cube = &coordinate_drslice_cube, + .isnasty = &coordinate_drslice_isnasty, + .gendata = coordinate_drslice_gendata, + .max = CLASSES_CP_16 * FACT_8, + .trans_mask = TM_UDFIX, + .moves_mask = MM18_DR, + .axistrans = { + [AXIS_UD] = TRANS_UFr, + [AXIS_RL] = TRANS_RFr, + [AXIS_FB] = TRANS_FDr, + }, + .is_admissible = &solution_always_valid, + .is_solvable = &is_drslice_solvable, + .pruning_distribution = { + /* TODO: copied from nissy-classic, to be verified */ + [0] = 1, + [1] = 3, + [2] = 10, + [3] = 52, + [4] = 285, + [5] = 1318, + [6] = 5671, + [7] = 26502, + [8] = 115467, + [9] = 470846, + [10] = 1853056, + [11] = 6535823, + [12] = 18349792, + [13] = 32843350, + [14] = 34118883, + [15] = 0, /* TODO: unknown, why does nissy-classic not have + have this value? */ + }, + .pruning_max = 15, /* TODO - either 14 or 15 */ + .sym = { + .classes = CLASSES_CP_16, + .max = FACT_8, + .coord = &coordinate_cp_coord, + .cube = &coordinate_cp_cube, + .max2 = FACT_8, + .coord2 = &coordinate_epud_coord, + .cube2 = &coordinate_epud_cube, + .merge = &coordinate_drslice_merge, + }, +}; + +STATIC uint64_t +coordinate_cp_coord(cube_t c) +{ + return coord_cp(c); +} + +STATIC cube_t +coordinate_cp_cube(uint64_t i) +{ + return invcoord_cp(i); +} + +STATIC uint64_t +coordinate_epud_coord(cube_t c) +{ + return coord_epud(c); +} + +STATIC cube_t +coordinate_epud_cube(uint64_t i) +{ + return invcoord_epud(i); +} + +STATIC cube_t +coordinate_drslice_merge(cube_t c1, cube_t c2) +{ + cube_t merged; + + merged = c1; + copy_edges(&merged, c2); + + return merged; +} + +STATIC uint64_t +coordinate_drslice_coord(cube_t cube, const unsigned char *data) +{ + return coord_coord_generic(&coordinate_drslice, cube, data); +} + +STATIC cube_t +coordinate_drslice_cube(uint64_t i, const unsigned char *data) +{ + return coord_cube_generic(&coordinate_drslice, i, data); +} + +STATIC bool +coordinate_drslice_isnasty(uint64_t i, const unsigned char *data) +{ + return coord_isnasty_generic(&coordinate_drslice, i, data); +} + +STATIC size_t +coordinate_drslice_gendata(unsigned char *data) +{ + return coord_gendata_generic(&coordinate_drslice, data); +} + +STATIC bool +is_drslice_solvable(cube_t cube) { + return coord_eo(cube) == 0 && + coord_eo(transform_edges(cube, TRANS_URr)) == 0 && + coord_co(cube) == 0; +} diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h @@ -2,5 +2,6 @@ coord_t *all_coordinates[] = { &coordinate_eo, &coordinate_dr, &coordinate_dreo, + &coordinate_drslice, NULL };