diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-02 14:33:21 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-02 14:33:21 +0200 |
| commit | c5a6ff0443fc9e5e890fe72cb13ea78d4fe2bbcb (patch) | |
| tree | 9a5710c2393a09078df72d95364b6af966d745bd /src/solvers/coord/dr.h | |
| parent | 82e0a6bf454f5684b44bb0a24db619e9ba0567a0 (diff) | |
| download | nissy-core-c5a6ff0443fc9e5e890fe72cb13ea78d4fe2bbcb.tar.gz nissy-core-c5a6ff0443fc9e5e890fe72cb13ea78d4fe2bbcb.zip | |
Added dreo coordinate solver
Diffstat (limited to 'src/solvers/coord/dr.h')
| -rw-r--r-- | src/solvers/coord/dr.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h index 314d4f1..3bc4c6d 100644 --- a/src/solvers/coord/dr.h +++ b/src/solvers/coord/dr.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #define DREOESEP_CLASSES UINT64_C(64430) | 1 | #define DREOESEP_CLASSES UINT64_C(64430) |
| 2 | #define DREOESEP_MAX (POW_2_11 * COMB_12_4) | 2 | #define DREOESEP_MAX (POW_2_11 * COMB_12_4) |
| 3 | 3 | ||
| 4 | STATIC uint64_t coord_dreoesep_nosym(cube_t); | 4 | STATIC uint64_t coord_dreoesep_nosym(cube_t); |
| 5 | STATIC cube_t invcoord_dreoesep_nosym(uint64_t); | 5 | STATIC cube_t invcoord_dreoesep_nosym(uint64_t); |
| @@ -10,6 +10,8 @@ STATIC cube_t coordinate_dr_cube(uint64_t, const void *); | |||
| 10 | STATIC bool coordinate_dr_isnasty(uint64_t, const void *); | 10 | STATIC bool coordinate_dr_isnasty(uint64_t, const void *); |
| 11 | STATIC size_t coordinate_dr_gendata(void *); | 11 | STATIC size_t coordinate_dr_gendata(void *); |
| 12 | 12 | ||
| 13 | STATIC bool is_eoco_solvable(cube_t); | ||
| 14 | |||
| 13 | /* TODO: remove the following two when all coordinates are converted to unsigned */ | 15 | /* TODO: remove the following two when all coordinates are converted to unsigned */ |
| 14 | STATIC uint64_t coord_co_u(cube_t c) { return (uint64_t)coord_co(c); } | 16 | STATIC uint64_t coord_co_u(cube_t c) { return (uint64_t)coord_co(c); } |
| 15 | STATIC cube_t invcoord_co_u(uint64_t i) { return invcoord_co((int64_t)i); } | 17 | STATIC cube_t invcoord_co_u(uint64_t i) { return invcoord_co((int64_t)i); } |
| @@ -29,6 +31,7 @@ STATIC coord_t coordinate_dr = { | |||
| 29 | [AXIS_FB] = TRANS_FDr, | 31 | [AXIS_FB] = TRANS_FDr, |
| 30 | }, | 32 | }, |
| 31 | .is_admissible = &solution_lastqt_cw, | 33 | .is_admissible = &solution_lastqt_cw, |
| 34 | .is_solvable = &is_eoco_solvable, | ||
| 32 | .sym = { | 35 | .sym = { |
| 33 | .classes = DREOESEP_CLASSES, | 36 | .classes = DREOESEP_CLASSES, |
| 34 | .max = DREOESEP_MAX, | 37 | .max = DREOESEP_MAX, |
| @@ -100,3 +103,18 @@ coordinate_dr_gendata(void *data) | |||
| 100 | { | 103 | { |
| 101 | return coord_gendata_generic(&coordinate_dr, data); | 104 | return coord_gendata_generic(&coordinate_dr, data); |
| 102 | } | 105 | } |
| 106 | |||
| 107 | STATIC bool | ||
| 108 | is_eoco_solvable(cube_t cube) { | ||
| 109 | uint8_t c[8], e[12], i, cocount, eocount; | ||
| 110 | |||
| 111 | pieces(&cube, c, e); | ||
| 112 | |||
| 113 | for (i = 0, cocount = 0; i < 8; i++) | ||
| 114 | cocount += (c[i] & COBITS_2) >> COSHIFT; | ||
| 115 | |||
| 116 | for (i = 0, eocount = 0; i < 12; i++) | ||
| 117 | eocount += (e[i] & EOBIT) >> EOSHIFT; | ||
| 118 | |||
| 119 | return cocount % 3 == 0 && eocount % 2 == 0; | ||
| 120 | } | ||
