diff options
Diffstat (limited to 'src/solvers/coord/dr.h')
| -rw-r--r-- | src/solvers/coord/dr.h | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h new file mode 100644 index 0000000..5f3a99b --- /dev/null +++ b/src/solvers/coord/dr.h | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | #define DREOESEP_CLASSES UINT64_C(64430) | ||
| 2 | #define DREOESEP_MAX (POW_2_11 * COMB_12_4) | ||
| 3 | |||
| 4 | #define DR_CLASS_TABLESIZE (sizeof(uint32_t) * (size_t)DREOESEP_MAX) | ||
| 5 | #define DR_REP_TABLESIZE (sizeof(uint32_t) * (size_t)DREOESEP_CLASSES) | ||
| 6 | #define DR_COORD_DATASIZE (INFOSIZE + DR_CLASS_TABLESIZE + DR_REP_TABLESIZE) | ||
| 7 | |||
| 8 | #define DR_CLASS_SHIFT UINT32_C(16) | ||
| 9 | #define DR_CLASS_MASK (UINT32_C(0xFFFF) << DR_CLASS_SHIFT) | ||
| 10 | #define DR_CLASS(d) (((d) & DR_CLASS_MASK) >> DR_CLASS_SHIFT) | ||
| 11 | |||
| 12 | #define DR_TTREP_SHIFT UINT32_C(0) | ||
| 13 | #define DR_TTREP_MASK (UINT32_C(0xFF) << DR_TTREP_SHIFT) | ||
| 14 | #define DR_TTREP(d) (((d) & DR_TTREP_MASK) >> DR_TTREP_SHIFT) | ||
| 15 | |||
| 16 | #define DR_ISNASTY_SHIFT UINT32_C(8) | ||
| 17 | #define DR_ISNASTY_MASK (UINT32_C(0xFF) << DR_ISNASTY_SHIFT) | ||
| 18 | #define DR_ISNASTY(d) (((d) & DR_ISNASTY_MASK) >> DR_ISNASTY_SHIFT) | ||
| 19 | |||
| 20 | STATIC uint64_t coord_dreoesep_nosym(cube_t); | ||
| 21 | STATIC cube_t invcoord_dreoesep_nosym(uint64_t); | ||
| 22 | |||
| 23 | STATIC uint64_t coordinate_dr_coord(cube_t, const void *); | ||
| 24 | STATIC cube_t coordinate_dr_cube(uint64_t, const void *); | ||
| 25 | STATIC bool coordinate_dr_isnasty(uint64_t, const void *); | ||
| 26 | STATIC uint64_t coordinate_dr_gendata(void *); | ||
| 27 | |||
| 28 | STATIC coord_t coordinate_dr = { | ||
| 29 | .name = "DR", | ||
| 30 | .coord = &coordinate_dr_coord, | ||
| 31 | .cube = &coordinate_dr_cube, | ||
| 32 | .isnasty = &coordinate_dr_isnasty, | ||
| 33 | .gendata = coordinate_dr_gendata, | ||
| 34 | .max = DREOESEP_CLASSES * POW_3_7, | ||
| 35 | .trans_mask = TM_UDFIX, | ||
| 36 | .moves_mask = MM_ALLMOVES, | ||
| 37 | .axistrans = { | ||
| 38 | [AXIS_UD] = TRANS_UFr, | ||
| 39 | [AXIS_RL] = TRANS_RFr, | ||
| 40 | [AXIS_FB] = TRANS_FDr, | ||
| 41 | }, | ||
| 42 | .is_admissible = &solution_lastqt_cw, | ||
| 43 | }; | ||
| 44 | |||
| 45 | STATIC uint64_t | ||
| 46 | coord_dreoesep_nosym(cube_t cube) | ||
| 47 | { | ||
| 48 | uint64_t eo, esep; | ||
| 49 | |||
| 50 | esep = coord_esep(cube) / COMB_8_4; | ||
| 51 | eo = coord_eo(cube); | ||
| 52 | |||
| 53 | return esep * POW_2_11 + eo; | ||
| 54 | } | ||
| 55 | |||
| 56 | STATIC cube_t | ||
| 57 | invcoord_dreoesep_nosym(uint64_t coord) | ||
| 58 | { | ||
| 59 | uint64_t eo, esep; | ||
| 60 | cube_t cube; | ||
| 61 | |||
| 62 | eo = coord % POW_2_11; | ||
| 63 | esep = (coord / POW_2_11) * COMB_8_4; | ||
| 64 | cube = invcoord_esep(esep); | ||
| 65 | set_eo(&cube, eo); | ||
| 66 | |||
| 67 | return cube; | ||
| 68 | } | ||
| 69 | |||
| 70 | STATIC uint64_t | ||
| 71 | coordinate_dr_coord(cube_t cube, const void *data) | ||
| 72 | { | ||
| 73 | const char *datanoinfo; | ||
| 74 | const uint32_t *data32; | ||
| 75 | uint32_t d; | ||
| 76 | cube_t transformed; | ||
| 77 | |||
| 78 | datanoinfo = (const char *)data + INFOSIZE; | ||
| 79 | data32 = (const uint32_t *)datanoinfo; | ||
| 80 | d = data32[coord_dreoesep_nosym(cube)]; | ||
| 81 | transformed = transform(cube, DR_TTREP(d)); | ||
| 82 | |||
| 83 | return DR_CLASS(d) * POW_3_7 + coord_co(transformed); | ||
| 84 | } | ||
| 85 | |||
| 86 | STATIC cube_t | ||
| 87 | coordinate_dr_cube(uint64_t coord, const void *data) | ||
| 88 | { | ||
| 89 | const char *datanoinfo; | ||
| 90 | const uint32_t *rep32; | ||
| 91 | cube_t cube; | ||
| 92 | |||
| 93 | datanoinfo = (const char *)data + INFOSIZE; | ||
| 94 | rep32 = (const uint32_t *)(datanoinfo + DR_CLASS_TABLESIZE); | ||
| 95 | cube = invcoord_dreoesep_nosym(rep32[coord / POW_3_7]); | ||
| 96 | copy_corners(&cube, invcoord_co(coord % POW_3_7)); | ||
| 97 | |||
| 98 | return cube; | ||
| 99 | } | ||
| 100 | |||
| 101 | STATIC bool | ||
| 102 | coordinate_dr_isnasty(uint64_t coord, const void *data) | ||
| 103 | { | ||
| 104 | const char *datanoinfo; | ||
| 105 | const uint32_t *classttrep; | ||
| 106 | |||
| 107 | datanoinfo = (const char *)data + INFOSIZE; | ||
| 108 | classttrep = (const uint32_t *)datanoinfo; | ||
| 109 | |||
| 110 | return DR_ISNASTY(classttrep[coord]); | ||
| 111 | } | ||
| 112 | |||
| 113 | STATIC size_t | ||
| 114 | coordinate_dr_gendata(void *data) | ||
| 115 | { | ||
| 116 | uint64_t i, ii, j, n, t, nasty; | ||
| 117 | char *datanoinfo; | ||
| 118 | uint32_t *classttrep, *rep; | ||
| 119 | cube_t c; | ||
| 120 | tableinfo_t info; | ||
| 121 | |||
| 122 | if (data == NULL) | ||
| 123 | goto coordinate_dr_gendata_returnsize; | ||
| 124 | |||
| 125 | datanoinfo = (char *)data + INFOSIZE; | ||
| 126 | classttrep = (uint32_t *)datanoinfo; | ||
| 127 | rep = classttrep + (DR_CLASS_TABLESIZE / sizeof(uint32_t)); | ||
| 128 | memset(data, 0xFF, DR_COORD_DATASIZE); | ||
| 129 | |||
| 130 | info = (tableinfo_t) { | ||
| 131 | .solver = "coord data for DR", | ||
| 132 | .type = TABLETYPE_SPECIAL, | ||
| 133 | .infosize = INFOSIZE, | ||
| 134 | .fullsize = DR_COORD_DATASIZE, | ||
| 135 | .hash = 0, | ||
| 136 | .entries = DREOESEP_CLASSES + DREOESEP_MAX, | ||
| 137 | .classes = DREOESEP_CLASSES, | ||
| 138 | .bits = 32, | ||
| 139 | .base = 0, | ||
| 140 | .maxvalue = 0, | ||
| 141 | .next = 0 | ||
| 142 | }; | ||
| 143 | |||
| 144 | for (i = 0, n = 0; i < COMB_12_4 * POW_2_11; i++) { | ||
| 145 | if (classttrep[i] != 0xFFFFFFFF) | ||
| 146 | continue; | ||
| 147 | |||
| 148 | c = invcoord_dreoesep_nosym(i); | ||
| 149 | ii = coord_dreoesep_nosym(c); | ||
| 150 | for (t = 0, nasty = 0; t < NTRANS && !nasty; t++) { | ||
| 151 | if (!((UINT64_C(1) << t) & coordinate_dr.trans_mask)) | ||
| 152 | continue; | ||
| 153 | |||
| 154 | nasty = ii == coord_dreoesep_nosym(transform(c, t)); | ||
| 155 | } | ||
| 156 | |||
| 157 | for (t = 0; t < NTRANS; t++) { | ||
| 158 | if (!((UINT64_C(1) << t) & coordinate_dr.trans_mask)) | ||
| 159 | continue; | ||
| 160 | |||
| 161 | j = coord_dreoesep_nosym(transform(c, t)); | ||
| 162 | classttrep[j] = | ||
| 163 | (n << DR_CLASS_SHIFT) | | ||
| 164 | (nasty << DR_ISNASTY_SHIFT) | | ||
| 165 | (inverse_trans(t) << DR_TTREP_SHIFT); | ||
| 166 | } | ||
| 167 | rep[n++] = i; | ||
| 168 | } | ||
| 169 | |||
| 170 | writetableinfo(&info, DR_COORD_DATASIZE, data); | ||
| 171 | |||
| 172 | DBG_ASSERT(n == DREOESEP_CLASSES, 0, | ||
| 173 | "dr coordinate data: computed %" PRIu64 " classes, " | ||
| 174 | "expected %" PRIu64 "\n", n, DREOESEP_CLASSES); | ||
| 175 | |||
| 176 | coordinate_dr_gendata_returnsize: | ||
| 177 | return DR_COORD_DATASIZE; | ||
| 178 | } | ||
