diff options
Diffstat (limited to 'cube.c')
| -rw-r--r-- | cube.c | 717 |
1 files changed, 32 insertions, 685 deletions
| @@ -27,10 +27,6 @@ | |||
| 27 | 27 | ||
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | /****************************************************************************** | ||
| 31 | Section: mathematical constants | ||
| 32 | ******************************************************************************/ | ||
| 33 | |||
| 34 | #define _2p11 2048U | 30 | #define _2p11 2048U |
| 35 | #define _2p12 4096U | 31 | #define _2p12 4096U |
| 36 | #define _3p7 2187U | 32 | #define _3p7 2187U |
| @@ -38,94 +34,6 @@ Section: mathematical constants | |||
| 38 | #define _12c4 495U | 34 | #define _12c4 495U |
| 39 | #define _8c4 70U | 35 | #define _8c4 70U |
| 40 | 36 | ||
| 41 | _static int64_t binomial[12][12] = { | ||
| 42 | {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | ||
| 43 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | ||
| 44 | {1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | ||
| 45 | {1, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0}, | ||
| 46 | {1, 4, 6, 4, 1, 0, 0, 0, 0, 0, 0, 0}, | ||
| 47 | {1, 5, 10, 10, 5, 1, 0, 0, 0, 0, 0, 0}, | ||
| 48 | {1, 6, 15, 20, 15, 6, 1, 0, 0, 0, 0, 0}, | ||
| 49 | {1, 7, 21, 35, 35, 21, 7, 1, 0, 0, 0, 0}, | ||
| 50 | {1, 8, 28, 56, 70, 56, 28, 8, 1, 0, 0, 0}, | ||
| 51 | {1, 9, 36, 84, 126, 126, 84, 36, 9, 1, 0, 0}, | ||
| 52 | {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0}, | ||
| 53 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, | ||
| 54 | }; | ||
| 55 | |||
| 56 | /****************************************************************************** | ||
| 57 | Section: moves definitions and tables | ||
| 58 | ******************************************************************************/ | ||
| 59 | |||
| 60 | #define U 0U | ||
| 61 | #define U2 1U | ||
| 62 | #define U3 2U | ||
| 63 | #define D 3U | ||
| 64 | #define D2 4U | ||
| 65 | #define D3 5U | ||
| 66 | #define R 6U | ||
| 67 | #define R2 7U | ||
| 68 | #define R3 8U | ||
| 69 | #define L 9U | ||
| 70 | #define L2 10U | ||
| 71 | #define L3 11U | ||
| 72 | #define F 12U | ||
| 73 | #define F2 13U | ||
| 74 | #define F3 14U | ||
| 75 | #define B 15U | ||
| 76 | #define B2 16U | ||
| 77 | #define B3 17U | ||
| 78 | |||
| 79 | #define UFr 0 | ||
| 80 | #define ULr 1 | ||
| 81 | #define UBr 2 | ||
| 82 | #define URr 3 | ||
| 83 | #define DFr 4 | ||
| 84 | #define DLr 5 | ||
| 85 | #define DBr 6 | ||
| 86 | #define DRr 7 | ||
| 87 | #define RUr 8 | ||
| 88 | #define RFr 9 | ||
| 89 | #define RDr 10 | ||
| 90 | #define RBr 11 | ||
| 91 | #define LUr 12 | ||
| 92 | #define LFr 13 | ||
| 93 | #define LDr 14 | ||
| 94 | #define LBr 15 | ||
| 95 | #define FUr 16 | ||
| 96 | #define FRr 17 | ||
| 97 | #define FDr 18 | ||
| 98 | #define FLr 19 | ||
| 99 | #define BUr 20 | ||
| 100 | #define BRr 21 | ||
| 101 | #define BDr 22 | ||
| 102 | #define BLr 23 | ||
| 103 | |||
| 104 | #define UFm 24 | ||
| 105 | #define ULm 25 | ||
| 106 | #define UBm 26 | ||
| 107 | #define URm 27 | ||
| 108 | #define DFm 28 | ||
| 109 | #define DLm 29 | ||
| 110 | #define DBm 30 | ||
| 111 | #define DRm 31 | ||
| 112 | #define RUm 32 | ||
| 113 | #define RFm 33 | ||
| 114 | #define RDm 34 | ||
| 115 | #define RBm 35 | ||
| 116 | #define LUm 36 | ||
| 117 | #define LFm 37 | ||
| 118 | #define LDm 38 | ||
| 119 | #define LBm 39 | ||
| 120 | #define FUm 40 | ||
| 121 | #define FRm 41 | ||
| 122 | #define FDm 42 | ||
| 123 | #define FLm 43 | ||
| 124 | #define BUm 44 | ||
| 125 | #define BRm 45 | ||
| 126 | #define BDm 46 | ||
| 127 | #define BLm 47 | ||
| 128 | |||
| 129 | #define _c_ufr 0U | 37 | #define _c_ufr 0U |
| 130 | #define _c_ubl 1U | 38 | #define _c_ubl 1U |
| 131 | #define _c_dfl 2U | 39 | #define _c_dfl 2U |
| @@ -163,406 +71,29 @@ Section: moves definitions and tables | |||
| 163 | #define _eflip 0x10U | 71 | #define _eflip 0x10U |
| 164 | #define _error 0xFFU | 72 | #define _error 0xFFU |
| 165 | 73 | ||
| 74 | typedef enum { | ||
| 75 | U, U2, U3, D, D2, D3, | ||
| 76 | R, R2, R3, L, L2, L3, | ||
| 77 | F, F2, F3, B, B2, B3 | ||
| 78 | } move_t; | ||
| 79 | |||
| 80 | typedef enum { | ||
| 81 | UFr, ULr, UBr, URr, DFr, DLr, DBr, DRr, | ||
| 82 | RUr, RFr, RDr, RBr, LUr, LFr, LDr, LBr, | ||
| 83 | FUr, FRr, FDr, FLr, BUr, BRr, BDr, BLr, | ||
| 84 | |||
| 85 | UFm, ULm, UBm, URm, DFm, DLm, DBm, DRm, | ||
| 86 | RUm, RFm, RDm, RBm, LUm, LFm, LDm, LBm, | ||
| 87 | FUm, FRm, FDm, FLm, BUm, BRm, BDm, BLm | ||
| 88 | } trans_t; | ||
| 89 | |||
| 166 | _static cube_t zero = { .corner = {0}, .edge = {0} }; | 90 | _static cube_t zero = { .corner = {0}, .edge = {0} }; |
| 167 | _static cube_t solved = { | 91 | _static cube_t solved = { |
| 168 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, | 92 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, |
| 169 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} | 93 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} |
| 170 | }; | 94 | }; |
| 171 | 95 | ||
| 172 | #define zero_fast fastcube( \ | 96 | #include "tables.h" |
| 173 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | ||
| 174 | #define solved_fast fastcube( \ | ||
| 175 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 176 | |||
| 177 | #define _move_cube_U fastcube( \ | ||
| 178 | 5, 4, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 1, 0, 6, 7, 8, 9, 10, 11) | ||
| 179 | #define _move_cube_U2 fastcube( \ | ||
| 180 | 1, 0, 2, 3, 5, 4, 6, 7, 1, 0, 2, 3, 5, 4, 6, 7, 8, 9, 10, 11) | ||
| 181 | #define _move_cube_U3 fastcube( \ | ||
| 182 | 4, 5, 2, 3, 1, 0, 6, 7, 5, 4, 2, 3, 0, 1, 6, 7, 8, 9, 10, 11) | ||
| 183 | #define _move_cube_D fastcube( \ | ||
| 184 | 0, 1, 7, 6, 4, 5, 2, 3, 0, 1, 7, 6, 4, 5, 2, 3, 8, 9, 10, 11) | ||
| 185 | #define _move_cube_D2 fastcube( \ | ||
| 186 | 0, 1, 3, 2, 4, 5, 7, 6, 0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11) | ||
| 187 | #define _move_cube_D3 fastcube( \ | ||
| 188 | 0, 1, 6, 7, 4, 5, 3, 2, 0, 1, 6, 7, 4, 5, 3, 2, 8, 9, 10, 11) | ||
| 189 | #define _move_cube_R fastcube( \ | ||
| 190 | 70, 1, 2, 69, 4, 32, 35, 7, 0, 1, 2, 3, 8, 5, 6, 11, 7, 9, 10, 4) | ||
| 191 | #define _move_cube_R2 fastcube( \ | ||
| 192 | 3, 1, 2, 0, 4, 6, 5, 7, 0, 1, 2, 3, 7, 5, 6, 4, 11, 9, 10, 8) | ||
| 193 | #define _move_cube_R3 fastcube( \ | ||
| 194 | 69, 1, 2, 70, 4, 35, 32, 7, 0, 1, 2, 3, 11, 5, 6, 8, 4, 9, 10, 7) | ||
| 195 | #define _move_cube_L fastcube( \ | ||
| 196 | 0, 71, 68, 3, 33, 5, 6, 34, 0, 1, 2, 3, 4, 10, 9, 7, 8, 5, 6, 11) | ||
| 197 | #define _move_cube_L2 fastcube( \ | ||
| 198 | 0, 2, 1, 3, 7, 5, 6, 4, 0, 1, 2, 3, 4, 6, 5, 7, 8, 10, 9, 11) | ||
| 199 | #define _move_cube_L3 fastcube( \ | ||
| 200 | 0, 68, 71, 3, 34, 5, 6, 33, 0, 1, 2, 3, 4, 9, 10, 7, 8, 6, 5, 11) | ||
| 201 | #define _move_cube_F fastcube( \ | ||
| 202 | 36, 1, 38, 3, 66, 5, 64, 7, 25, 1, 2, 24, 4, 5, 6, 7, 16, 19, 10, 11) | ||
| 203 | #define _move_cube_F2 fastcube( \ | ||
| 204 | 2, 1, 0, 3, 6, 5, 4, 7, 3, 1, 2, 0, 4, 5, 6, 7, 9, 8, 10, 11) | ||
| 205 | #define _move_cube_F3 fastcube( \ | ||
| 206 | 38, 1, 36, 3, 64, 5, 66, 7, 24, 1, 2, 25, 4, 5, 6, 7, 19, 16, 10, 11) | ||
| 207 | #define _move_cube_B fastcube( \ | ||
| 208 | 0, 37, 2, 39, 4, 67, 6, 65, 0, 27, 26, 3, 4, 5, 6, 7, 8, 9, 17, 18) | ||
| 209 | #define _move_cube_B2 fastcube( \ | ||
| 210 | 0, 3, 2, 1, 4, 7, 6, 5, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 11, 10) | ||
| 211 | #define _move_cube_B3 fastcube( \ | ||
| 212 | 0, 39, 2, 37, 4, 65, 6, 67, 0, 26, 27, 3, 4, 5, 6, 7, 8, 9, 18, 17) | ||
| 213 | |||
| 214 | #define _trans_cube_UFr fastcube( \ | ||
| 215 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 216 | #define _trans_cube_UFr_inverse fastcube( \ | ||
| 217 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 218 | #define _trans_cube_ULr fastcube( \ | ||
| 219 | 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) | ||
| 220 | #define _trans_cube_ULr_inverse fastcube( \ | ||
| 221 | 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) | ||
| 222 | #define _trans_cube_UBr fastcube( \ | ||
| 223 | 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) | ||
| 224 | #define _trans_cube_UBr_inverse fastcube( \ | ||
| 225 | 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) | ||
| 226 | #define _trans_cube_URr fastcube( \ | ||
| 227 | 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) | ||
| 228 | #define _trans_cube_URr_inverse fastcube( \ | ||
| 229 | 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) | ||
| 230 | #define _trans_cube_DFr fastcube( \ | ||
| 231 | 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) | ||
| 232 | #define _trans_cube_DFr_inverse fastcube( \ | ||
| 233 | 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) | ||
| 234 | #define _trans_cube_DLr fastcube( \ | ||
| 235 | 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) | ||
| 236 | #define _trans_cube_DLr_inverse fastcube( \ | ||
| 237 | 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) | ||
| 238 | #define _trans_cube_DBr fastcube( \ | ||
| 239 | 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) | ||
| 240 | #define _trans_cube_DBr_inverse fastcube( \ | ||
| 241 | 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) | ||
| 242 | #define _trans_cube_DRr fastcube( \ | ||
| 243 | 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) | ||
| 244 | #define _trans_cube_DRr_inverse fastcube( \ | ||
| 245 | 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) | ||
| 246 | #define _trans_cube_RUr fastcube( \ | ||
| 247 | 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) | ||
| 248 | #define _trans_cube_RUr_inverse fastcube( \ | ||
| 249 | 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) | ||
| 250 | #define _trans_cube_RFr fastcube( \ | ||
| 251 | 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) | ||
| 252 | #define _trans_cube_RFr_inverse fastcube( \ | ||
| 253 | 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) | ||
| 254 | #define _trans_cube_RDr fastcube( \ | ||
| 255 | 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) | ||
| 256 | #define _trans_cube_RDr_inverse fastcube( \ | ||
| 257 | 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) | ||
| 258 | #define _trans_cube_RBr fastcube( \ | ||
| 259 | 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) | ||
| 260 | #define _trans_cube_RBr_inverse fastcube( \ | ||
| 261 | 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) | ||
| 262 | #define _trans_cube_LUr fastcube( \ | ||
| 263 | 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) | ||
| 264 | #define _trans_cube_LUr_inverse fastcube( \ | ||
| 265 | 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) | ||
| 266 | #define _trans_cube_LFr fastcube( \ | ||
| 267 | 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) | ||
| 268 | #define _trans_cube_LFr_inverse fastcube( \ | ||
| 269 | 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) | ||
| 270 | #define _trans_cube_LDr fastcube( \ | ||
| 271 | 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) | ||
| 272 | #define _trans_cube_LDr_inverse fastcube( \ | ||
| 273 | 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) | ||
| 274 | #define _trans_cube_LBr fastcube( \ | ||
| 275 | 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) | ||
| 276 | #define _trans_cube_LBr_inverse fastcube( \ | ||
| 277 | 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) | ||
| 278 | #define _trans_cube_FUr fastcube( \ | ||
| 279 | 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) | ||
| 280 | #define _trans_cube_FUr_inverse fastcube( \ | ||
| 281 | 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) | ||
| 282 | #define _trans_cube_FRr fastcube( \ | ||
| 283 | 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) | ||
| 284 | #define _trans_cube_FRr_inverse fastcube( \ | ||
| 285 | 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) | ||
| 286 | #define _trans_cube_FDr fastcube( \ | ||
| 287 | 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) | ||
| 288 | #define _trans_cube_FDr_inverse fastcube( \ | ||
| 289 | 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) | ||
| 290 | #define _trans_cube_FLr fastcube( \ | ||
| 291 | 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) | ||
| 292 | #define _trans_cube_FLr_inverse fastcube( \ | ||
| 293 | 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) | ||
| 294 | #define _trans_cube_BUr fastcube( \ | ||
| 295 | 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) | ||
| 296 | #define _trans_cube_BUr_inverse fastcube( \ | ||
| 297 | 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) | ||
| 298 | #define _trans_cube_BRr fastcube( \ | ||
| 299 | 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) | ||
| 300 | #define _trans_cube_BRr_inverse fastcube( \ | ||
| 301 | 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) | ||
| 302 | #define _trans_cube_BDr fastcube( \ | ||
| 303 | 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) | ||
| 304 | #define _trans_cube_BDr_inverse fastcube( \ | ||
| 305 | 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) | ||
| 306 | #define _trans_cube_BLr fastcube( \ | ||
| 307 | 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) | ||
| 308 | #define _trans_cube_BLr_inverse fastcube( \ | ||
| 309 | 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) | ||
| 310 | #define _trans_cube_UFm fastcube( \ | ||
| 311 | 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) | ||
| 312 | #define _trans_cube_UFm_inverse fastcube( \ | ||
| 313 | 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) | ||
| 314 | #define _trans_cube_ULm fastcube( \ | ||
| 315 | 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) | ||
| 316 | #define _trans_cube_ULm_inverse fastcube( \ | ||
| 317 | 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) | ||
| 318 | #define _trans_cube_UBm fastcube( \ | ||
| 319 | 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) | ||
| 320 | #define _trans_cube_UBm_inverse fastcube( \ | ||
| 321 | 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) | ||
| 322 | #define _trans_cube_URm fastcube( \ | ||
| 323 | 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) | ||
| 324 | #define _trans_cube_URm_inverse fastcube( \ | ||
| 325 | 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) | ||
| 326 | #define _trans_cube_DFm fastcube( \ | ||
| 327 | 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) | ||
| 328 | #define _trans_cube_DFm_inverse fastcube( \ | ||
| 329 | 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) | ||
| 330 | #define _trans_cube_DLm fastcube( \ | ||
| 331 | 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) | ||
| 332 | #define _trans_cube_DLm_inverse fastcube( \ | ||
| 333 | 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) | ||
| 334 | #define _trans_cube_DBm fastcube( \ | ||
| 335 | 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) | ||
| 336 | #define _trans_cube_DBm_inverse fastcube( \ | ||
| 337 | 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) | ||
| 338 | #define _trans_cube_DRm fastcube( \ | ||
| 339 | 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) | ||
| 340 | #define _trans_cube_DRm_inverse fastcube( \ | ||
| 341 | 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) | ||
| 342 | #define _trans_cube_RUm fastcube( \ | ||
| 343 | 68, 71, 69, 70, 33, 34, 32, 35, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) | ||
| 344 | #define _trans_cube_RUm_inverse fastcube( \ | ||
| 345 | 70, 68, 69, 71, 32, 34, 35, 33, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) | ||
| 346 | #define _trans_cube_RFm fastcube( \ | ||
| 347 | 34, 33, 32, 35, 68, 71, 70, 69, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) | ||
| 348 | #define _trans_cube_RFm_inverse fastcube( \ | ||
| 349 | 66, 65, 64, 67, 36, 39, 38, 37, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) | ||
| 350 | #define _trans_cube_RDm fastcube( \ | ||
| 351 | 71, 68, 70, 69, 34, 33, 35, 32, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) | ||
| 352 | #define _trans_cube_RDm_inverse fastcube( \ | ||
| 353 | 71, 69, 68, 70, 33, 35, 34, 32, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) | ||
| 354 | #define _trans_cube_RBm fastcube( \ | ||
| 355 | 33, 34, 35, 32, 71, 68, 69, 70, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) | ||
| 356 | #define _trans_cube_RBm_inverse fastcube( \ | ||
| 357 | 67, 64, 65, 66, 37, 38, 39, 36, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) | ||
| 358 | #define _trans_cube_LUm fastcube( \ | ||
| 359 | 69, 70, 68, 71, 32, 35, 33, 34, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) | ||
| 360 | #define _trans_cube_LUm_inverse fastcube( \ | ||
| 361 | 68, 70, 71, 69, 34, 32, 33, 35, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) | ||
| 362 | #define _trans_cube_LFm fastcube( \ | ||
| 363 | 32, 35, 34, 33, 70, 69, 68, 71, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) | ||
| 364 | #define _trans_cube_LFm_inverse fastcube( \ | ||
| 365 | 64, 67, 66, 65, 38, 37, 36, 39, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) | ||
| 366 | #define _trans_cube_LDm fastcube( \ | ||
| 367 | 70, 69, 71, 68, 35, 32, 34, 33, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) | ||
| 368 | #define _trans_cube_LDm_inverse fastcube( \ | ||
| 369 | 69, 71, 70, 68, 35, 33, 32, 34, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) | ||
| 370 | #define _trans_cube_LBm fastcube( \ | ||
| 371 | 35, 32, 33, 34, 69, 70, 71, 68, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) | ||
| 372 | #define _trans_cube_LBm_inverse fastcube( \ | ||
| 373 | 65, 66, 67, 64, 39, 36, 37, 38, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) | ||
| 374 | #define _trans_cube_FUm fastcube( \ | ||
| 375 | 64, 66, 65, 67, 36, 38, 37, 39, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) | ||
| 376 | #define _trans_cube_FUm_inverse fastcube( \ | ||
| 377 | 32, 34, 33, 35, 68, 70, 69, 71, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) | ||
| 378 | #define _trans_cube_FRm fastcube( \ | ||
| 379 | 36, 38, 39, 37, 66, 64, 65, 67, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) | ||
| 380 | #define _trans_cube_FRm_inverse fastcube( \ | ||
| 381 | 37, 38, 36, 39, 64, 67, 65, 66, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) | ||
| 382 | #define _trans_cube_FDm fastcube( \ | ||
| 383 | 66, 64, 67, 65, 38, 36, 39, 37, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) | ||
| 384 | #define _trans_cube_FDm_inverse fastcube( \ | ||
| 385 | 33, 35, 32, 34, 69, 71, 68, 70, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) | ||
| 386 | #define _trans_cube_FLm fastcube( \ | ||
| 387 | 38, 36, 37, 39, 64, 66, 67, 65, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) | ||
| 388 | #define _trans_cube_FLm_inverse fastcube( \ | ||
| 389 | 36, 39, 37, 38, 65, 66, 64, 67, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) | ||
| 390 | #define _trans_cube_BUm fastcube( \ | ||
| 391 | 65, 67, 64, 66, 37, 39, 36, 38, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) | ||
| 392 | #define _trans_cube_BUm_inverse fastcube( \ | ||
| 393 | 34, 32, 35, 33, 70, 68, 71, 69, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) | ||
| 394 | #define _trans_cube_BRm fastcube( \ | ||
| 395 | 39, 37, 36, 38, 65, 67, 66, 64, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) | ||
| 396 | #define _trans_cube_BRm_inverse fastcube( \ | ||
| 397 | 39, 36, 38, 37, 66, 65, 67, 64, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) | ||
| 398 | #define _trans_cube_BDm fastcube( \ | ||
| 399 | 67, 65, 66, 64, 39, 37, 38, 36, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) | ||
| 400 | #define _trans_cube_BDm_inverse fastcube( \ | ||
| 401 | 35, 33, 34, 32, 71, 69, 70, 68, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) | ||
| 402 | #define _trans_cube_BLm fastcube( \ | ||
| 403 | 37, 39, 38, 36, 67, 65, 64, 66, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) | ||
| 404 | #define _trans_cube_BLm_inverse fastcube( \ | ||
| 405 | 38, 37, 39, 36, 67, 64, 66, 65, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) | ||
| 406 | |||
| 407 | _static char *cornerstr[] = { | ||
| 408 | [_c_ufr] = "UFR", | ||
| 409 | [_c_ubl] = "UBL", | ||
| 410 | [_c_dfl] = "DFL", | ||
| 411 | [_c_dbr] = "DBR", | ||
| 412 | [_c_ufl] = "UFL", | ||
| 413 | [_c_ubr] = "UBR", | ||
| 414 | [_c_dfr] = "DFR", | ||
| 415 | [_c_dbl] = "DBL" | ||
| 416 | }; | ||
| 417 | |||
| 418 | _static char *cornerstralt[] = { | ||
| 419 | [_c_ufr] = "URF", | ||
| 420 | [_c_ubl] = "ULB", | ||
| 421 | [_c_dfl] = "DLF", | ||
| 422 | [_c_dbr] = "DRB", | ||
| 423 | [_c_ufl] = "ULF", | ||
| 424 | [_c_ubr] = "URB", | ||
| 425 | [_c_dfr] = "DRF", | ||
| 426 | [_c_dbl] = "DLB" | ||
| 427 | }; | ||
| 428 | |||
| 429 | _static char *edgestr[] = { | ||
| 430 | [_e_uf] = "UF", | ||
| 431 | [_e_ub] = "UB", | ||
| 432 | [_e_db] = "DB", | ||
| 433 | [_e_df] = "DF", | ||
| 434 | [_e_ur] = "UR", | ||
| 435 | [_e_ul] = "UL", | ||
| 436 | [_e_dl] = "DL", | ||
| 437 | [_e_dr] = "DR", | ||
| 438 | [_e_fr] = "FR", | ||
| 439 | [_e_fl] = "FL", | ||
| 440 | [_e_bl] = "BL", | ||
| 441 | [_e_br] = "BR" | ||
| 442 | }; | ||
| 443 | |||
| 444 | _static char *movestr[] = { | ||
| 445 | [U] = "U", | ||
| 446 | [U2] = "U2", | ||
| 447 | [U3] = "U'", | ||
| 448 | [D] = "D", | ||
| 449 | [D2] = "D2", | ||
| 450 | [D3] = "D'", | ||
| 451 | [R] = "R", | ||
| 452 | [R2] = "R2", | ||
| 453 | [R3] = "R'", | ||
| 454 | [L] = "L", | ||
| 455 | [L2] = "L2", | ||
| 456 | [L3] = "L'", | ||
| 457 | [F] = "F", | ||
| 458 | [F2] = "F2", | ||
| 459 | [F3] = "F'", | ||
| 460 | [B] = "B", | ||
| 461 | [B2] = "B2", | ||
| 462 | [B3] = "B'", | ||
| 463 | }; | ||
| 464 | |||
| 465 | _static char *transstr[] = { | ||
| 466 | [UFr] = "rotation UF", | ||
| 467 | [UFm] = "mirrored UF", | ||
| 468 | [ULr] = "rotation UL", | ||
| 469 | [ULm] = "mirrored UL", | ||
| 470 | [UBr] = "rotation UB", | ||
| 471 | [UBm] = "mirrored UB", | ||
| 472 | [URr] = "rotation UR", | ||
| 473 | [URm] = "mirrored UR", | ||
| 474 | [DFr] = "rotation DF", | ||
| 475 | [DFm] = "mirrored DF", | ||
| 476 | [DLr] = "rotation DL", | ||
| 477 | [DLm] = "mirrored DL", | ||
| 478 | [DBr] = "rotation DB", | ||
| 479 | [DBm] = "mirrored DB", | ||
| 480 | [DRr] = "rotation DR", | ||
| 481 | [DRm] = "mirrored DR", | ||
| 482 | [RUr] = "rotation RU", | ||
| 483 | [RUm] = "mirrored RU", | ||
| 484 | [RFr] = "rotation RF", | ||
| 485 | [RFm] = "mirrored RF", | ||
| 486 | [RDr] = "rotation RD", | ||
| 487 | [RDm] = "mirrored RD", | ||
| 488 | [RBr] = "rotation RB", | ||
| 489 | [RBm] = "mirrored RB", | ||
| 490 | [LUr] = "rotation LU", | ||
| 491 | [LUm] = "mirrored LU", | ||
| 492 | [LFr] = "rotation LF", | ||
| 493 | [LFm] = "mirrored LF", | ||
| 494 | [LDr] = "rotation LD", | ||
| 495 | [LDm] = "mirrored LD", | ||
| 496 | [LBr] = "rotation LB", | ||
| 497 | [LBm] = "mirrored LB", | ||
| 498 | [FUr] = "rotation FU", | ||
| 499 | [FUm] = "mirrored FU", | ||
| 500 | [FRr] = "rotation FR", | ||
| 501 | [FRm] = "mirrored FR", | ||
| 502 | [FDr] = "rotation FD", | ||
| 503 | [FDm] = "mirrored FD", | ||
| 504 | [FLr] = "rotation FL", | ||
| 505 | [FLm] = "mirrored FL", | ||
| 506 | [BUr] = "rotation BU", | ||
| 507 | [BUm] = "mirrored BU", | ||
| 508 | [BRr] = "rotation BR", | ||
| 509 | [BRm] = "mirrored BR", | ||
| 510 | [BDr] = "rotation BD", | ||
| 511 | [BDm] = "mirrored BD", | ||
| 512 | [BLr] = "rotation BL", | ||
| 513 | [BLm] = "mirrored BL", | ||
| 514 | }; | ||
| 515 | |||
| 516 | static uint8_t inverse_trans_table[48] = { | ||
| 517 | [UFr] = UFr, | ||
| 518 | [UFm] = UFm, | ||
| 519 | [ULr] = URr, | ||
| 520 | [ULm] = ULm, | ||
| 521 | [UBr] = UBr, | ||
| 522 | [UBm] = UBm, | ||
| 523 | [URr] = ULr, | ||
| 524 | [URm] = URm, | ||
| 525 | [DFr] = DFr, | ||
| 526 | [DFm] = DFm, | ||
| 527 | [DLr] = DLr, | ||
| 528 | [DLm] = DRm, | ||
| 529 | [DBr] = DBr, | ||
| 530 | [DBm] = DBm, | ||
| 531 | [DRr] = DRr, | ||
| 532 | [DRm] = DLm, | ||
| 533 | [RUr] = FRr, | ||
| 534 | [RUm] = FLm, | ||
| 535 | [RFr] = LFr, | ||
| 536 | [RFm] = RFm, | ||
| 537 | [RDr] = BLr, | ||
| 538 | [RDm] = BRm, | ||
| 539 | [RBr] = RBr, | ||
| 540 | [RBm] = LBm, | ||
| 541 | [LUr] = FLr, | ||
| 542 | [LUm] = FRm, | ||
| 543 | [LFr] = RFr, | ||
| 544 | [LFm] = LFm, | ||
| 545 | [LDr] = BRr, | ||
| 546 | [LDm] = BLm, | ||
| 547 | [LBr] = LBr, | ||
| 548 | [LBm] = RBm, | ||
| 549 | [FUr] = FUr, | ||
| 550 | [FUm] = FUm, | ||
| 551 | [FRr] = RUr, | ||
| 552 | [FRm] = LUm, | ||
| 553 | [FDr] = BUr, | ||
| 554 | [FDm] = BUm, | ||
| 555 | [FLr] = LUr, | ||
| 556 | [FLm] = RUm, | ||
| 557 | [BUr] = FDr, | ||
| 558 | [BUm] = FDm, | ||
| 559 | [BRr] = LDr, | ||
| 560 | [BRm] = RDm, | ||
| 561 | [BDr] = BDr, | ||
| 562 | [BDm] = BDm, | ||
| 563 | [BLr] = RDr, | ||
| 564 | [BLm] = LDm, | ||
| 565 | }; | ||
| 566 | 97 | ||
| 567 | /****************************************************************************** | 98 | /****************************************************************************** |
| 568 | Section: portable fast methods | 99 | Section: portable fast methods |
| @@ -574,12 +105,6 @@ in the previous section(s) for unsupported architectures. | |||
| 574 | 105 | ||
| 575 | typedef cube_t cube_fast_t; | 106 | typedef cube_t cube_fast_t; |
| 576 | 107 | ||
| 577 | _static_inline cube_fast_t fastcube( | ||
| 578 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | ||
| 579 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | ||
| 580 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | ||
| 581 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t | ||
| 582 | ); | ||
| 583 | _static cube_fast_t cubetofast(cube_t); | 108 | _static cube_fast_t cubetofast(cube_t); |
| 584 | _static cube_t fasttocube(cube_fast_t); | 109 | _static cube_t fasttocube(cube_fast_t); |
| 585 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); | 110 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); |
| @@ -590,44 +115,6 @@ _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | |||
| 590 | _static_inline int64_t coord_fast_co(cube_fast_t); | 115 | _static_inline int64_t coord_fast_co(cube_fast_t); |
| 591 | _static_inline int64_t coord_fast_eo(cube_fast_t); | 116 | _static_inline int64_t coord_fast_eo(cube_fast_t); |
| 592 | 117 | ||
| 593 | _static_inline cube_fast_t | ||
| 594 | fastcube( | ||
| 595 | uint8_t c_ufr, | ||
| 596 | uint8_t c_ubl, | ||
| 597 | uint8_t c_dfl, | ||
| 598 | uint8_t c_dbr, | ||
| 599 | uint8_t c_ufl, | ||
| 600 | uint8_t c_ubr, | ||
| 601 | uint8_t c_dfr, | ||
| 602 | uint8_t c_dbl, | ||
| 603 | |||
| 604 | uint8_t e_uf, | ||
| 605 | uint8_t e_ub, | ||
| 606 | uint8_t e_db, | ||
| 607 | uint8_t e_df, | ||
| 608 | uint8_t e_ur, | ||
| 609 | uint8_t e_ul, | ||
| 610 | uint8_t e_dl, | ||
| 611 | uint8_t e_dr, | ||
| 612 | uint8_t e_fr, | ||
| 613 | uint8_t e_fl, | ||
| 614 | uint8_t e_bl, | ||
| 615 | uint8_t e_br | ||
| 616 | ) | ||
| 617 | { | ||
| 618 | cube_fast_t cube = { | ||
| 619 | .corner = { | ||
| 620 | c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl | ||
| 621 | }, | ||
| 622 | .edge = { | ||
| 623 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, | ||
| 624 | e_dl, e_dr, e_fr, e_fl, e_bl, e_br | ||
| 625 | } | ||
| 626 | }; | ||
| 627 | |||
| 628 | return cube; | ||
| 629 | } | ||
| 630 | |||
| 631 | _static cube_fast_t | 118 | _static cube_fast_t |
| 632 | cubetofast(cube_t cube) | 119 | cubetofast(cube_t cube) |
| 633 | { | 120 | { |
| @@ -662,7 +149,7 @@ equal_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 662 | _static_inline bool | 149 | _static_inline bool |
| 663 | issolved_fast(cube_fast_t cube) | 150 | issolved_fast(cube_fast_t cube) |
| 664 | { | 151 | { |
| 665 | return equal_fast(cube, solved_fast); | 152 | return equal_fast(cube, solved); |
| 666 | } | 153 | } |
| 667 | 154 | ||
| 668 | _static_inline cube_fast_t | 155 | _static_inline cube_fast_t |
| @@ -687,7 +174,7 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 687 | cube_fast_t ret; | 174 | cube_fast_t ret; |
| 688 | uint8_t i, piece1, piece2, p, orien, aux, auy; | 175 | uint8_t i, piece1, piece2, p, orien, aux, auy; |
| 689 | 176 | ||
| 690 | ret = zero_fast; | 177 | ret = zero; |
| 691 | 178 | ||
| 692 | for (i = 0; i < 12; i++) { | 179 | for (i = 0; i < 12; i++) { |
| 693 | piece2 = c2.edge[i]; | 180 | piece2 = c2.edge[i]; |
| @@ -742,14 +229,7 @@ Some of these routines depend on the efficient functions implemented in the | |||
| 742 | previous sections, while some other operate directly on the cube. | 229 | previous sections, while some other operate directly on the cube. |
| 743 | ******************************************************************************/ | 230 | ******************************************************************************/ |
| 744 | 231 | ||
| 745 | #define _move(M, c) compose_fast(c, _move_cube_ ## M) | ||
| 746 | #define _premove(M, c) compose_fast(_move_cube_ ## M, c) | 232 | #define _premove(M, c) compose_fast(_move_cube_ ## M, c) |
| 747 | #define _trans_rotation(T, c) \ | ||
| 748 | compose_fast(compose_fast(_trans_cube_ ## T, c), \ | ||
| 749 | _trans_cube_ ## T ## _inverse) | ||
| 750 | #define _trans_mirrored(T, c) \ | ||
| 751 | invertco_fast(compose_fast(compose_fast(_trans_cube_ ## T, c), \ | ||
| 752 | _trans_cube_ ## T ## _inverse)) | ||
| 753 | 233 | ||
| 754 | #define _foreach_move(_m, _c, _d, instruction) \ | 234 | #define _foreach_move(_m, _c, _d, instruction) \ |
| 755 | for (_m = 0; _m < 18; _m++) { _d = move(_c, _m); instruction } | 235 | for (_m = 0; _m < 18; _m++) { _d = move(_c, _m); instruction } |
| @@ -785,8 +265,8 @@ _static uint8_t readmodifier(char); | |||
| 785 | _static uint8_t readtrans(char *); | 265 | _static uint8_t readtrans(char *); |
| 786 | _static int writemoves(uint8_t *, int, char *); | 266 | _static int writemoves(uint8_t *, int, char *); |
| 787 | _static void writetrans(uint8_t, char *); | 267 | _static void writetrans(uint8_t, char *); |
| 788 | _static cube_fast_t move(cube_fast_t, uint8_t); | 268 | _static cube_fast_t move(cube_fast_t, move_t); |
| 789 | _static cube_fast_t transform(cube_fast_t, uint8_t); | 269 | _static cube_fast_t transform(cube_fast_t, trans_t); |
| 790 | 270 | ||
| 791 | cube_t | 271 | cube_t |
| 792 | solvedcube(void) | 272 | solvedcube(void) |
| @@ -1339,155 +819,22 @@ writetrans(uint8_t t, char *buf) | |||
| 1339 | } | 819 | } |
| 1340 | 820 | ||
| 1341 | _static cube_fast_t | 821 | _static cube_fast_t |
| 1342 | move(cube_fast_t c, uint8_t m) | 822 | move(cube_fast_t c, move_t m) |
| 1343 | { | 823 | { |
| 1344 | switch (m) { | 824 | return compose_fast(c, move_table[m]); |
| 1345 | case U: | ||
| 1346 | return _move(U, c); | ||
| 1347 | case U2: | ||
| 1348 | return _move(U2, c); | ||
| 1349 | case U3: | ||
| 1350 | return _move(U3, c); | ||
| 1351 | case D: | ||
| 1352 | return _move(D, c); | ||
| 1353 | case D2: | ||
| 1354 | return _move(D2, c); | ||
| 1355 | case D3: | ||
| 1356 | return _move(D3, c); | ||
| 1357 | case R: | ||
| 1358 | return _move(R, c); | ||
| 1359 | case R2: | ||
| 1360 | return _move(R2, c); | ||
| 1361 | case R3: | ||
| 1362 | return _move(R3, c); | ||
| 1363 | case L: | ||
| 1364 | return _move(L, c); | ||
| 1365 | case L2: | ||
| 1366 | return _move(L2, c); | ||
| 1367 | case L3: | ||
| 1368 | return _move(L3, c); | ||
| 1369 | case F: | ||
| 1370 | return _move(F, c); | ||
| 1371 | case F2: | ||
| 1372 | return _move(F2, c); | ||
| 1373 | case F3: | ||
| 1374 | return _move(F3, c); | ||
| 1375 | case B: | ||
| 1376 | return _move(B, c); | ||
| 1377 | case B2: | ||
| 1378 | return _move(B2, c); | ||
| 1379 | case B3: | ||
| 1380 | return _move(B3, c); | ||
| 1381 | default: | ||
| 1382 | DBG_LOG("move error, unknown move\n"); | ||
| 1383 | return zero_fast; | ||
| 1384 | } | ||
| 1385 | } | 825 | } |
| 1386 | 826 | ||
| 1387 | _static cube_fast_t | 827 | _static cube_fast_t |
| 1388 | transform(cube_fast_t c, uint8_t t) | 828 | transform(cube_fast_t c, trans_t t) |
| 1389 | { | 829 | { |
| 1390 | switch (t) { | 830 | cube_t tcube, tinv; |
| 1391 | case UFr: | 831 | |
| 1392 | return _trans_rotation(UFr, c); | 832 | tcube = trans_table[t][NORMAL]; |
| 1393 | case ULr: | 833 | tinv = trans_table[t][INVERSE]; |
| 1394 | return _trans_rotation(ULr, c); | 834 | |
| 1395 | case UBr: | 835 | return t < 24 ? |
| 1396 | return _trans_rotation(UBr, c); | 836 | compose_fast(compose_fast(tcube, c), tinv) : |
| 1397 | case URr: | 837 | invertco_fast(compose_fast(compose_fast(tcube, c), tinv)); |
| 1398 | return _trans_rotation(URr, c); | ||
| 1399 | case DFr: | ||
| 1400 | return _trans_rotation(DFr, c); | ||
| 1401 | case DLr: | ||
| 1402 | return _trans_rotation(DLr, c); | ||
| 1403 | case DBr: | ||
| 1404 | return _trans_rotation(DBr, c); | ||
| 1405 | case DRr: | ||
| 1406 | return _trans_rotation(DRr, c); | ||
| 1407 | case RUr: | ||
| 1408 | return _trans_rotation(RUr, c); | ||
| 1409 | case RFr: | ||
| 1410 | return _trans_rotation(RFr, c); | ||
| 1411 | case RDr: | ||
| 1412 | return _trans_rotation(RDr, c); | ||
| 1413 | case RBr: | ||
| 1414 | return _trans_rotation(RBr, c); | ||
| 1415 | case LUr: | ||
| 1416 | return _trans_rotation(LUr, c); | ||
| 1417 | case LFr: | ||
| 1418 | return _trans_rotation(LFr, c); | ||
| 1419 | case LDr: | ||
| 1420 | return _trans_rotation(LDr, c); | ||
| 1421 | case LBr: | ||
| 1422 | return _trans_rotation(LBr, c); | ||
| 1423 | case FUr: | ||
| 1424 | return _trans_rotation(FUr, c); | ||
| 1425 | case FRr: | ||
| 1426 | return _trans_rotation(FRr, c); | ||
| 1427 | case FDr: | ||
| 1428 | return _trans_rotation(FDr, c); | ||
| 1429 | case FLr: | ||
| 1430 | return _trans_rotation(FLr, c); | ||
| 1431 | case BUr: | ||
| 1432 | return _trans_rotation(BUr, c); | ||
| 1433 | case BRr: | ||
| 1434 | return _trans_rotation(BRr, c); | ||
| 1435 | case BDr: | ||
| 1436 | return _trans_rotation(BDr, c); | ||
| 1437 | case BLr: | ||
| 1438 | return _trans_rotation(BLr, c); | ||
| 1439 | case UFm: | ||
| 1440 | return _trans_mirrored(UFm, c); | ||
| 1441 | case ULm: | ||
| 1442 | return _trans_mirrored(ULm, c); | ||
| 1443 | case UBm: | ||
| 1444 | return _trans_mirrored(UBm, c); | ||
| 1445 | case URm: | ||
| 1446 | return _trans_mirrored(URm, c); | ||
| 1447 | case DFm: | ||
| 1448 | return _trans_mirrored(DFm, c); | ||
| 1449 | case DLm: | ||
| 1450 | return _trans_mirrored(DLm, c); | ||
| 1451 | case DBm: | ||
| 1452 | return _trans_mirrored(DBm, c); | ||
| 1453 | case DRm: | ||
| 1454 | return _trans_mirrored(DRm, c); | ||
| 1455 | case RUm: | ||
| 1456 | return _trans_mirrored(RUm, c); | ||
| 1457 | case RFm: | ||
| 1458 | return _trans_mirrored(RFm, c); | ||
| 1459 | case RDm: | ||
| 1460 | return _trans_mirrored(RDm, c); | ||
| 1461 | case RBm: | ||
| 1462 | return _trans_mirrored(RBm, c); | ||
| 1463 | case LUm: | ||
| 1464 | return _trans_mirrored(LUm, c); | ||
| 1465 | case LFm: | ||
| 1466 | return _trans_mirrored(LFm, c); | ||
| 1467 | case LDm: | ||
| 1468 | return _trans_mirrored(LDm, c); | ||
| 1469 | case LBm: | ||
| 1470 | return _trans_mirrored(LBm, c); | ||
| 1471 | case FUm: | ||
| 1472 | return _trans_mirrored(FUm, c); | ||
| 1473 | case FRm: | ||
| 1474 | return _trans_mirrored(FRm, c); | ||
| 1475 | case FDm: | ||
| 1476 | return _trans_mirrored(FDm, c); | ||
| 1477 | case FLm: | ||
| 1478 | return _trans_mirrored(FLm, c); | ||
| 1479 | case BUm: | ||
| 1480 | return _trans_mirrored(BUm, c); | ||
| 1481 | case BRm: | ||
| 1482 | return _trans_mirrored(BRm, c); | ||
| 1483 | case BDm: | ||
| 1484 | return _trans_mirrored(BDm, c); | ||
| 1485 | case BLm: | ||
| 1486 | return _trans_mirrored(BLm, c); | ||
| 1487 | default: | ||
| 1488 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 1489 | return zero_fast; | ||
| 1490 | } | ||
| 1491 | } | 838 | } |
| 1492 | 839 | ||
| 1493 | /****************************************************************************** | 840 | /****************************************************************************** |
