diff options
31 files changed, 1083 insertions, 1097 deletions
| @@ -1,25 +1,19 @@ | |||
| 1 | Refactoring: remove cube_fast_t and add b32 format | 1 | Refactoring: remove cube_fast_t and add b32 format |
| 2 | x added b32 converter by piece (not tested, will be tested automatically) | 2 | - fix all public functions in cube.h |
| 3 | x added piece functions (e.g. corner(cube, i)) | 3 | and their implementations in cube_generic |
| 4 | (would be more efficient to just convert the whole thing to arrays...) | 4 | - cube i/o format |
| 5 | - replace all usages of cube_t with cube_fast_t and piece functions | 5 | move all formats other than b32 to convert.{c,h} |
| 6 | (this is mainly in cube_routines) | 6 | add tests for conversion |
| 7 | (fix tests in tandem with main code) | 7 | convert test files (?) |
| 8 | cubetofast fasttocube | 8 | make b32 default |
| 9 | zero and solved | 9 | replace utils/*.c with a generic convert utility |
| 10 | solvedcube(void) | ||
| 11 | [cube.h] isconsistent, issolvable, issolved, equal, iserror | ||
| 12 | [cube.h] compose, inverse | ||
| 13 | [cube.h] applymoves, applytrans | ||
| 14 | [cube.h] readcube writecube | ||
| 15 | [cube.h] solve | ||
| 16 | - add b32 i/o format as default | ||
| 17 | - remove cube_t type | ||
| 18 | - rename cube_fast_t to cube_t | ||
| 19 | - if all public functions work with strings, always use return value | 10 | - if all public functions work with strings, always use return value |
| 20 | as error code (solve already does this), and use string as buffer | 11 | as error code (solve already does this), and use string as buffer |
| 21 | to print error | 12 | to print error |
| 22 | 13 | ||
| 14 | Transform with big table | ||
| 15 | - make static cube actually static (how?) | ||
| 16 | |||
| 23 | Solver | 17 | Solver |
| 24 | - write a solver (how many tricks? some, but not all are needed) | 18 | - write a solver (how many tricks? some, but not all are needed) |
| 25 | 19 | ||
diff --git a/src/constant_cubes.h b/src/constant_cubes.h new file mode 100644 index 0000000..b7748d8 --- /dev/null +++ b/src/constant_cubes.h | |||
| @@ -0,0 +1,229 @@ | |||
| 1 | #define _move_cube_U static_cube( \ | ||
| 2 | 5, 4, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 1, 0, 6, 7, 8, 9, 10, 11) | ||
| 3 | #define _move_cube_U2 static_cube( \ | ||
| 4 | 1, 0, 2, 3, 5, 4, 6, 7, 1, 0, 2, 3, 5, 4, 6, 7, 8, 9, 10, 11) | ||
| 5 | #define _move_cube_U3 static_cube( \ | ||
| 6 | 4, 5, 2, 3, 1, 0, 6, 7, 5, 4, 2, 3, 0, 1, 6, 7, 8, 9, 10, 11) | ||
| 7 | #define _move_cube_D static_cube( \ | ||
| 8 | 0, 1, 7, 6, 4, 5, 2, 3, 0, 1, 7, 6, 4, 5, 2, 3, 8, 9, 10, 11) | ||
| 9 | #define _move_cube_D2 static_cube( \ | ||
| 10 | 0, 1, 3, 2, 4, 5, 7, 6, 0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11) | ||
| 11 | #define _move_cube_D3 static_cube( \ | ||
| 12 | 0, 1, 6, 7, 4, 5, 3, 2, 0, 1, 6, 7, 4, 5, 3, 2, 8, 9, 10, 11) | ||
| 13 | #define _move_cube_R static_cube( \ | ||
| 14 | 70, 1, 2, 69, 4, 32, 35, 7, 0, 1, 2, 3, 8, 5, 6, 11, 7, 9, 10, 4) | ||
| 15 | #define _move_cube_R2 static_cube( \ | ||
| 16 | 3, 1, 2, 0, 4, 6, 5, 7, 0, 1, 2, 3, 7, 5, 6, 4, 11, 9, 10, 8) | ||
| 17 | #define _move_cube_R3 static_cube( \ | ||
| 18 | 69, 1, 2, 70, 4, 35, 32, 7, 0, 1, 2, 3, 11, 5, 6, 8, 4, 9, 10, 7) | ||
| 19 | #define _move_cube_L static_cube( \ | ||
| 20 | 0, 71, 68, 3, 33, 5, 6, 34, 0, 1, 2, 3, 4, 10, 9, 7, 8, 5, 6, 11) | ||
| 21 | #define _move_cube_L2 static_cube( \ | ||
| 22 | 0, 2, 1, 3, 7, 5, 6, 4, 0, 1, 2, 3, 4, 6, 5, 7, 8, 10, 9, 11) | ||
| 23 | #define _move_cube_L3 static_cube( \ | ||
| 24 | 0, 68, 71, 3, 34, 5, 6, 33, 0, 1, 2, 3, 4, 9, 10, 7, 8, 6, 5, 11) | ||
| 25 | #define _move_cube_F static_cube( \ | ||
| 26 | 36, 1, 38, 3, 66, 5, 64, 7, 25, 1, 2, 24, 4, 5, 6, 7, 16, 19, 10, 11) | ||
| 27 | #define _move_cube_F2 static_cube( \ | ||
| 28 | 2, 1, 0, 3, 6, 5, 4, 7, 3, 1, 2, 0, 4, 5, 6, 7, 9, 8, 10, 11) | ||
| 29 | #define _move_cube_F3 static_cube( \ | ||
| 30 | 38, 1, 36, 3, 64, 5, 66, 7, 24, 1, 2, 25, 4, 5, 6, 7, 19, 16, 10, 11) | ||
| 31 | #define _move_cube_B static_cube( \ | ||
| 32 | 0, 37, 2, 39, 4, 67, 6, 65, 0, 27, 26, 3, 4, 5, 6, 7, 8, 9, 17, 18) | ||
| 33 | #define _move_cube_B2 static_cube( \ | ||
| 34 | 0, 3, 2, 1, 4, 7, 6, 5, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 11, 10) | ||
| 35 | #define _move_cube_B3 static_cube( \ | ||
| 36 | 0, 39, 2, 37, 4, 65, 6, 67, 0, 26, 27, 3, 4, 5, 6, 7, 8, 9, 18, 17) | ||
| 37 | |||
| 38 | #define _trans_cube_UFr static_cube( \ | ||
| 39 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 40 | #define _trans_cube_UFr_inverse static_cube( \ | ||
| 41 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 42 | #define _trans_cube_ULr static_cube( \ | ||
| 43 | 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) | ||
| 44 | #define _trans_cube_ULr_inverse static_cube( \ | ||
| 45 | 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) | ||
| 46 | #define _trans_cube_UBr static_cube( \ | ||
| 47 | 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) | ||
| 48 | #define _trans_cube_UBr_inverse static_cube( \ | ||
| 49 | 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) | ||
| 50 | #define _trans_cube_URr static_cube( \ | ||
| 51 | 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) | ||
| 52 | #define _trans_cube_URr_inverse static_cube( \ | ||
| 53 | 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) | ||
| 54 | #define _trans_cube_DFr static_cube( \ | ||
| 55 | 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) | ||
| 56 | #define _trans_cube_DFr_inverse static_cube( \ | ||
| 57 | 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) | ||
| 58 | #define _trans_cube_DLr static_cube( \ | ||
| 59 | 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) | ||
| 60 | #define _trans_cube_DLr_inverse static_cube( \ | ||
| 61 | 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) | ||
| 62 | #define _trans_cube_DBr static_cube( \ | ||
| 63 | 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) | ||
| 64 | #define _trans_cube_DBr_inverse static_cube( \ | ||
| 65 | 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) | ||
| 66 | #define _trans_cube_DRr static_cube( \ | ||
| 67 | 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) | ||
| 68 | #define _trans_cube_DRr_inverse static_cube( \ | ||
| 69 | 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) | ||
| 70 | #define _trans_cube_RUr static_cube( \ | ||
| 71 | 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) | ||
| 72 | #define _trans_cube_RUr_inverse static_cube( \ | ||
| 73 | 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) | ||
| 74 | #define _trans_cube_RFr static_cube( \ | ||
| 75 | 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) | ||
| 76 | #define _trans_cube_RFr_inverse static_cube( \ | ||
| 77 | 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) | ||
| 78 | #define _trans_cube_RDr static_cube( \ | ||
| 79 | 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) | ||
| 80 | #define _trans_cube_RDr_inverse static_cube( \ | ||
| 81 | 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) | ||
| 82 | #define _trans_cube_RBr static_cube( \ | ||
| 83 | 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) | ||
| 84 | #define _trans_cube_RBr_inverse static_cube( \ | ||
| 85 | 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) | ||
| 86 | #define _trans_cube_LUr static_cube( \ | ||
| 87 | 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) | ||
| 88 | #define _trans_cube_LUr_inverse static_cube( \ | ||
| 89 | 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) | ||
| 90 | #define _trans_cube_LFr static_cube( \ | ||
| 91 | 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) | ||
| 92 | #define _trans_cube_LFr_inverse static_cube( \ | ||
| 93 | 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) | ||
| 94 | #define _trans_cube_LDr static_cube( \ | ||
| 95 | 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) | ||
| 96 | #define _trans_cube_LDr_inverse static_cube( \ | ||
| 97 | 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) | ||
| 98 | #define _trans_cube_LBr static_cube( \ | ||
| 99 | 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) | ||
| 100 | #define _trans_cube_LBr_inverse static_cube( \ | ||
| 101 | 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) | ||
| 102 | #define _trans_cube_FUr static_cube( \ | ||
| 103 | 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) | ||
| 104 | #define _trans_cube_FUr_inverse static_cube( \ | ||
| 105 | 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) | ||
| 106 | #define _trans_cube_FRr static_cube( \ | ||
| 107 | 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) | ||
| 108 | #define _trans_cube_FRr_inverse static_cube( \ | ||
| 109 | 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) | ||
| 110 | #define _trans_cube_FDr static_cube( \ | ||
| 111 | 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) | ||
| 112 | #define _trans_cube_FDr_inverse static_cube( \ | ||
| 113 | 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) | ||
| 114 | #define _trans_cube_FLr static_cube( \ | ||
| 115 | 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) | ||
| 116 | #define _trans_cube_FLr_inverse static_cube( \ | ||
| 117 | 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) | ||
| 118 | #define _trans_cube_BUr static_cube( \ | ||
| 119 | 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) | ||
| 120 | #define _trans_cube_BUr_inverse static_cube( \ | ||
| 121 | 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) | ||
| 122 | #define _trans_cube_BRr static_cube( \ | ||
| 123 | 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) | ||
| 124 | #define _trans_cube_BRr_inverse static_cube( \ | ||
| 125 | 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) | ||
| 126 | #define _trans_cube_BDr static_cube( \ | ||
| 127 | 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) | ||
| 128 | #define _trans_cube_BDr_inverse static_cube( \ | ||
| 129 | 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) | ||
| 130 | #define _trans_cube_BLr static_cube( \ | ||
| 131 | 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) | ||
| 132 | #define _trans_cube_BLr_inverse static_cube( \ | ||
| 133 | 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) | ||
| 134 | #define _trans_cube_UFm static_cube( \ | ||
| 135 | 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) | ||
| 136 | #define _trans_cube_UFm_inverse static_cube( \ | ||
| 137 | 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) | ||
| 138 | #define _trans_cube_ULm static_cube( \ | ||
| 139 | 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) | ||
| 140 | #define _trans_cube_ULm_inverse static_cube( \ | ||
| 141 | 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) | ||
| 142 | #define _trans_cube_UBm static_cube( \ | ||
| 143 | 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) | ||
| 144 | #define _trans_cube_UBm_inverse static_cube( \ | ||
| 145 | 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) | ||
| 146 | #define _trans_cube_URm static_cube( \ | ||
| 147 | 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) | ||
| 148 | #define _trans_cube_URm_inverse static_cube( \ | ||
| 149 | 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) | ||
| 150 | #define _trans_cube_DFm static_cube( \ | ||
| 151 | 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) | ||
| 152 | #define _trans_cube_DFm_inverse static_cube( \ | ||
| 153 | 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) | ||
| 154 | #define _trans_cube_DLm static_cube( \ | ||
| 155 | 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) | ||
| 156 | #define _trans_cube_DLm_inverse static_cube( \ | ||
| 157 | 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) | ||
| 158 | #define _trans_cube_DBm static_cube( \ | ||
| 159 | 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) | ||
| 160 | #define _trans_cube_DBm_inverse static_cube( \ | ||
| 161 | 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) | ||
| 162 | #define _trans_cube_DRm static_cube( \ | ||
| 163 | 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) | ||
| 164 | #define _trans_cube_DRm_inverse static_cube( \ | ||
| 165 | 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) | ||
| 166 | #define _trans_cube_RUm static_cube( \ | ||
| 167 | 68, 71, 69, 70, 33, 34, 32, 35, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) | ||
| 168 | #define _trans_cube_RUm_inverse static_cube( \ | ||
| 169 | 70, 68, 69, 71, 32, 34, 35, 33, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) | ||
| 170 | #define _trans_cube_RFm static_cube( \ | ||
| 171 | 34, 33, 32, 35, 68, 71, 70, 69, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) | ||
| 172 | #define _trans_cube_RFm_inverse static_cube( \ | ||
| 173 | 66, 65, 64, 67, 36, 39, 38, 37, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) | ||
| 174 | #define _trans_cube_RDm static_cube( \ | ||
| 175 | 71, 68, 70, 69, 34, 33, 35, 32, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) | ||
| 176 | #define _trans_cube_RDm_inverse static_cube( \ | ||
| 177 | 71, 69, 68, 70, 33, 35, 34, 32, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) | ||
| 178 | #define _trans_cube_RBm static_cube( \ | ||
| 179 | 33, 34, 35, 32, 71, 68, 69, 70, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) | ||
| 180 | #define _trans_cube_RBm_inverse static_cube( \ | ||
| 181 | 67, 64, 65, 66, 37, 38, 39, 36, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) | ||
| 182 | #define _trans_cube_LUm static_cube( \ | ||
| 183 | 69, 70, 68, 71, 32, 35, 33, 34, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) | ||
| 184 | #define _trans_cube_LUm_inverse static_cube( \ | ||
| 185 | 68, 70, 71, 69, 34, 32, 33, 35, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) | ||
| 186 | #define _trans_cube_LFm static_cube( \ | ||
| 187 | 32, 35, 34, 33, 70, 69, 68, 71, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) | ||
| 188 | #define _trans_cube_LFm_inverse static_cube( \ | ||
| 189 | 64, 67, 66, 65, 38, 37, 36, 39, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) | ||
| 190 | #define _trans_cube_LDm static_cube( \ | ||
| 191 | 70, 69, 71, 68, 35, 32, 34, 33, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) | ||
| 192 | #define _trans_cube_LDm_inverse static_cube( \ | ||
| 193 | 69, 71, 70, 68, 35, 33, 32, 34, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) | ||
| 194 | #define _trans_cube_LBm static_cube( \ | ||
| 195 | 35, 32, 33, 34, 69, 70, 71, 68, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) | ||
| 196 | #define _trans_cube_LBm_inverse static_cube( \ | ||
| 197 | 65, 66, 67, 64, 39, 36, 37, 38, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) | ||
| 198 | #define _trans_cube_FUm static_cube( \ | ||
| 199 | 64, 66, 65, 67, 36, 38, 37, 39, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) | ||
| 200 | #define _trans_cube_FUm_inverse static_cube( \ | ||
| 201 | 32, 34, 33, 35, 68, 70, 69, 71, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) | ||
| 202 | #define _trans_cube_FRm static_cube( \ | ||
| 203 | 36, 38, 39, 37, 66, 64, 65, 67, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) | ||
| 204 | #define _trans_cube_FRm_inverse static_cube( \ | ||
| 205 | 37, 38, 36, 39, 64, 67, 65, 66, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) | ||
| 206 | #define _trans_cube_FDm static_cube( \ | ||
| 207 | 66, 64, 67, 65, 38, 36, 39, 37, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) | ||
| 208 | #define _trans_cube_FDm_inverse static_cube( \ | ||
| 209 | 33, 35, 32, 34, 69, 71, 68, 70, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) | ||
| 210 | #define _trans_cube_FLm static_cube( \ | ||
| 211 | 38, 36, 37, 39, 64, 66, 67, 65, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) | ||
| 212 | #define _trans_cube_FLm_inverse static_cube( \ | ||
| 213 | 36, 39, 37, 38, 65, 66, 64, 67, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) | ||
| 214 | #define _trans_cube_BUm static_cube( \ | ||
| 215 | 65, 67, 64, 66, 37, 39, 36, 38, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) | ||
| 216 | #define _trans_cube_BUm_inverse static_cube( \ | ||
| 217 | 34, 32, 35, 33, 70, 68, 71, 69, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) | ||
| 218 | #define _trans_cube_BRm static_cube( \ | ||
| 219 | 39, 37, 36, 38, 65, 67, 66, 64, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) | ||
| 220 | #define _trans_cube_BRm_inverse static_cube( \ | ||
| 221 | 39, 36, 38, 37, 66, 65, 67, 64, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) | ||
| 222 | #define _trans_cube_BDm static_cube( \ | ||
| 223 | 67, 65, 66, 64, 39, 37, 38, 36, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) | ||
| 224 | #define _trans_cube_BDm_inverse static_cube( \ | ||
| 225 | 35, 33, 34, 32, 71, 69, 70, 68, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) | ||
| 226 | #define _trans_cube_BLm static_cube( \ | ||
| 227 | 37, 39, 38, 36, 67, 65, 64, 66, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) | ||
| 228 | #define _trans_cube_BLm_inverse static_cube( \ | ||
| 229 | 38, 37, 39, 36, 67, 64, 66, 65, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) | ||
diff --git a/src/constants.h b/src/constants.h index 1a5453c..c8909d7 100644 --- a/src/constants.h +++ b/src/constants.h | |||
| @@ -130,247 +130,6 @@ _static int64_t binomial[12][12] = { | |||
| 130 | #define _eflip UINT8_C(0x10) | 130 | #define _eflip UINT8_C(0x10) |
| 131 | #define _error UINT8_C(0xFF) | 131 | #define _error UINT8_C(0xFF) |
| 132 | 132 | ||
| 133 | _static cube_t zero = { .corner = {0}, .edge = {0} }; | ||
| 134 | _static cube_t solved = { | ||
| 135 | .corner = {0, 1, 2, 3, 4, 5, 6, 7}, | ||
| 136 | .edge = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} | ||
| 137 | }; | ||
| 138 | |||
| 139 | #define zero_fast fastcube( \ | ||
| 140 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | ||
| 141 | #define solved_fast fastcube( \ | ||
| 142 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 143 | |||
| 144 | #define _move_cube_U fastcube( \ | ||
| 145 | 5, 4, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 1, 0, 6, 7, 8, 9, 10, 11) | ||
| 146 | #define _move_cube_U2 fastcube( \ | ||
| 147 | 1, 0, 2, 3, 5, 4, 6, 7, 1, 0, 2, 3, 5, 4, 6, 7, 8, 9, 10, 11) | ||
| 148 | #define _move_cube_U3 fastcube( \ | ||
| 149 | 4, 5, 2, 3, 1, 0, 6, 7, 5, 4, 2, 3, 0, 1, 6, 7, 8, 9, 10, 11) | ||
| 150 | #define _move_cube_D fastcube( \ | ||
| 151 | 0, 1, 7, 6, 4, 5, 2, 3, 0, 1, 7, 6, 4, 5, 2, 3, 8, 9, 10, 11) | ||
| 152 | #define _move_cube_D2 fastcube( \ | ||
| 153 | 0, 1, 3, 2, 4, 5, 7, 6, 0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11) | ||
| 154 | #define _move_cube_D3 fastcube( \ | ||
| 155 | 0, 1, 6, 7, 4, 5, 3, 2, 0, 1, 6, 7, 4, 5, 3, 2, 8, 9, 10, 11) | ||
| 156 | #define _move_cube_R fastcube( \ | ||
| 157 | 70, 1, 2, 69, 4, 32, 35, 7, 0, 1, 2, 3, 8, 5, 6, 11, 7, 9, 10, 4) | ||
| 158 | #define _move_cube_R2 fastcube( \ | ||
| 159 | 3, 1, 2, 0, 4, 6, 5, 7, 0, 1, 2, 3, 7, 5, 6, 4, 11, 9, 10, 8) | ||
| 160 | #define _move_cube_R3 fastcube( \ | ||
| 161 | 69, 1, 2, 70, 4, 35, 32, 7, 0, 1, 2, 3, 11, 5, 6, 8, 4, 9, 10, 7) | ||
| 162 | #define _move_cube_L fastcube( \ | ||
| 163 | 0, 71, 68, 3, 33, 5, 6, 34, 0, 1, 2, 3, 4, 10, 9, 7, 8, 5, 6, 11) | ||
| 164 | #define _move_cube_L2 fastcube( \ | ||
| 165 | 0, 2, 1, 3, 7, 5, 6, 4, 0, 1, 2, 3, 4, 6, 5, 7, 8, 10, 9, 11) | ||
| 166 | #define _move_cube_L3 fastcube( \ | ||
| 167 | 0, 68, 71, 3, 34, 5, 6, 33, 0, 1, 2, 3, 4, 9, 10, 7, 8, 6, 5, 11) | ||
| 168 | #define _move_cube_F fastcube( \ | ||
| 169 | 36, 1, 38, 3, 66, 5, 64, 7, 25, 1, 2, 24, 4, 5, 6, 7, 16, 19, 10, 11) | ||
| 170 | #define _move_cube_F2 fastcube( \ | ||
| 171 | 2, 1, 0, 3, 6, 5, 4, 7, 3, 1, 2, 0, 4, 5, 6, 7, 9, 8, 10, 11) | ||
| 172 | #define _move_cube_F3 fastcube( \ | ||
| 173 | 38, 1, 36, 3, 64, 5, 66, 7, 24, 1, 2, 25, 4, 5, 6, 7, 19, 16, 10, 11) | ||
| 174 | #define _move_cube_B fastcube( \ | ||
| 175 | 0, 37, 2, 39, 4, 67, 6, 65, 0, 27, 26, 3, 4, 5, 6, 7, 8, 9, 17, 18) | ||
| 176 | #define _move_cube_B2 fastcube( \ | ||
| 177 | 0, 3, 2, 1, 4, 7, 6, 5, 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 11, 10) | ||
| 178 | #define _move_cube_B3 fastcube( \ | ||
| 179 | 0, 39, 2, 37, 4, 65, 6, 67, 0, 26, 27, 3, 4, 5, 6, 7, 8, 9, 18, 17) | ||
| 180 | |||
| 181 | #define _trans_cube_UFr fastcube( \ | ||
| 182 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 183 | #define _trans_cube_UFr_inverse fastcube( \ | ||
| 184 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | ||
| 185 | #define _trans_cube_ULr fastcube( \ | ||
| 186 | 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) | ||
| 187 | #define _trans_cube_ULr_inverse fastcube( \ | ||
| 188 | 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) | ||
| 189 | #define _trans_cube_UBr fastcube( \ | ||
| 190 | 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) | ||
| 191 | #define _trans_cube_UBr_inverse fastcube( \ | ||
| 192 | 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 10, 11, 8, 9) | ||
| 193 | #define _trans_cube_URr fastcube( \ | ||
| 194 | 5, 4, 6, 7, 0, 1, 3, 2, 4, 5, 6, 7, 1, 0, 3, 2, 27, 24, 25, 26) | ||
| 195 | #define _trans_cube_URr_inverse fastcube( \ | ||
| 196 | 4, 5, 7, 6, 1, 0, 2, 3, 5, 4, 7, 6, 0, 1, 2, 3, 25, 26, 27, 24) | ||
| 197 | #define _trans_cube_DFr fastcube( \ | ||
| 198 | 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) | ||
| 199 | #define _trans_cube_DFr_inverse fastcube( \ | ||
| 200 | 2, 3, 0, 1, 6, 7, 4, 5, 3, 2, 1, 0, 6, 7, 4, 5, 9, 8, 11, 10) | ||
| 201 | #define _trans_cube_DLr fastcube( \ | ||
| 202 | 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) | ||
| 203 | #define _trans_cube_DLr_inverse fastcube( \ | ||
| 204 | 7, 6, 4, 5, 2, 3, 1, 0, 6, 7, 4, 5, 2, 3, 0, 1, 26, 25, 24, 27) | ||
| 205 | #define _trans_cube_DBr fastcube( \ | ||
| 206 | 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) | ||
| 207 | #define _trans_cube_DBr_inverse fastcube( \ | ||
| 208 | 3, 2, 1, 0, 7, 6, 5, 4, 2, 3, 0, 1, 7, 6, 5, 4, 11, 10, 9, 8) | ||
| 209 | #define _trans_cube_DRr fastcube( \ | ||
| 210 | 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) | ||
| 211 | #define _trans_cube_DRr_inverse fastcube( \ | ||
| 212 | 6, 7, 5, 4, 3, 2, 0, 1, 7, 6, 5, 4, 3, 2, 1, 0, 24, 27, 26, 25) | ||
| 213 | #define _trans_cube_RUr fastcube( \ | ||
| 214 | 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) | ||
| 215 | #define _trans_cube_RUr_inverse fastcube( \ | ||
| 216 | 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) | ||
| 217 | #define _trans_cube_RFr fastcube( \ | ||
| 218 | 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) | ||
| 219 | #define _trans_cube_RFr_inverse fastcube( \ | ||
| 220 | 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) | ||
| 221 | #define _trans_cube_RDr fastcube( \ | ||
| 222 | 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) | ||
| 223 | #define _trans_cube_RDr_inverse fastcube( \ | ||
| 224 | 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) | ||
| 225 | #define _trans_cube_RBr fastcube( \ | ||
| 226 | 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) | ||
| 227 | #define _trans_cube_RBr_inverse fastcube( \ | ||
| 228 | 37, 38, 39, 36, 67, 64, 65, 66, 27, 24, 25, 26, 20, 23, 22, 21, 17, 18, 19, 16) | ||
| 229 | #define _trans_cube_LUr fastcube( \ | ||
| 230 | 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) | ||
| 231 | #define _trans_cube_LUr_inverse fastcube( \ | ||
| 232 | 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) | ||
| 233 | #define _trans_cube_LFr fastcube( \ | ||
| 234 | 36, 39, 38, 37, 66, 65, 64, 67, 25, 26, 27, 24, 21, 22, 23, 20, 16, 19, 18, 17) | ||
| 235 | #define _trans_cube_LFr_inverse fastcube( \ | ||
| 236 | 38, 37, 36, 39, 64, 67, 66, 65, 24, 27, 26, 25, 23, 20, 21, 22, 19, 16, 17, 18) | ||
| 237 | #define _trans_cube_LDr fastcube( \ | ||
| 238 | 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) | ||
| 239 | #define _trans_cube_LDr_inverse fastcube( \ | ||
| 240 | 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) | ||
| 241 | #define _trans_cube_LBr fastcube( \ | ||
| 242 | 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) | ||
| 243 | #define _trans_cube_LBr_inverse fastcube( \ | ||
| 244 | 39, 36, 37, 38, 65, 66, 67, 64, 26, 25, 24, 27, 22, 21, 20, 23, 18, 17, 16, 19) | ||
| 245 | #define _trans_cube_FUr fastcube( \ | ||
| 246 | 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) | ||
| 247 | #define _trans_cube_FUr_inverse fastcube( \ | ||
| 248 | 68, 70, 69, 71, 32, 34, 33, 35, 16, 19, 18, 17, 9, 8, 11, 10, 5, 4, 7, 6) | ||
| 249 | #define _trans_cube_FRr fastcube( \ | ||
| 250 | 32, 34, 35, 33, 70, 68, 69, 71, 8, 9, 10, 11, 16, 19, 18, 17, 20, 23, 22, 21) | ||
| 251 | #define _trans_cube_FRr_inverse fastcube( \ | ||
| 252 | 64, 67, 65, 66, 37, 38, 36, 39, 20, 23, 22, 21, 24, 27, 26, 25, 0, 1, 2, 3) | ||
| 253 | #define _trans_cube_FDr fastcube( \ | ||
| 254 | 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) | ||
| 255 | #define _trans_cube_FDr_inverse fastcube( \ | ||
| 256 | 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) | ||
| 257 | #define _trans_cube_FLr fastcube( \ | ||
| 258 | 34, 32, 33, 35, 68, 70, 71, 69, 9, 8, 11, 10, 19, 16, 17, 18, 22, 21, 20, 23) | ||
| 259 | #define _trans_cube_FLr_inverse fastcube( \ | ||
| 260 | 65, 66, 64, 67, 36, 39, 37, 38, 21, 22, 23, 20, 26, 25, 24, 27, 1, 0, 3, 2) | ||
| 261 | #define _trans_cube_BUr fastcube( \ | ||
| 262 | 69, 71, 68, 70, 33, 35, 32, 34, 17, 18, 19, 16, 11, 10, 9, 8, 4, 5, 6, 7) | ||
| 263 | #define _trans_cube_BUr_inverse fastcube( \ | ||
| 264 | 70, 68, 71, 69, 34, 32, 35, 33, 19, 16, 17, 18, 8, 9, 10, 11, 7, 6, 5, 4) | ||
| 265 | #define _trans_cube_BRr fastcube( \ | ||
| 266 | 35, 33, 32, 34, 69, 71, 70, 68, 11, 10, 9, 8, 18, 17, 16, 19, 23, 20, 21, 22) | ||
| 267 | #define _trans_cube_BRr_inverse fastcube( \ | ||
| 268 | 66, 65, 67, 64, 39, 36, 38, 37, 22, 21, 20, 23, 25, 26, 27, 24, 3, 2, 1, 0) | ||
| 269 | #define _trans_cube_BDr fastcube( \ | ||
| 270 | 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) | ||
| 271 | #define _trans_cube_BDr_inverse fastcube( \ | ||
| 272 | 71, 69, 70, 68, 35, 33, 34, 32, 18, 17, 16, 19, 10, 11, 8, 9, 6, 7, 4, 5) | ||
| 273 | #define _trans_cube_BLr fastcube( \ | ||
| 274 | 33, 35, 34, 32, 71, 69, 68, 70, 10, 11, 8, 9, 17, 18, 19, 16, 21, 22, 23, 20) | ||
| 275 | #define _trans_cube_BLr_inverse fastcube( \ | ||
| 276 | 67, 64, 66, 65, 38, 37, 39, 36, 23, 20, 21, 22, 27, 24, 25, 26, 2, 3, 0, 1) | ||
| 277 | #define _trans_cube_UFm fastcube( \ | ||
| 278 | 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) | ||
| 279 | #define _trans_cube_UFm_inverse fastcube( \ | ||
| 280 | 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 2, 3, 5, 4, 7, 6, 9, 8, 11, 10) | ||
| 281 | #define _trans_cube_ULm fastcube( \ | ||
| 282 | 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) | ||
| 283 | #define _trans_cube_ULm_inverse fastcube( \ | ||
| 284 | 0, 1, 3, 2, 5, 4, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3, 24, 27, 26, 25) | ||
| 285 | #define _trans_cube_UBm fastcube( \ | ||
| 286 | 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) | ||
| 287 | #define _trans_cube_UBm_inverse fastcube( \ | ||
| 288 | 5, 4, 7, 6, 1, 0, 3, 2, 1, 0, 3, 2, 4, 5, 6, 7, 11, 10, 9, 8) | ||
| 289 | #define _trans_cube_URm fastcube( \ | ||
| 290 | 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) | ||
| 291 | #define _trans_cube_URm_inverse fastcube( \ | ||
| 292 | 1, 0, 2, 3, 4, 5, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 26, 25, 24, 27) | ||
| 293 | #define _trans_cube_DFm fastcube( \ | ||
| 294 | 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) | ||
| 295 | #define _trans_cube_DFm_inverse fastcube( \ | ||
| 296 | 6, 7, 4, 5, 2, 3, 0, 1, 3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11) | ||
| 297 | #define _trans_cube_DLm fastcube( \ | ||
| 298 | 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) | ||
| 299 | #define _trans_cube_DLm_inverse fastcube( \ | ||
| 300 | 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) | ||
| 301 | #define _trans_cube_DBm fastcube( \ | ||
| 302 | 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) | ||
| 303 | #define _trans_cube_DBm_inverse fastcube( \ | ||
| 304 | 7, 6, 5, 4, 3, 2, 1, 0, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9) | ||
| 305 | #define _trans_cube_DRm fastcube( \ | ||
| 306 | 2, 3, 1, 0, 7, 6, 4, 5, 6, 7, 4, 5, 3, 2, 1, 0, 25, 26, 27, 24) | ||
| 307 | #define _trans_cube_DRm_inverse fastcube( \ | ||
| 308 | 3, 2, 0, 1, 6, 7, 5, 4, 7, 6, 5, 4, 2, 3, 0, 1, 27, 24, 25, 26) | ||
| 309 | #define _trans_cube_RUm fastcube( \ | ||
| 310 | 68, 71, 69, 70, 33, 34, 32, 35, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) | ||
| 311 | #define _trans_cube_RUm_inverse fastcube( \ | ||
| 312 | 70, 68, 69, 71, 32, 34, 35, 33, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) | ||
| 313 | #define _trans_cube_RFm fastcube( \ | ||
| 314 | 34, 33, 32, 35, 68, 71, 70, 69, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) | ||
| 315 | #define _trans_cube_RFm_inverse fastcube( \ | ||
| 316 | 66, 65, 64, 67, 36, 39, 38, 37, 25, 26, 27, 24, 22, 21, 20, 23, 19, 16, 17, 18) | ||
| 317 | #define _trans_cube_RDm fastcube( \ | ||
| 318 | 71, 68, 70, 69, 34, 33, 35, 32, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) | ||
| 319 | #define _trans_cube_RDm_inverse fastcube( \ | ||
| 320 | 71, 69, 68, 70, 33, 35, 34, 32, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) | ||
| 321 | #define _trans_cube_RBm fastcube( \ | ||
| 322 | 33, 34, 35, 32, 71, 68, 69, 70, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) | ||
| 323 | #define _trans_cube_RBm_inverse fastcube( \ | ||
| 324 | 67, 64, 65, 66, 37, 38, 39, 36, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) | ||
| 325 | #define _trans_cube_LUm fastcube( \ | ||
| 326 | 69, 70, 68, 71, 32, 35, 33, 34, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) | ||
| 327 | #define _trans_cube_LUm_inverse fastcube( \ | ||
| 328 | 68, 70, 71, 69, 34, 32, 33, 35, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) | ||
| 329 | #define _trans_cube_LFm fastcube( \ | ||
| 330 | 32, 35, 34, 33, 70, 69, 68, 71, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) | ||
| 331 | #define _trans_cube_LFm_inverse fastcube( \ | ||
| 332 | 64, 67, 66, 65, 38, 37, 36, 39, 24, 27, 26, 25, 20, 23, 22, 21, 16, 19, 18, 17) | ||
| 333 | #define _trans_cube_LDm fastcube( \ | ||
| 334 | 70, 69, 71, 68, 35, 32, 34, 33, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) | ||
| 335 | #define _trans_cube_LDm_inverse fastcube( \ | ||
| 336 | 69, 71, 70, 68, 35, 33, 32, 34, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) | ||
| 337 | #define _trans_cube_LBm fastcube( \ | ||
| 338 | 35, 32, 33, 34, 69, 70, 71, 68, 27, 24, 25, 26, 23, 20, 21, 22, 18, 17, 16, 19) | ||
| 339 | #define _trans_cube_LBm_inverse fastcube( \ | ||
| 340 | 65, 66, 67, 64, 39, 36, 37, 38, 26, 25, 24, 27, 21, 22, 23, 20, 17, 18, 19, 16) | ||
| 341 | #define _trans_cube_FUm fastcube( \ | ||
| 342 | 64, 66, 65, 67, 36, 38, 37, 39, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) | ||
| 343 | #define _trans_cube_FUm_inverse fastcube( \ | ||
| 344 | 32, 34, 33, 35, 68, 70, 69, 71, 16, 19, 18, 17, 8, 9, 10, 11, 4, 5, 6, 7) | ||
| 345 | #define _trans_cube_FRm fastcube( \ | ||
| 346 | 36, 38, 39, 37, 66, 64, 65, 67, 9, 8, 11, 10, 16, 19, 18, 17, 21, 22, 23, 20) | ||
| 347 | #define _trans_cube_FRm_inverse fastcube( \ | ||
| 348 | 37, 38, 36, 39, 64, 67, 65, 66, 20, 23, 22, 21, 27, 24, 25, 26, 1, 0, 3, 2) | ||
| 349 | #define _trans_cube_FDm fastcube( \ | ||
| 350 | 66, 64, 67, 65, 38, 36, 39, 37, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) | ||
| 351 | #define _trans_cube_FDm_inverse fastcube( \ | ||
| 352 | 33, 35, 32, 34, 69, 71, 68, 70, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) | ||
| 353 | #define _trans_cube_FLm fastcube( \ | ||
| 354 | 38, 36, 37, 39, 64, 66, 67, 65, 8, 9, 10, 11, 19, 16, 17, 18, 23, 20, 21, 22) | ||
| 355 | #define _trans_cube_FLm_inverse fastcube( \ | ||
| 356 | 36, 39, 37, 38, 65, 66, 64, 67, 21, 22, 23, 20, 25, 26, 27, 24, 0, 1, 2, 3) | ||
| 357 | #define _trans_cube_BUm fastcube( \ | ||
| 358 | 65, 67, 64, 66, 37, 39, 36, 38, 17, 18, 19, 16, 10, 11, 8, 9, 5, 4, 7, 6) | ||
| 359 | #define _trans_cube_BUm_inverse fastcube( \ | ||
| 360 | 34, 32, 35, 33, 70, 68, 71, 69, 19, 16, 17, 18, 9, 8, 11, 10, 6, 7, 4, 5) | ||
| 361 | #define _trans_cube_BRm fastcube( \ | ||
| 362 | 39, 37, 36, 38, 65, 67, 66, 64, 10, 11, 8, 9, 18, 17, 16, 19, 22, 21, 20, 23) | ||
| 363 | #define _trans_cube_BRm_inverse fastcube( \ | ||
| 364 | 39, 36, 38, 37, 66, 65, 67, 64, 22, 21, 20, 23, 26, 25, 24, 27, 2, 3, 0, 1) | ||
| 365 | #define _trans_cube_BDm fastcube( \ | ||
| 366 | 67, 65, 66, 64, 39, 37, 38, 36, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) | ||
| 367 | #define _trans_cube_BDm_inverse fastcube( \ | ||
| 368 | 35, 33, 34, 32, 71, 69, 70, 68, 18, 17, 16, 19, 11, 10, 9, 8, 7, 6, 5, 4) | ||
| 369 | #define _trans_cube_BLm fastcube( \ | ||
| 370 | 37, 39, 38, 36, 67, 65, 64, 66, 11, 10, 9, 8, 17, 18, 19, 16, 20, 23, 22, 21) | ||
| 371 | #define _trans_cube_BLm_inverse fastcube( \ | ||
| 372 | 38, 37, 39, 36, 67, 64, 66, 65, 23, 20, 21, 22, 24, 27, 26, 25, 3, 2, 1, 0) | ||
| 373 | |||
| 374 | _static const char *cornerstr[] = { | 133 | _static const char *cornerstr[] = { |
| 375 | [_c_ufr] = "UFR", | 134 | [_c_ufr] = "UFR", |
| 376 | [_c_ubl] = "UBL", | 135 | [_c_ubl] = "UBL", |
| @@ -19,7 +19,6 @@ | |||
| 19 | #define DBG_ASSERT(condition, retval, ...) | 19 | #define DBG_ASSERT(condition, retval, ...) |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | #include "cube.h" | ||
| 23 | #include "constants.h" | 22 | #include "constants.h" |
| 24 | 23 | ||
| 25 | #if defined(CUBE_AVX2) | 24 | #if defined(CUBE_AVX2) |
| @@ -32,8 +31,17 @@ | |||
| 32 | #include "cube_portable.h" | 31 | #include "cube_portable.h" |
| 33 | #endif | 32 | #endif |
| 34 | 33 | ||
| 35 | #include "cube_routines.h" | 34 | #include "constant_cubes.h" |
| 36 | #include "cube_transform.h" /* TODO: merge with cube_routines? */ | 35 | #include "cube_generic.h" |
| 36 | |||
| 37 | /* TODO: work in progress */ | ||
| 38 | #if 0 | ||
| 39 | #include "constant_cubes_transform.h" | ||
| 40 | #include "cube_transform.h" | ||
| 41 | #else | ||
| 42 | #include "cube_transform_with_switch.h" | ||
| 43 | #endif | ||
| 44 | |||
| 37 | #include "moves.h" | 45 | #include "moves.h" |
| 38 | #include "solve_h48.h" | 46 | #include "solve_h48.h" |
| 39 | #include "solve_generic.h" | 47 | #include "solve_generic.h" |
| @@ -25,23 +25,6 @@ you operate on the cube only via the functions provided below, you don't | |||
| 25 | need to worry about this. | 25 | need to worry about this. |
| 26 | ******************************************************************************/ | 26 | ******************************************************************************/ |
| 27 | 27 | ||
| 28 | typedef struct { | ||
| 29 | uint8_t corner[8]; | ||
| 30 | uint8_t edge[12]; | ||
| 31 | } cube_t; | ||
| 32 | |||
| 33 | /* Returns a copy of the solved cube */ | ||
| 34 | cube_t solvedcube(void); | ||
| 35 | |||
| 36 | /* Basic checks on the cube */ | ||
| 37 | bool isconsistent(cube_t); | ||
| 38 | bool issolvable(cube_t); | ||
| 39 | bool issolved(cube_t); | ||
| 40 | bool equal(cube_t, cube_t); | ||
| 41 | |||
| 42 | /* All functions can return an error value, use iserror() to check this */ | ||
| 43 | bool iserror(cube_t); | ||
| 44 | |||
| 45 | /* Apply the second cube on the first as a move sequence */ | 28 | /* Apply the second cube on the first as a move sequence */ |
| 46 | cube_t compose(cube_t, cube_t); | 29 | cube_t compose(cube_t, cube_t); |
| 47 | 30 | ||
diff --git a/src/cube_avx2.h b/src/cube_avx2.h index f3fe731..42ca9b5 100644 --- a/src/cube_avx2.h +++ b/src/cube_avx2.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | typedef __m256i cube_fast_t; | 1 | typedef __m256i cube_t; |
| 2 | 2 | ||
| 3 | #define _co2_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060)) | 3 | #define _co2_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060)) |
| 4 | #define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020)) | 4 | #define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020)) |
| @@ -8,117 +8,47 @@ typedef __m256i cube_fast_t; | |||
| 8 | #define _eo_avx2 \ | 8 | #define _eo_avx2 \ |
| 9 | _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0) | 9 | _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0) |
| 10 | 10 | ||
| 11 | _static_inline cube_fast_t fastcube( | 11 | #define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ |
| 12 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | 12 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ |
| 13 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | 13 | _mm256_set_epi8(0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, \ |
| 14 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | 14 | e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, \ |
| 15 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t | 15 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 16 | ); | 16 | c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr) |
| 17 | _static uint8_t corner(cube_fast_t, int); | 17 | #define zero _mm256_set_epi64x(0, 0, 0, 0) |
| 18 | _static uint8_t edge(cube_fast_t, int); | 18 | #define solved static_cube( \ |
| 19 | _static cube_fast_t cubetofast(cube_t); | 19 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) |
| 20 | _static cube_t fasttocube(cube_fast_t); | ||
| 21 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); | ||
| 22 | _static_inline bool issolved_fast(cube_fast_t); | ||
| 23 | _static_inline cube_fast_t invertco_fast(cube_fast_t); | ||
| 24 | _static_inline cube_fast_t compose_epcpeo(cube_fast_t, cube_fast_t); | ||
| 25 | _static_inline cube_fast_t compose_fast_edges(cube_fast_t, cube_fast_t); | ||
| 26 | _static_inline cube_fast_t compose_fast_corners(cube_fast_t, cube_fast_t); | ||
| 27 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | ||
| 28 | 20 | ||
| 29 | _static_inline int64_t coord_fast_co(cube_fast_t); | 21 | _static void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 30 | _static_inline int64_t coord_fast_csep(cube_fast_t); | 22 | _static_inline bool equal(cube_t, cube_t); |
| 31 | _static_inline int64_t coord_fast_cocsep(cube_fast_t); | 23 | _static_inline cube_t invertco(cube_t); |
| 32 | _static_inline int64_t coord_fast_eo(cube_fast_t); | 24 | _static_inline cube_t compose_epcpeo(cube_t, cube_t); |
| 33 | _static_inline int64_t coord_fast_esep(cube_fast_t); | 25 | _static_inline cube_t compose_edges(cube_t, cube_t); |
| 26 | _static_inline cube_t compose_corners(cube_t, cube_t); | ||
| 27 | _static_inline cube_t compose(cube_t, cube_t); | ||
| 34 | 28 | ||
| 35 | _static_inline void copy_corners_fast(cube_fast_t *, cube_fast_t); | 29 | _static_inline int64_t coord_co(cube_t); |
| 36 | _static_inline void copy_edges_fast(cube_fast_t *, cube_fast_t); | 30 | _static_inline int64_t coord_csep(cube_t); |
| 37 | _static_inline void set_eo_fast(cube_fast_t *, int64_t); | 31 | _static_inline int64_t coord_cocsep(cube_t); |
| 38 | _static_inline cube_fast_t invcoord_fast_esep(int64_t); | 32 | _static_inline int64_t coord_eo(cube_t); |
| 33 | _static_inline int64_t coord_esep(cube_t); | ||
| 39 | 34 | ||
| 40 | _static_inline cube_fast_t | 35 | _static_inline void copy_corners(cube_t *, cube_t); |
| 41 | fastcube( | 36 | _static_inline void copy_edges(cube_t *, cube_t); |
| 42 | uint8_t c_ufr, | 37 | _static_inline void set_eo(cube_t *, int64_t); |
| 43 | uint8_t c_ubl, | 38 | _static_inline cube_t invcoord_esep(int64_t); |
| 44 | uint8_t c_dfl, | ||
| 45 | uint8_t c_dbr, | ||
| 46 | uint8_t c_ufl, | ||
| 47 | uint8_t c_ubr, | ||
| 48 | uint8_t c_dfr, | ||
| 49 | uint8_t c_dbl, | ||
| 50 | 39 | ||
| 51 | uint8_t e_uf, | 40 | _static void |
| 52 | uint8_t e_ub, | 41 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 53 | uint8_t e_db, | ||
| 54 | uint8_t e_df, | ||
| 55 | uint8_t e_ur, | ||
| 56 | uint8_t e_ul, | ||
| 57 | uint8_t e_dl, | ||
| 58 | uint8_t e_dr, | ||
| 59 | uint8_t e_fr, | ||
| 60 | uint8_t e_fl, | ||
| 61 | uint8_t e_bl, | ||
| 62 | uint8_t e_br | ||
| 63 | ) | ||
| 64 | { | ||
| 65 | return _mm256_set_epi8( | ||
| 66 | 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, | ||
| 67 | e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, | ||
| 68 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 69 | c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr | ||
| 70 | ); | ||
| 71 | } | ||
| 72 | |||
| 73 | _static uint8_t | ||
| 74 | corner(cube_fast_t c, int i) | ||
| 75 | { | ||
| 76 | uint8_t aux[32]; | ||
| 77 | |||
| 78 | DBG_ASSERT(i >= 0 && i < 8, 255, "Corner must be between 0 and 7\n"); | ||
| 79 | _mm256_storeu_si256((__m256i_u *)aux, c); | ||
| 80 | |||
| 81 | return aux[i]; | ||
| 82 | } | ||
| 83 | |||
| 84 | _static uint8_t | ||
| 85 | edge(cube_fast_t c, int i) | ||
| 86 | { | 42 | { |
| 87 | uint8_t aux[32]; | 43 | uint8_t aux[32]; |
| 88 | 44 | ||
| 89 | DBG_ASSERT(i >= 0 && i < 12, 255, "Edge must be between 0 and 11\n"); | 45 | _mm256_storeu_si256((__m256i_u *)aux, *cube); |
| 90 | _mm256_storeu_si256((__m256i_u *)aux, c); | 46 | memcpy(c, aux, 8); |
| 91 | 47 | memcpy(e, aux+16, 12); | |
| 92 | return aux[i+16]; | ||
| 93 | } | ||
| 94 | |||
| 95 | _static cube_fast_t | ||
| 96 | cubetofast(cube_t a) | ||
| 97 | { | ||
| 98 | uint8_t aux[32]; | ||
| 99 | |||
| 100 | memset(aux, 0, 32); | ||
| 101 | memcpy(aux, &a.corner, 8); | ||
| 102 | memcpy(aux + 16, &a.edge, 12); | ||
| 103 | |||
| 104 | return _mm256_loadu_si256((__m256i_u *)&aux); | ||
| 105 | } | ||
| 106 | |||
| 107 | _static cube_t | ||
| 108 | fasttocube(cube_fast_t c) | ||
| 109 | { | ||
| 110 | cube_t a; | ||
| 111 | uint8_t aux[32]; | ||
| 112 | |||
| 113 | _mm256_storeu_si256((__m256i_u *)aux, c); | ||
| 114 | memcpy(&a.corner, aux, 8); | ||
| 115 | memcpy(&a.edge, aux + 16, 12); | ||
| 116 | |||
| 117 | return a; | ||
| 118 | } | 48 | } |
| 119 | 49 | ||
| 120 | _static_inline bool | 50 | _static_inline bool |
| 121 | equal_fast(cube_fast_t c1, cube_fast_t c2) | 51 | equal(cube_t c1, cube_t c2) |
| 122 | { | 52 | { |
| 123 | int32_t mask; | 53 | int32_t mask; |
| 124 | __m256i cmp; | 54 | __m256i cmp; |
| @@ -129,16 +59,10 @@ equal_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 129 | return mask == ~0; | 59 | return mask == ~0; |
| 130 | } | 60 | } |
| 131 | 61 | ||
| 132 | _static_inline bool | 62 | _static_inline cube_t |
| 133 | issolved_fast(cube_fast_t cube) | 63 | invertco(cube_t c) |
| 134 | { | ||
| 135 | return equal_fast(cube, solved_fast); | ||
| 136 | } | ||
| 137 | |||
| 138 | _static_inline cube_fast_t | ||
| 139 | invertco_fast(cube_fast_t c) | ||
| 140 | { | 64 | { |
| 141 | cube_fast_t co, shleft, shright, summed, newco, cleanco, ret; | 65 | cube_t co, shleft, shright, summed, newco, cleanco, ret; |
| 142 | 66 | ||
| 143 | co = _mm256_and_si256(c, _co2_avx2); | 67 | co = _mm256_and_si256(c, _co2_avx2); |
| 144 | shleft = _mm256_slli_epi32(co, 1); | 68 | shleft = _mm256_slli_epi32(co, 1); |
| @@ -151,10 +75,10 @@ invertco_fast(cube_fast_t c) | |||
| 151 | return ret; | 75 | return ret; |
| 152 | } | 76 | } |
| 153 | 77 | ||
| 154 | _static_inline cube_fast_t | 78 | _static_inline cube_t |
| 155 | compose_epcpeo(cube_fast_t c1, cube_fast_t c2) | 79 | compose_epcpeo(cube_t c1, cube_t c2) |
| 156 | { | 80 | { |
| 157 | cube_fast_t b, s, eo2; | 81 | cube_t b, s, eo2; |
| 158 | 82 | ||
| 159 | /* Permute and clean unused bits */ | 83 | /* Permute and clean unused bits */ |
| 160 | s = _mm256_shuffle_epi8(c1, c2); | 84 | s = _mm256_shuffle_epi8(c1, c2); |
| @@ -171,27 +95,27 @@ compose_epcpeo(cube_fast_t c1, cube_fast_t c2) | |||
| 171 | return s; | 95 | return s; |
| 172 | } | 96 | } |
| 173 | 97 | ||
| 174 | _static_inline cube_fast_t | 98 | _static_inline cube_t |
| 175 | compose_fast_edges(cube_fast_t c1, cube_fast_t c2) | 99 | compose_edges(cube_t c1, cube_t c2) |
| 176 | { | 100 | { |
| 177 | return compose_epcpeo(c1, c2); | 101 | return compose_epcpeo(c1, c2); |
| 178 | } | 102 | } |
| 179 | 103 | ||
| 180 | _static_inline cube_fast_t | 104 | _static_inline cube_t |
| 181 | compose_fast_corners(cube_fast_t c1, cube_fast_t c2) | 105 | compose_corners(cube_t c1, cube_t c2) |
| 182 | { | 106 | { |
| 183 | /* | 107 | /* |
| 184 | * We do a full compose. Minor optimizations are possible, like | 108 | * We do a full compose. Minor optimizations are possible, like |
| 185 | * saving one instruction by not doing EO, but it should not | 109 | * saving one instruction by not doing EO, but it should not |
| 186 | * be significant. | 110 | * be significant. |
| 187 | */ | 111 | */ |
| 188 | return compose_fast(c1, c2); | 112 | return compose(c1, c2); |
| 189 | } | 113 | } |
| 190 | 114 | ||
| 191 | _static_inline cube_fast_t | 115 | _static_inline cube_t |
| 192 | compose_fast(cube_fast_t c1, cube_fast_t c2) | 116 | compose(cube_t c1, cube_t c2) |
| 193 | { | 117 | { |
| 194 | cube_fast_t s, co1, co2, aux, auy1, auy2, auz1, auz2; | 118 | cube_t s, co1, co2, aux, auy1, auy2, auz1, auz2; |
| 195 | 119 | ||
| 196 | s = compose_epcpeo(c1, c2); | 120 | s = compose_epcpeo(c1, c2); |
| 197 | 121 | ||
| @@ -212,9 +136,9 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 212 | } | 136 | } |
| 213 | 137 | ||
| 214 | _static_inline int64_t | 138 | _static_inline int64_t |
| 215 | coord_fast_co(cube_fast_t c) | 139 | coord_co(cube_t c) |
| 216 | { | 140 | { |
| 217 | cube_fast_t co; | 141 | cube_t co; |
| 218 | int64_t mem[4], ret, i, p; | 142 | int64_t mem[4], ret, i, p; |
| 219 | 143 | ||
| 220 | co = _mm256_and_si256(c, _co2_avx2); | 144 | co = _mm256_and_si256(c, _co2_avx2); |
| @@ -228,9 +152,9 @@ coord_fast_co(cube_fast_t c) | |||
| 228 | } | 152 | } |
| 229 | 153 | ||
| 230 | _static_inline int64_t | 154 | _static_inline int64_t |
| 231 | coord_fast_csep(cube_fast_t c) | 155 | coord_csep(cube_t c) |
| 232 | { | 156 | { |
| 233 | cube_fast_t cp, shifted; | 157 | cube_t cp, shifted; |
| 234 | int64_t mask; | 158 | int64_t mask; |
| 235 | 159 | ||
| 236 | cp = _mm256_and_si256(c, _cp_avx2); | 160 | cp = _mm256_and_si256(c, _cp_avx2); |
| @@ -241,15 +165,15 @@ coord_fast_csep(cube_fast_t c) | |||
| 241 | } | 165 | } |
| 242 | 166 | ||
| 243 | _static_inline int64_t | 167 | _static_inline int64_t |
| 244 | coord_fast_cocsep(cube_fast_t c) | 168 | coord_cocsep(cube_t c) |
| 245 | { | 169 | { |
| 246 | return (coord_fast_co(c) << 7) + coord_fast_csep(c); | 170 | return (coord_co(c) << 7) + coord_csep(c); |
| 247 | } | 171 | } |
| 248 | 172 | ||
| 249 | _static_inline int64_t | 173 | _static_inline int64_t |
| 250 | coord_fast_eo(cube_fast_t c) | 174 | coord_eo(cube_t c) |
| 251 | { | 175 | { |
| 252 | cube_fast_t eo, shifted; | 176 | cube_t eo, shifted; |
| 253 | int64_t mask; | 177 | int64_t mask; |
| 254 | 178 | ||
| 255 | eo = _mm256_and_si256(c, _eo_avx2); | 179 | eo = _mm256_and_si256(c, _eo_avx2); |
| @@ -260,9 +184,9 @@ coord_fast_eo(cube_fast_t c) | |||
| 260 | } | 184 | } |
| 261 | 185 | ||
| 262 | _static_inline int64_t | 186 | _static_inline int64_t |
| 263 | coord_fast_esep(cube_fast_t c) | 187 | coord_esep(cube_t c) |
| 264 | { | 188 | { |
| 265 | cube_fast_t ep; | 189 | cube_t ep; |
| 266 | int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; | 190 | int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 267 | 191 | ||
| 268 | ep = _mm256_and_si256(c, _ep_avx2); | 192 | ep = _mm256_and_si256(c, _ep_avx2); |
| @@ -291,19 +215,19 @@ coord_fast_esep(cube_fast_t c) | |||
| 291 | } | 215 | } |
| 292 | 216 | ||
| 293 | _static_inline void | 217 | _static_inline void |
| 294 | copy_corners_fast(cube_fast_t *dest, cube_fast_t src) | 218 | copy_corners(cube_t *dest, cube_t src) |
| 295 | { | 219 | { |
| 296 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); | 220 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); |
| 297 | } | 221 | } |
| 298 | 222 | ||
| 299 | _static_inline void | 223 | _static_inline void |
| 300 | copy_edges_fast(cube_fast_t *dest, cube_fast_t src) | 224 | copy_edges(cube_t *dest, cube_t src) |
| 301 | { | 225 | { |
| 302 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); | 226 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); |
| 303 | } | 227 | } |
| 304 | 228 | ||
| 305 | _static_inline void | 229 | _static_inline void |
| 306 | set_eo_fast(cube_fast_t *cube, int64_t eo) | 230 | set_eo(cube_t *cube, int64_t eo) |
| 307 | { | 231 | { |
| 308 | int64_t eo12, eotop, eobot; | 232 | int64_t eo12, eotop, eobot; |
| 309 | __m256i veo; | 233 | __m256i veo; |
| @@ -327,10 +251,10 @@ set_eo_fast(cube_fast_t *cube, int64_t eo) | |||
| 327 | *cube = _mm256_or_si256(*cube, veo); | 251 | *cube = _mm256_or_si256(*cube, veo); |
| 328 | } | 252 | } |
| 329 | 253 | ||
| 330 | _static_inline cube_fast_t | 254 | _static_inline cube_t |
| 331 | invcoord_fast_esep(int64_t esep) | 255 | invcoord_esep(int64_t esep) |
| 332 | { | 256 | { |
| 333 | cube_fast_t eee, ret; | 257 | cube_t eee, ret; |
| 334 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1, set1, set2; | 258 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1, set1, set2; |
| 335 | uint8_t mem[32]; | 259 | uint8_t mem[32]; |
| 336 | uint8_t slice[3] = {0}; | 260 | uint8_t slice[3] = {0}; |
| @@ -356,9 +280,9 @@ invcoord_fast_esep(int64_t esep) | |||
| 356 | mem[i+16] = (slice[s]++) | (uint8_t)(s << 2); | 280 | mem[i+16] = (slice[s]++) | (uint8_t)(s << 2); |
| 357 | } | 281 | } |
| 358 | 282 | ||
| 359 | ret = cubetofast(solved); | 283 | ret = solved; |
| 360 | eee = _mm256_loadu_si256((__m256i_u *)&mem); | 284 | eee = _mm256_loadu_si256((__m256i_u *)&mem); |
| 361 | copy_edges_fast(&ret, eee); | 285 | copy_edges(&ret, eee); |
| 362 | 286 | ||
| 363 | return ret; | 287 | return ret; |
| 364 | } | 288 | } |
diff --git a/src/cube_routines.h b/src/cube_generic.h index 3730e90..a90aa17 100644 --- a/src/cube_routines.h +++ b/src/cube_generic.h | |||
| @@ -1,15 +1,18 @@ | |||
| 1 | #define _move(M, c) compose_fast(c, _move_cube_ ## M) | 1 | #define _move(M, c) compose(c, _move_cube_ ## M) |
| 2 | #define _premove(M, c) compose_fast(_move_cube_ ## M, c) | 2 | #define _premove(M, c) compose(_move_cube_ ## M, c) |
| 3 | 3 | ||
| 4 | _static cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | ||
| 4 | _static int permsign(uint8_t *, int); | 5 | _static int permsign(uint8_t *, int); |
| 5 | _static uint8_t readco(const char *); | 6 | _static uint8_t readco(const char *); |
| 6 | _static uint8_t readcp(const char *); | 7 | _static uint8_t readcp(const char *); |
| 7 | _static uint8_t readeo(const char *); | 8 | _static uint8_t readeo(const char *); |
| 8 | _static uint8_t readep(const char *); | 9 | _static uint8_t readep(const char *); |
| 10 | _static cube_t readcube_B32(const char *); | ||
| 9 | _static cube_t readcube_H48(const char *); | 11 | _static cube_t readcube_H48(const char *); |
| 10 | _static uint8_t readpiece_LST(const char **); | 12 | _static uint8_t readpiece_LST(const char **); |
| 11 | _static cube_t readcube_LST(const char *); | 13 | _static cube_t readcube_LST(const char *); |
| 12 | _static int writepiece_LST(uint8_t, char *); | 14 | _static int writepiece_LST(uint8_t, char *); |
| 15 | _static void writecube_B32(cube_t, char *); | ||
| 13 | _static void writecube_H48(cube_t, char *); | 16 | _static void writecube_H48(cube_t, char *); |
| 14 | _static void writecube_LST(cube_t, char *); | 17 | _static void writecube_LST(cube_t, char *); |
| 15 | _static uint8_t b32toedge(char); | 18 | _static uint8_t b32toedge(char); |
| @@ -21,10 +24,31 @@ _static uint8_t readmodifier(char); | |||
| 21 | _static uint8_t readtrans(const char *); | 24 | _static uint8_t readtrans(const char *); |
| 22 | _static int writemoves(uint8_t *, int, char *); | 25 | _static int writemoves(uint8_t *, int, char *); |
| 23 | _static void writetrans(uint8_t, char *); | 26 | _static void writetrans(uint8_t, char *); |
| 24 | _static cube_fast_t move(cube_fast_t, uint8_t); | 27 | _static cube_t move(cube_t, uint8_t); |
| 25 | _static cube_fast_t transform_edges(cube_fast_t, uint8_t); | 28 | _static cube_t transform_edges(cube_t, uint8_t); |
| 26 | _static cube_fast_t transform_corners(cube_fast_t, uint8_t); | 29 | _static cube_t transform_corners(cube_t, uint8_t); |
| 27 | _static cube_fast_t transform(cube_fast_t, uint8_t); | 30 | _static cube_t transform(cube_t, uint8_t); |
| 31 | |||
| 32 | _static struct { | ||
| 33 | const char *name; | ||
| 34 | cube_t (*read)(const char *); | ||
| 35 | void (*write)(cube_t, char *); | ||
| 36 | } ioformat[] = | ||
| 37 | { | ||
| 38 | { .name = "B32", .read = readcube_B32, .write = writecube_B32 }, | ||
| 39 | { .name = "LST", .read = readcube_LST, .write = writecube_LST }, | ||
| 40 | { .name = "H48", .read = readcube_H48, .write = writecube_H48 }, | ||
| 41 | { .name = "NONE", .read = NULL, .write = NULL }, | ||
| 42 | }; | ||
| 43 | |||
| 44 | _static_inline cube_t | ||
| 45 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | ||
| 46 | { | ||
| 47 | return static_cube( | ||
| 48 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], | ||
| 49 | e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], | ||
| 50 | e[8], e[9], e[10], e[11]); | ||
| 51 | } | ||
| 28 | 52 | ||
| 29 | cube_t | 53 | cube_t |
| 30 | solvedcube(void) | 54 | solvedcube(void) |
| @@ -35,13 +59,15 @@ solvedcube(void) | |||
| 35 | bool | 59 | bool |
| 36 | isconsistent(cube_t cube) | 60 | isconsistent(cube_t cube) |
| 37 | { | 61 | { |
| 38 | uint8_t i, p, e, piece; | 62 | uint8_t i, p, e, piece, corner[8], edge[12]; |
| 39 | bool found[12]; | 63 | bool found[12]; |
| 40 | 64 | ||
| 65 | pieces(&cube, corner, edge); | ||
| 66 | |||
| 41 | for (i = 0; i < 12; i++) | 67 | for (i = 0; i < 12; i++) |
| 42 | found[i] = false; | 68 | found[i] = false; |
| 43 | for (i = 0; i < 12; i++) { | 69 | for (i = 0; i < 12; i++) { |
| 44 | piece = cube.edge[i]; | 70 | piece = edge[i]; |
| 45 | p = piece & _pbits; | 71 | p = piece & _pbits; |
| 46 | e = piece & _eobit; | 72 | e = piece & _eobit; |
| 47 | if (p >= 12) | 73 | if (p >= 12) |
| @@ -57,7 +83,7 @@ isconsistent(cube_t cube) | |||
| 57 | for (i = 0; i < 8; i++) | 83 | for (i = 0; i < 8; i++) |
| 58 | found[i] = false; | 84 | found[i] = false; |
| 59 | for (i = 0; i < 8; i++) { | 85 | for (i = 0; i < 8; i++) { |
| 60 | piece = cube.corner[i]; | 86 | piece = corner[i]; |
| 61 | p = piece & _pbits; | 87 | p = piece & _pbits; |
| 62 | e = piece & _cobits; | 88 | e = piece & _cobits; |
| 63 | if (p >= 8) | 89 | if (p >= 8) |
| @@ -89,22 +115,23 @@ inconsistent_co: | |||
| 89 | bool | 115 | bool |
| 90 | issolvable(cube_t cube) | 116 | issolvable(cube_t cube) |
| 91 | { | 117 | { |
| 92 | uint8_t i, eo, co, piece, edges[12], corners[8]; | 118 | uint8_t i, eo, co, piece, edge[12], corner[8], ep[12], cp[8]; |
| 93 | 119 | ||
| 94 | DBG_ASSERT(isconsistent(cube), false, | 120 | DBG_ASSERT(isconsistent(cube), false, |
| 95 | "issolvable: cube is inconsistent\n"); | 121 | "issolvable: cube is inconsistent\n"); |
| 96 | 122 | ||
| 123 | pieces(&cube, corner, edge); | ||
| 97 | for (i = 0; i < 12; i++) | 124 | for (i = 0; i < 12; i++) |
| 98 | edges[i] = cube.edge[i] & _pbits; | 125 | ep[i] = edge[i] & _pbits; |
| 99 | for (i = 0; i < 8; i++) | 126 | for (i = 0; i < 8; i++) |
| 100 | corners[i] = cube.corner[i] & _pbits; | 127 | cp[i] = corner[i] & _pbits; |
| 101 | 128 | ||
| 102 | if (permsign(edges, 12) != permsign(corners, 8)) | 129 | if (permsign(ep, 12) != permsign(cp, 8)) |
| 103 | goto issolvable_parity; | 130 | goto issolvable_parity; |
| 104 | 131 | ||
| 105 | eo = 0; | 132 | eo = 0; |
| 106 | for (i = 0; i < 12; i++) { | 133 | for (i = 0; i < 12; i++) { |
| 107 | piece = cube.edge[i]; | 134 | piece = edge[i]; |
| 108 | eo += (piece & _eobit) >> _eoshift; | 135 | eo += (piece & _eobit) >> _eoshift; |
| 109 | } | 136 | } |
| 110 | if (eo % 2 != 0) | 137 | if (eo % 2 != 0) |
| @@ -112,7 +139,7 @@ issolvable(cube_t cube) | |||
| 112 | 139 | ||
| 113 | co = 0; | 140 | co = 0; |
| 114 | for (i = 0; i < 8; i++) { | 141 | for (i = 0; i < 8; i++) { |
| 115 | piece = cube.corner[i]; | 142 | piece = corner[i]; |
| 116 | co += (piece & _cobits) >> _coshift; | 143 | co += (piece & _cobits) >> _coshift; |
| 117 | } | 144 | } |
| 118 | if (co % 3 != 0) | 145 | if (co % 3 != 0) |
| @@ -138,73 +165,45 @@ issolved(cube_t cube) | |||
| 138 | } | 165 | } |
| 139 | 166 | ||
| 140 | bool | 167 | bool |
| 141 | equal(cube_t c1, cube_t c2) | ||
| 142 | { | ||
| 143 | int i; | ||
| 144 | bool ret; | ||
| 145 | |||
| 146 | ret = true; | ||
| 147 | for (i = 0; i < 8; i++) | ||
| 148 | ret = ret && c1.corner[i] == c2.corner[i]; | ||
| 149 | for (i = 0; i < 12; i++) | ||
| 150 | ret = ret && c1.edge[i] == c2.edge[i]; | ||
| 151 | |||
| 152 | return ret; | ||
| 153 | } | ||
| 154 | |||
| 155 | bool | ||
| 156 | iserror(cube_t cube) | 168 | iserror(cube_t cube) |
| 157 | { | 169 | { |
| 158 | return equal(cube, zero); | 170 | return equal(cube, zero); |
| 159 | } | 171 | } |
| 160 | 172 | ||
| 161 | cube_t | 173 | cube_t |
| 162 | compose(cube_t c1, cube_t c2) | ||
| 163 | { | ||
| 164 | DBG_ASSERT(isconsistent(c1) && isconsistent(c2), | ||
| 165 | zero, "compose error: inconsistent cube\n") | ||
| 166 | |||
| 167 | return fasttocube(compose_fast(cubetofast(c1), cubetofast(c2))); | ||
| 168 | } | ||
| 169 | |||
| 170 | cube_t | ||
| 171 | inverse(cube_t cube) | 174 | inverse(cube_t cube) |
| 172 | { | 175 | { |
| 173 | cube_t ret; | 176 | uint8_t i, piece, orien, e[12], c[8], edge[12], corner[8]; |
| 174 | uint8_t i, piece, orien; | ||
| 175 | 177 | ||
| 176 | DBG_ASSERT(isconsistent(cube), zero, | 178 | DBG_ASSERT(isconsistent(cube), zero, |
| 177 | "inverse error: inconsistent cube\n"); | 179 | "inverse error: inconsistent cube\n"); |
| 178 | 180 | ||
| 179 | ret = zero; | 181 | pieces(&cube, corner, edge); |
| 180 | 182 | ||
| 181 | for (i = 0; i < 12; i++) { | 183 | for (i = 0; i < 12; i++) { |
| 182 | piece = cube.edge[i]; | 184 | piece = edge[i]; |
| 183 | orien = piece & _eobit; | 185 | orien = piece & _eobit; |
| 184 | ret.edge[piece & _pbits] = i | orien; | 186 | e[piece & _pbits] = i | orien; |
| 185 | } | 187 | } |
| 186 | 188 | ||
| 187 | for (i = 0; i < 8; i++) { | 189 | for (i = 0; i < 8; i++) { |
| 188 | piece = cube.corner[i]; | 190 | piece = corner[i]; |
| 189 | orien = ((piece << 1) | (piece >> 1)) & _cobits2; | 191 | orien = ((piece << 1) | (piece >> 1)) & _cobits2; |
| 190 | ret.corner[piece & _pbits] = i | orien; | 192 | c[piece & _pbits] = i | orien; |
| 191 | } | 193 | } |
| 192 | 194 | ||
| 193 | return ret; | 195 | return cubefromarray(c, e); |
| 194 | } | 196 | } |
| 195 | 197 | ||
| 196 | cube_t | 198 | cube_t |
| 197 | applymoves(cube_t cube, const char *buf) | 199 | applymoves(cube_t cube, const char *buf) |
| 198 | { | 200 | { |
| 199 | cube_fast_t fast; | ||
| 200 | uint8_t r, m; | 201 | uint8_t r, m; |
| 201 | const char *b; | 202 | const char *b; |
| 202 | 203 | ||
| 203 | DBG_ASSERT(isconsistent(cube), zero, | 204 | DBG_ASSERT(isconsistent(cube), zero, |
| 204 | "move error: inconsistent cube\n"); | 205 | "move error: inconsistent cube\n"); |
| 205 | 206 | ||
| 206 | fast = cubetofast(cube); | ||
| 207 | |||
| 208 | for (b = buf; *b != '\0'; b++) { | 207 | for (b = buf; *b != '\0'; b++) { |
| 209 | while (*b == ' ' || *b == '\t' || *b == '\n') | 208 | while (*b == ' ' || *b == '\t' || *b == '\n') |
| 210 | b++; | 209 | b++; |
| @@ -214,11 +213,11 @@ applymoves(cube_t cube, const char *buf) | |||
| 214 | goto applymoves_error; | 213 | goto applymoves_error; |
| 215 | if ((m = readmodifier(*(b+1))) != 0) | 214 | if ((m = readmodifier(*(b+1))) != 0) |
| 216 | b++; | 215 | b++; |
| 217 | fast = move(fast, r + m); | 216 | cube = move(cube, r + m); |
| 218 | } | 217 | } |
| 219 | 218 | ||
| 220 | applymoves_finish: | 219 | applymoves_finish: |
| 221 | return fasttocube(fast); | 220 | return cube; |
| 222 | 221 | ||
| 223 | applymoves_error: | 222 | applymoves_error: |
| 224 | DBG_LOG("applymoves error\n"); | 223 | DBG_LOG("applymoves error\n"); |
| @@ -228,34 +227,27 @@ applymoves_error: | |||
| 228 | cube_t | 227 | cube_t |
| 229 | applytrans(cube_t cube, const char *buf) | 228 | applytrans(cube_t cube, const char *buf) |
| 230 | { | 229 | { |
| 231 | cube_fast_t fast; | ||
| 232 | uint8_t t; | 230 | uint8_t t; |
| 233 | 231 | ||
| 234 | DBG_ASSERT(isconsistent(cube), zero, | 232 | DBG_ASSERT(isconsistent(cube), zero, |
| 235 | "transformation error: inconsistent cube\n"); | 233 | "transformation error: inconsistent cube\n"); |
| 236 | 234 | ||
| 237 | t = readtrans(buf); | 235 | t = readtrans(buf); |
| 238 | fast = cubetofast(cube); | ||
| 239 | fast = transform(fast, t); | ||
| 240 | 236 | ||
| 241 | return fasttocube(fast); | 237 | return transform(cube, t); |
| 242 | } | 238 | } |
| 243 | 239 | ||
| 244 | cube_t | 240 | cube_t |
| 245 | readcube(const char *format, const char *buf) | 241 | readcube(const char *format, const char *buf) |
| 246 | { | 242 | { |
| 247 | cube_t cube; | 243 | int i; |
| 248 | 244 | ||
| 249 | if (!strcmp(format, "H48")) { | 245 | for (i = 0; ioformat[i].read != NULL; i++) |
| 250 | cube = readcube_H48(buf); | 246 | if (!strcmp(format, ioformat[i].name)) |
| 251 | } else if (!strcmp(format, "LST")) { | 247 | return ioformat[i].read(buf); |
| 252 | cube = readcube_LST(buf); | ||
| 253 | } else { | ||
| 254 | DBG_LOG("Cannot read cube in the given format\n"); | ||
| 255 | cube = zero; | ||
| 256 | } | ||
| 257 | 248 | ||
| 258 | return cube; | 249 | DBG_LOG("Cannot read cube in the given format\n"); |
| 250 | return zero; | ||
| 259 | } | 251 | } |
| 260 | 252 | ||
| 261 | void | 253 | void |
| @@ -269,16 +261,16 @@ writecube(const char *format, cube_t cube, char *buf) | |||
| 269 | goto writecube_error; | 261 | goto writecube_error; |
| 270 | } | 262 | } |
| 271 | 263 | ||
| 272 | if (!strcmp(format, "H48")) { | 264 | int i; |
| 273 | writecube_H48(cube, buf); | 265 | |
| 274 | } else if (!strcmp(format, "LST")) { | 266 | for (i = 0; ioformat[i].write != NULL; i++) { |
| 275 | writecube_LST(cube, buf); | 267 | if (!strcmp(format, ioformat[i].name)) { |
| 276 | } else { | 268 | ioformat[i].write(cube, buf); |
| 277 | errormsg = "ERROR: cannot write cube in the given format"; | 269 | return; |
| 278 | goto writecube_error; | 270 | } |
| 279 | } | 271 | } |
| 280 | 272 | ||
| 281 | return; | 273 | errormsg = "ERROR: cannot write cube in the given format"; |
| 282 | 274 | ||
| 283 | writecube_error: | 275 | writecube_error: |
| 284 | DBG_LOG("writecube error, see stdout for details\n"); | 276 | DBG_LOG("writecube error, see stdout for details\n"); |
| @@ -355,11 +347,31 @@ readep(const char *str) | |||
| 355 | } | 347 | } |
| 356 | 348 | ||
| 357 | _static cube_t | 349 | _static cube_t |
| 350 | readcube_B32(const char *buf) | ||
| 351 | { | ||
| 352 | int i; | ||
| 353 | uint8_t c[8], e[12]; | ||
| 354 | |||
| 355 | for (i = 0; i < 8; i++) { | ||
| 356 | c[i] = b32tocorner(buf[i]); | ||
| 357 | DBG_ASSERT(c[i] < 255, zero, | ||
| 358 | "Error reading B32 corner %d (char %d)\n", i, i); | ||
| 359 | } | ||
| 360 | |||
| 361 | for (i = 0; i < 12; i++) { | ||
| 362 | e[i] = b32toedge(buf[i+9]); | ||
| 363 | DBG_ASSERT(e[i] < 255, zero, | ||
| 364 | "Error reading B32 edge %d (char %d)\n", i, i+9); | ||
| 365 | } | ||
| 366 | |||
| 367 | return cubefromarray(c, e); | ||
| 368 | } | ||
| 369 | |||
| 370 | _static cube_t | ||
| 358 | readcube_H48(const char *buf) | 371 | readcube_H48(const char *buf) |
| 359 | { | 372 | { |
| 360 | int i; | 373 | int i; |
| 361 | uint8_t piece, orient; | 374 | uint8_t piece, orient, c[8], e[12]; |
| 362 | cube_t ret = {0}; | ||
| 363 | const char *b; | 375 | const char *b; |
| 364 | 376 | ||
| 365 | b = buf; | 377 | b = buf; |
| @@ -373,7 +385,7 @@ readcube_H48(const char *buf) | |||
| 373 | if ((orient = readeo(b)) == _error) | 385 | if ((orient = readeo(b)) == _error) |
| 374 | return zero; | 386 | return zero; |
| 375 | b++; | 387 | b++; |
| 376 | ret.edge[i] = piece | orient; | 388 | e[i] = piece | orient; |
| 377 | } | 389 | } |
| 378 | for (i = 0; i < 8; i++) { | 390 | for (i = 0; i < 8; i++) { |
| 379 | while (*b == ' ' || *b == '\t' || *b == '\n') | 391 | while (*b == ' ' || *b == '\t' || *b == '\n') |
| @@ -384,10 +396,10 @@ readcube_H48(const char *buf) | |||
| 384 | if ((orient = readco(b)) == _error) | 396 | if ((orient = readco(b)) == _error) |
| 385 | return zero; | 397 | return zero; |
| 386 | b++; | 398 | b++; |
| 387 | ret.corner[i] = piece | orient; | 399 | c[i] = piece | orient; |
| 388 | } | 400 | } |
| 389 | 401 | ||
| 390 | return ret; | 402 | return cubefromarray(c, e); |
| 391 | } | 403 | } |
| 392 | 404 | ||
| 393 | _static uint8_t | 405 | _static uint8_t |
| @@ -411,15 +423,15 @@ _static cube_t | |||
| 411 | readcube_LST(const char *buf) | 423 | readcube_LST(const char *buf) |
| 412 | { | 424 | { |
| 413 | int i; | 425 | int i; |
| 414 | cube_t ret = {0}; | 426 | uint8_t c[8], e[12]; |
| 415 | 427 | ||
| 416 | for (i = 0; i < 8; i++) | 428 | for (i = 0; i < 8; i++) |
| 417 | ret.corner[i] = readpiece_LST(&buf); | 429 | c[i] = readpiece_LST(&buf); |
| 418 | 430 | ||
| 419 | for (i = 0; i < 12; i++) | 431 | for (i = 0; i < 12; i++) |
| 420 | ret.edge[i] = readpiece_LST(&buf); | 432 | e[i] = readpiece_LST(&buf); |
| 421 | 433 | ||
| 422 | return ret; | 434 | return cubefromarray(c, e); |
| 423 | } | 435 | } |
| 424 | 436 | ||
| 425 | _static int | 437 | _static int |
| @@ -447,13 +459,34 @@ writepiece_LST(uint8_t piece, char *buf) | |||
| 447 | } | 459 | } |
| 448 | 460 | ||
| 449 | _static void | 461 | _static void |
| 462 | writecube_B32(cube_t cube, char *buf) | ||
| 463 | { | ||
| 464 | int i; | ||
| 465 | uint8_t corner[8], edge[12]; | ||
| 466 | |||
| 467 | pieces(&cube, corner, edge); | ||
| 468 | |||
| 469 | for (i = 0; i < 8; i++) | ||
| 470 | buf[i] = cornertob32(corner[i]); | ||
| 471 | |||
| 472 | buf[8] = '='; | ||
| 473 | |||
| 474 | for (i = 0; i < 12; i++) | ||
| 475 | buf[i+9] = edgetob32(edge[i]); | ||
| 476 | |||
| 477 | buf[21] = '\0'; | ||
| 478 | } | ||
| 479 | |||
| 480 | _static void | ||
| 450 | writecube_H48(cube_t cube, char *buf) | 481 | writecube_H48(cube_t cube, char *buf) |
| 451 | { | 482 | { |
| 452 | uint8_t piece, perm, orient; | 483 | uint8_t piece, perm, orient, corner[8], edge[12]; |
| 453 | int i; | 484 | int i; |
| 454 | 485 | ||
| 486 | pieces(&cube, corner, edge); | ||
| 487 | |||
| 455 | for (i = 0; i < 12; i++) { | 488 | for (i = 0; i < 12; i++) { |
| 456 | piece = cube.edge[i]; | 489 | piece = edge[i]; |
| 457 | perm = piece & _pbits; | 490 | perm = piece & _pbits; |
| 458 | orient = (piece & _eobit) >> _eoshift; | 491 | orient = (piece & _eobit) >> _eoshift; |
| 459 | buf[4*i ] = edgestr[perm][0]; | 492 | buf[4*i ] = edgestr[perm][0]; |
| @@ -462,7 +495,7 @@ writecube_H48(cube_t cube, char *buf) | |||
| 462 | buf[4*i + 3] = ' '; | 495 | buf[4*i + 3] = ' '; |
| 463 | } | 496 | } |
| 464 | for (i = 0; i < 8; i++) { | 497 | for (i = 0; i < 8; i++) { |
| 465 | piece = cube.corner[i]; | 498 | piece = corner[i]; |
| 466 | perm = piece & _pbits; | 499 | perm = piece & _pbits; |
| 467 | orient = (piece & _cobits) >> _coshift; | 500 | orient = (piece & _cobits) >> _coshift; |
| 468 | buf[48 + 5*i ] = cornerstr[perm][0]; | 501 | buf[48 + 5*i ] = cornerstr[perm][0]; |
| @@ -480,17 +513,18 @@ writecube_LST(cube_t cube, char *buf) | |||
| 480 | { | 513 | { |
| 481 | int i; | 514 | int i; |
| 482 | size_t ptr; | 515 | size_t ptr; |
| 483 | uint8_t piece; | 516 | uint8_t piece, corner[8], edge[12]; |
| 484 | 517 | ||
| 485 | ptr = 0; | 518 | ptr = 0; |
| 519 | pieces(&cube, corner, edge); | ||
| 486 | 520 | ||
| 487 | for (i = 0; i < 8; i++) { | 521 | for (i = 0; i < 8; i++) { |
| 488 | piece = cube.corner[i]; | 522 | piece = corner[i]; |
| 489 | ptr += writepiece_LST(piece, buf + ptr); | 523 | ptr += writepiece_LST(piece, buf + ptr); |
| 490 | } | 524 | } |
| 491 | 525 | ||
| 492 | for (i = 0; i < 12; i++) { | 526 | for (i = 0; i < 12; i++) { |
| 493 | piece = cube.edge[i]; | 527 | piece = edge[i]; |
| 494 | ptr += writepiece_LST(piece, buf + ptr); | 528 | ptr += writepiece_LST(piece, buf + ptr); |
| 495 | } | 529 | } |
| 496 | 530 | ||
| @@ -500,8 +534,8 @@ writecube_LST(cube_t cube, char *buf) | |||
| 500 | _static uint8_t | 534 | _static uint8_t |
| 501 | b32toedge(char c) | 535 | b32toedge(char c) |
| 502 | { | 536 | { |
| 503 | DBG_ASSERT((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g'), 255, | 537 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g')) |
| 504 | "Error reading base32 piece"); | 538 | return 255; |
| 505 | 539 | ||
| 506 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a'); | 540 | return c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a'); |
| 507 | } | 541 | } |
| @@ -510,8 +544,8 @@ _static uint8_t | |||
| 510 | b32tocorner(char c) { | 544 | b32tocorner(char c) { |
| 511 | uint8_t val; | 545 | uint8_t val; |
| 512 | 546 | ||
| 513 | DBG_ASSERT((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g'), 255, | 547 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'g')) |
| 514 | "Error reading base32 piece"); | 548 | return 255; |
| 515 | 549 | ||
| 516 | val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; | 550 | val = c <= 'Z' ? (uint8_t)(c - 'A') : (uint8_t)(c - 'a') + 26; |
| 517 | 551 | ||
| @@ -616,8 +650,8 @@ writetrans(uint8_t t, char *buf) | |||
| 616 | buf[11] = '\0'; | 650 | buf[11] = '\0'; |
| 617 | } | 651 | } |
| 618 | 652 | ||
| 619 | _static cube_fast_t | 653 | _static cube_t |
| 620 | move(cube_fast_t c, uint8_t m) | 654 | move(cube_t c, uint8_t m) |
| 621 | { | 655 | { |
| 622 | switch (m) { | 656 | switch (m) { |
| 623 | case _move_U: | 657 | case _move_U: |
| @@ -658,7 +692,7 @@ move(cube_fast_t c, uint8_t m) | |||
| 658 | return _move(B3, c); | 692 | return _move(B3, c); |
| 659 | default: | 693 | default: |
| 660 | DBG_LOG("move error, unknown move\n"); | 694 | DBG_LOG("move error, unknown move\n"); |
| 661 | return zero_fast; | 695 | return zero; |
| 662 | } | 696 | } |
| 663 | } | 697 | } |
| 664 | 698 | ||
diff --git a/src/cube_neon.h b/src/cube_neon.h index cb2d815..434d6b5 100644 --- a/src/cube_neon.h +++ b/src/cube_neon.h | |||
| @@ -3,4 +3,4 @@ | |||
| 3 | typedef struct { | 3 | typedef struct { |
| 4 | uint8x16_t corner; | 4 | uint8x16_t corner; |
| 5 | uint8x16_t edge; | 5 | uint8x16_t edge; |
| 6 | } cube_fast_t; | 6 | } cube_t; |
diff --git a/src/cube_portable.h b/src/cube_portable.h index 48885ff..71a7e41 100644 --- a/src/cube_portable.h +++ b/src/cube_portable.h | |||
| @@ -1,109 +1,48 @@ | |||
| 1 | typedef struct { | 1 | typedef struct { |
| 2 | uint8_t corner[8]; | 2 | uint8_t corner[8]; |
| 3 | uint8_t edge[12]; | 3 | uint8_t edge[12]; |
| 4 | } cube_fast_t; | 4 | } cube_t; |
| 5 | 5 | ||
| 6 | _static_inline cube_fast_t fastcube( | 6 | #define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ |
| 7 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | 7 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ |
| 8 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | 8 | ((cube_t) { \ |
| 9 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, | 9 | .corner = { c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl }, \ |
| 10 | uint8_t, uint8_t, uint8_t, uint8_t, uint8_t | 10 | .edge = { e_uf, e_ub, e_db, e_df, e_ur, e_ul, \ |
| 11 | ); | 11 | e_dl, e_dr, e_fr, e_fl, e_bl, e_br } }) |
| 12 | _static uint8_t corner(cube_fast_t, int); | 12 | #define zero static_cube( \ |
| 13 | _static uint8_t edge(cube_fast_t, int); | 13 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) |
| 14 | _static cube_fast_t cubetofast(cube_t); | 14 | #define solved static_cube( \ |
| 15 | _static cube_t fasttocube(cube_fast_t); | 15 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) |
| 16 | _static_inline bool equal_fast(cube_fast_t, cube_fast_t); | ||
| 17 | _static_inline bool issolved_fast(cube_fast_t); | ||
| 18 | _static_inline cube_fast_t invertco_fast(cube_fast_t); | ||
| 19 | _static_inline void compose_edges_inplace(cube_fast_t, cube_fast_t, cube_fast_t *); | ||
| 20 | _static_inline void compose_corners_inplace(cube_fast_t, cube_fast_t, cube_fast_t *); | ||
| 21 | _static_inline cube_fast_t compose_fast_edges(cube_fast_t, cube_fast_t); | ||
| 22 | _static_inline cube_fast_t compose_fast_corners(cube_fast_t, cube_fast_t); | ||
| 23 | _static_inline cube_fast_t compose_fast(cube_fast_t, cube_fast_t); | ||
| 24 | 16 | ||
| 25 | _static_inline int64_t coord_fast_co(cube_fast_t); | 17 | _static void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 26 | _static_inline int64_t coord_fast_csep(cube_fast_t); | 18 | _static_inline bool equal(cube_t, cube_t); |
| 27 | _static_inline int64_t coord_fast_cocsep(cube_fast_t); | 19 | _static_inline cube_t invertco(cube_t); |
| 28 | _static_inline int64_t coord_fast_eo(cube_fast_t); | 20 | _static_inline void compose_edges_inplace(cube_t, cube_t, cube_t *); |
| 29 | _static_inline int64_t coord_fast_esep(cube_fast_t); | 21 | _static_inline void compose_corners_inplace(cube_t, cube_t, cube_t *); |
| 22 | _static_inline cube_t compose_edges(cube_t, cube_t); | ||
| 23 | _static_inline cube_t compose_corners(cube_t, cube_t); | ||
| 24 | _static_inline cube_t compose(cube_t, cube_t); | ||
| 30 | 25 | ||
| 31 | _static_inline void copy_corners_fast(cube_fast_t *, cube_fast_t); | 26 | _static_inline int64_t coord_co(cube_t); |
| 32 | _static_inline void copy_edges_fast(cube_fast_t *, cube_fast_t); | 27 | _static_inline int64_t coord_csep(cube_t); |
| 33 | _static_inline void set_eo_fast(cube_fast_t *, int64_t); | 28 | _static_inline int64_t coord_cocsep(cube_t); |
| 34 | _static_inline cube_fast_t invcoord_fast_esep(int64_t); | 29 | _static_inline int64_t coord_eo(cube_t); |
| 30 | _static_inline int64_t coord_esep(cube_t); | ||
| 35 | 31 | ||
| 36 | _static_inline cube_fast_t | 32 | _static_inline void copy_corners(cube_t *, cube_t); |
| 37 | fastcube( | 33 | _static_inline void copy_edges(cube_t *, cube_t); |
| 38 | uint8_t c_ufr, | 34 | _static_inline void set_eo(cube_t *, int64_t); |
| 39 | uint8_t c_ubl, | 35 | _static_inline cube_t invcoord_esep(int64_t); |
| 40 | uint8_t c_dfl, | ||
| 41 | uint8_t c_dbr, | ||
| 42 | uint8_t c_ufl, | ||
| 43 | uint8_t c_ubr, | ||
| 44 | uint8_t c_dfr, | ||
| 45 | uint8_t c_dbl, | ||
| 46 | 36 | ||
| 47 | uint8_t e_uf, | 37 | _static void |
| 48 | uint8_t e_ub, | 38 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 49 | uint8_t e_db, | ||
| 50 | uint8_t e_df, | ||
| 51 | uint8_t e_ur, | ||
| 52 | uint8_t e_ul, | ||
| 53 | uint8_t e_dl, | ||
| 54 | uint8_t e_dr, | ||
| 55 | uint8_t e_fr, | ||
| 56 | uint8_t e_fl, | ||
| 57 | uint8_t e_bl, | ||
| 58 | uint8_t e_br | ||
| 59 | ) | ||
| 60 | { | 39 | { |
| 61 | cube_fast_t cube = { | 40 | memcpy(c, cube->corner, 8); |
| 62 | .corner = { | 41 | memcpy(e, cube->edge, 12); |
| 63 | c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl | ||
| 64 | }, | ||
| 65 | .edge = { | ||
| 66 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, | ||
| 67 | e_dl, e_dr, e_fr, e_fl, e_bl, e_br | ||
| 68 | } | ||
| 69 | }; | ||
| 70 | |||
| 71 | return cube; | ||
| 72 | } | ||
| 73 | |||
| 74 | _static uint8_t | ||
| 75 | corner(cube_fast_t c, int i) | ||
| 76 | { | ||
| 77 | DBG_ASSERT(i >= 0 && i < 8, 255, "Corner must be between 0 and 7\n"); | ||
| 78 | |||
| 79 | return c.corner[i]; | ||
| 80 | } | ||
| 81 | _static uint8_t | ||
| 82 | edge(cube_fast_t c, int i) | ||
| 83 | { | ||
| 84 | DBG_ASSERT(i >= 0 && i < 12, 255, "Edge must be between 0 and 11\n"); | ||
| 85 | |||
| 86 | return c.edge[i]; | ||
| 87 | } | ||
| 88 | |||
| 89 | _static cube_fast_t | ||
| 90 | cubetofast(cube_t cube) | ||
| 91 | { | ||
| 92 | cube_fast_t fast; | ||
| 93 | memcpy(&fast, &cube, sizeof(cube_fast_t)); | ||
| 94 | return fast; | ||
| 95 | } | ||
| 96 | |||
| 97 | _static cube_t | ||
| 98 | fasttocube(cube_fast_t fast) | ||
| 99 | { | ||
| 100 | cube_t cube; | ||
| 101 | memcpy(&cube, &fast, sizeof(cube_fast_t)); | ||
| 102 | return cube; | ||
| 103 | } | 42 | } |
| 104 | 43 | ||
| 105 | _static_inline bool | 44 | _static_inline bool |
| 106 | equal_fast(cube_fast_t c1, cube_fast_t c2) | 45 | equal(cube_t c1, cube_t c2) |
| 107 | { | 46 | { |
| 108 | uint8_t i; | 47 | uint8_t i; |
| 109 | bool ret; | 48 | bool ret; |
| @@ -117,17 +56,11 @@ equal_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 117 | return ret; | 56 | return ret; |
| 118 | } | 57 | } |
| 119 | 58 | ||
| 120 | _static_inline bool | 59 | _static_inline cube_t |
| 121 | issolved_fast(cube_fast_t cube) | 60 | invertco(cube_t c) |
| 122 | { | ||
| 123 | return equal_fast(cube, solved_fast); | ||
| 124 | } | ||
| 125 | |||
| 126 | _static_inline cube_fast_t | ||
| 127 | invertco_fast(cube_fast_t c) | ||
| 128 | { | 61 | { |
| 129 | uint8_t i, piece, orien; | 62 | uint8_t i, piece, orien; |
| 130 | cube_fast_t ret; | 63 | cube_t ret; |
| 131 | 64 | ||
| 132 | ret = c; | 65 | ret = c; |
| 133 | for (i = 0; i < 8; i++) { | 66 | for (i = 0; i < 8; i++) { |
| @@ -140,7 +73,7 @@ invertco_fast(cube_fast_t c) | |||
| 140 | } | 73 | } |
| 141 | 74 | ||
| 142 | _static_inline void | 75 | _static_inline void |
| 143 | compose_edges_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret) | 76 | compose_edges_inplace(cube_t c1, cube_t c2, cube_t *ret) |
| 144 | { | 77 | { |
| 145 | uint8_t i, piece1, piece2, p, orien; | 78 | uint8_t i, piece1, piece2, p, orien; |
| 146 | 79 | ||
| @@ -154,7 +87,7 @@ compose_edges_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret) | |||
| 154 | } | 87 | } |
| 155 | 88 | ||
| 156 | _static_inline void | 89 | _static_inline void |
| 157 | compose_corners_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret) | 90 | compose_corners_inplace(cube_t c1, cube_t c2, cube_t *ret) |
| 158 | { | 91 | { |
| 159 | uint8_t i, piece1, piece2, p, orien, aux, auy; | 92 | uint8_t i, piece1, piece2, p, orien, aux, auy; |
| 160 | 93 | ||
| @@ -169,30 +102,30 @@ compose_corners_inplace(cube_fast_t c1, cube_fast_t c2, cube_fast_t *ret) | |||
| 169 | } | 102 | } |
| 170 | } | 103 | } |
| 171 | 104 | ||
| 172 | _static_inline cube_fast_t | 105 | _static_inline cube_t |
| 173 | compose_fast_edges(cube_fast_t c1, cube_fast_t c2) | 106 | compose_edges(cube_t c1, cube_t c2) |
| 174 | { | 107 | { |
| 175 | cube_fast_t ret = zero_fast; | 108 | cube_t ret = zero; |
| 176 | 109 | ||
| 177 | compose_edges_inplace(c1, c2, &ret); | 110 | compose_edges_inplace(c1, c2, &ret); |
| 178 | 111 | ||
| 179 | return ret; | 112 | return ret; |
| 180 | } | 113 | } |
| 181 | 114 | ||
| 182 | _static_inline cube_fast_t | 115 | _static_inline cube_t |
| 183 | compose_fast_corners(cube_fast_t c1, cube_fast_t c2) | 116 | compose_corners(cube_t c1, cube_t c2) |
| 184 | { | 117 | { |
| 185 | cube_fast_t ret = zero_fast; | 118 | cube_t ret = zero; |
| 186 | 119 | ||
| 187 | compose_corners_inplace(c1, c2, &ret); | 120 | compose_corners_inplace(c1, c2, &ret); |
| 188 | 121 | ||
| 189 | return ret; | 122 | return ret; |
| 190 | } | 123 | } |
| 191 | 124 | ||
| 192 | _static_inline cube_fast_t | 125 | _static_inline cube_t |
| 193 | compose_fast(cube_fast_t c1, cube_fast_t c2) | 126 | compose(cube_t c1, cube_t c2) |
| 194 | { | 127 | { |
| 195 | cube_fast_t ret = zero_fast; | 128 | cube_t ret = zero; |
| 196 | 129 | ||
| 197 | compose_edges_inplace(c1, c2, &ret); | 130 | compose_edges_inplace(c1, c2, &ret); |
| 198 | compose_corners_inplace(c1, c2, &ret); | 131 | compose_corners_inplace(c1, c2, &ret); |
| @@ -201,7 +134,7 @@ compose_fast(cube_fast_t c1, cube_fast_t c2) | |||
| 201 | } | 134 | } |
| 202 | 135 | ||
| 203 | _static_inline int64_t | 136 | _static_inline int64_t |
| 204 | coord_fast_co(cube_fast_t c) | 137 | coord_co(cube_t c) |
| 205 | { | 138 | { |
| 206 | int i, p; | 139 | int i, p; |
| 207 | int64_t ret; | 140 | int64_t ret; |
| @@ -220,7 +153,7 @@ possible. Encoding this as a number from 0 to C(8,4) would save about 40% | |||
| 220 | of space, but we are not going to use this coordinate in large tables. | 153 | of space, but we are not going to use this coordinate in large tables. |
| 221 | */ | 154 | */ |
| 222 | _static_inline int64_t | 155 | _static_inline int64_t |
| 223 | coord_fast_csep(cube_fast_t c) | 156 | coord_csep(cube_t c) |
| 224 | { | 157 | { |
| 225 | int i, p; | 158 | int i, p; |
| 226 | int64_t ret; | 159 | int64_t ret; |
| @@ -232,13 +165,13 @@ coord_fast_csep(cube_fast_t c) | |||
| 232 | } | 165 | } |
| 233 | 166 | ||
| 234 | _static_inline int64_t | 167 | _static_inline int64_t |
| 235 | coord_fast_cocsep(cube_fast_t c) | 168 | coord_cocsep(cube_t c) |
| 236 | { | 169 | { |
| 237 | return (coord_fast_co(c) << 7) + coord_fast_csep(c); | 170 | return (coord_co(c) << 7) + coord_csep(c); |
| 238 | } | 171 | } |
| 239 | 172 | ||
| 240 | _static_inline int64_t | 173 | _static_inline int64_t |
| 241 | coord_fast_eo(cube_fast_t c) | 174 | coord_eo(cube_t c) |
| 242 | { | 175 | { |
| 243 | int i, p; | 176 | int i, p; |
| 244 | int64_t ret; | 177 | int64_t ret; |
| @@ -254,7 +187,7 @@ We encode the edge separation as a number from 0 to C(12,4)*C(8,4). | |||
| 254 | It can be seen as the composition of two "subset index" coordinates. | 187 | It can be seen as the composition of two "subset index" coordinates. |
| 255 | */ | 188 | */ |
| 256 | _static_inline int64_t | 189 | _static_inline int64_t |
| 257 | coord_fast_esep(cube_fast_t c) | 190 | coord_esep(cube_t c) |
| 258 | { | 191 | { |
| 259 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; | 192 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 260 | 193 | ||
| @@ -286,19 +219,19 @@ coord_fast_esep(cube_fast_t c) | |||
| 286 | } | 219 | } |
| 287 | 220 | ||
| 288 | _static_inline void | 221 | _static_inline void |
| 289 | copy_corners_fast(cube_fast_t *dest, cube_fast_t src) | 222 | copy_corners(cube_t *dest, cube_t src) |
| 290 | { | 223 | { |
| 291 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); | 224 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); |
| 292 | } | 225 | } |
| 293 | 226 | ||
| 294 | _static_inline void | 227 | _static_inline void |
| 295 | copy_edges_fast(cube_fast_t *dest, cube_fast_t src) | 228 | copy_edges(cube_t *dest, cube_t src) |
| 296 | { | 229 | { |
| 297 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); | 230 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); |
| 298 | } | 231 | } |
| 299 | 232 | ||
| 300 | _static_inline void | 233 | _static_inline void |
| 301 | set_eo_fast(cube_fast_t *cube, int64_t eo) | 234 | set_eo(cube_t *cube, int64_t eo) |
| 302 | { | 235 | { |
| 303 | uint8_t i, sum, flip; | 236 | uint8_t i, sum, flip; |
| 304 | 237 | ||
| @@ -310,14 +243,14 @@ set_eo_fast(cube_fast_t *cube, int64_t eo) | |||
| 310 | cube->edge[0] = (cube->edge[0] & ~_eobit) | (_eobit * (sum % 2)); | 243 | cube->edge[0] = (cube->edge[0] & ~_eobit) | (_eobit * (sum % 2)); |
| 311 | } | 244 | } |
| 312 | 245 | ||
| 313 | _static_inline cube_fast_t | 246 | _static_inline cube_t |
| 314 | invcoord_fast_esep(int64_t esep) | 247 | invcoord_esep(int64_t esep) |
| 315 | { | 248 | { |
| 316 | cube_fast_t ret; | 249 | cube_t ret; |
| 317 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1, set1, set2; | 250 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1, set1, set2; |
| 318 | uint8_t slice[3] = {0}; | 251 | uint8_t slice[3] = {0}; |
| 319 | 252 | ||
| 320 | ret = cubetofast(solved); | 253 | ret = solved; |
| 321 | set1 = esep % 70; | 254 | set1 = esep % 70; |
| 322 | set2 = esep / 70; | 255 | set2 = esep / 70; |
| 323 | 256 | ||
diff --git a/src/cube_transform.h b/src/cube_transform.h index d9a0941..358b051 100644 --- a/src/cube_transform.h +++ b/src/cube_transform.h | |||
| @@ -1,336 +1,176 @@ | |||
| 1 | /* TODO: remove these macros, if the below works */ | ||
| 2 | |||
| 1 | #define _trans_edges_rotation(T, c) \ | 3 | #define _trans_edges_rotation(T, c) \ |
| 2 | compose_fast_edges(compose_fast_edges(_trans_cube_ ## T, c), \ | 4 | compose_edges(compose_edges(_trans_cube_ ## T, c), \ |
| 3 | _trans_cube_ ## T ## _inverse) | 5 | _trans_cube_ ## T ## _inverse) |
| 4 | #define _trans_edges_mirrored(T, c) _trans_edges_rotation(T, c) | 6 | #define _trans_edges_mirrored(T, c) _trans_edges_rotation(T, c) |
| 5 | 7 | ||
| 6 | #define _trans_corners_rotation(T, c) \ | 8 | #define _trans_corners_rotation(T, c) \ |
| 7 | compose_fast_corners(compose_fast_corners(_trans_cube_ ## T, c), \ | 9 | compose_corners(compose_corners(_trans_cube_ ## T, c), \ |
| 8 | _trans_cube_ ## T ## _inverse) | 10 | _trans_cube_ ## T ## _inverse) |
| 9 | #define _trans_corners_mirrored(T, c) \ | 11 | #define _trans_corners_mirrored(T, c) \ |
| 10 | invertco_fast(compose_fast_corners( \ | 12 | invertco(compose_corners( \ |
| 11 | compose_fast_corners(_trans_cube_ ## T, c), _trans_cube_ ## T ## _inverse)) | 13 | compose_corners(_trans_cube_ ## T, c), _trans_cube_ ## T ## _inverse)) |
| 12 | 14 | ||
| 13 | #define _trans_rotation(T, c) \ | 15 | #define _trans_rotation(T, c) \ |
| 14 | compose_fast(compose_fast(_trans_cube_ ## T, c), \ | 16 | compose(compose(_trans_cube_ ## T, c), \ |
| 15 | _trans_cube_ ## T ## _inverse) | 17 | _trans_cube_ ## T ## _inverse) |
| 16 | #define _trans_mirrored(T, c) \ | 18 | #define _trans_mirrored(T, c) \ |
| 17 | invertco_fast(compose_fast(compose_fast(_trans_cube_ ## T, c), \ | 19 | invertco(compose(compose(_trans_cube_ ## T, c), \ |
| 18 | _trans_cube_ ## T ## _inverse)) | 20 | _trans_cube_ ## T ## _inverse)) |
| 19 | 21 | ||
| 20 | _static cube_fast_t | 22 | static cube_t cube_trans_table[48] = { |
| 21 | transform_edges(cube_fast_t c, uint8_t t) | 23 | [_trans_UFr] = _trans_cube_UFr, |
| 24 | [_trans_UFm] = _trans_cube_UFm, | ||
| 25 | [_trans_ULr] = _trans_cube_URr, | ||
| 26 | [_trans_ULm] = _trans_cube_ULm, | ||
| 27 | [_trans_UBr] = _trans_cube_UBr, | ||
| 28 | [_trans_UBm] = _trans_cube_UBm, | ||
| 29 | [_trans_URr] = _trans_cube_ULr, | ||
| 30 | [_trans_URm] = _trans_cube_URm, | ||
| 31 | [_trans_DFr] = _trans_cube_DFr, | ||
| 32 | [_trans_DFm] = _trans_cube_DFm, | ||
| 33 | [_trans_DLr] = _trans_cube_DLr, | ||
| 34 | [_trans_DLm] = _trans_cube_DRm, | ||
| 35 | [_trans_DBr] = _trans_cube_DBr, | ||
| 36 | [_trans_DBm] = _trans_cube_DBm, | ||
| 37 | [_trans_DRr] = _trans_cube_DRr, | ||
| 38 | [_trans_DRm] = _trans_cube_DLm, | ||
| 39 | [_trans_RUr] = _trans_cube_FRr, | ||
| 40 | [_trans_RUm] = _trans_cube_FLm, | ||
| 41 | [_trans_RFr] = _trans_cube_LFr, | ||
| 42 | [_trans_RFm] = _trans_cube_RFm, | ||
| 43 | [_trans_RDr] = _trans_cube_BLr, | ||
| 44 | [_trans_RDm] = _trans_cube_BRm, | ||
| 45 | [_trans_RBr] = _trans_cube_RBr, | ||
| 46 | [_trans_RBm] = _trans_cube_LBm, | ||
| 47 | [_trans_LUr] = _trans_cube_FLr, | ||
| 48 | [_trans_LUm] = _trans_cube_FRm, | ||
| 49 | [_trans_LFr] = _trans_cube_RFr, | ||
| 50 | [_trans_LFm] = _trans_cube_LFm, | ||
| 51 | [_trans_LDr] = _trans_cube_BRr, | ||
| 52 | [_trans_LDm] = _trans_cube_BLm, | ||
| 53 | [_trans_LBr] = _trans_cube_LBr, | ||
| 54 | [_trans_LBm] = _trans_cube_RBm, | ||
| 55 | [_trans_FUr] = _trans_cube_FUr, | ||
| 56 | [_trans_FUm] = _trans_cube_FUm, | ||
| 57 | [_trans_FRr] = _trans_cube_RUr, | ||
| 58 | [_trans_FRm] = _trans_cube_LUm, | ||
| 59 | [_trans_FDr] = _trans_cube_BUr, | ||
| 60 | [_trans_FDm] = _trans_cube_BUm, | ||
| 61 | [_trans_FLr] = _trans_cube_LUr, | ||
| 62 | [_trans_FLm] = _trans_cube_RUm, | ||
| 63 | [_trans_BUr] = _trans_cube_FDr, | ||
| 64 | [_trans_BUm] = _trans_cube_FDm, | ||
| 65 | [_trans_BRr] = _trans_cube_LDr, | ||
| 66 | [_trans_BRm] = _trans_cube_RDm, | ||
| 67 | [_trans_BDr] = _trans_cube_BDr, | ||
| 68 | [_trans_BDm] = _trans_cube_BDm, | ||
| 69 | [_trans_BLr] = _trans_cube_RDr, | ||
| 70 | [_trans_BLm] = _trans_cube_LDm, | ||
| 71 | }; | ||
| 72 | |||
| 73 | static cube_t cube_trans_table_inverse[48] = { | ||
| 74 | [_trans_UFr] = _trans_cube_UFr_inverse, | ||
| 75 | [_trans_UFm] = _trans_cube_UFm_inverse, | ||
| 76 | [_trans_ULr] = _trans_cube_URr_inverse, | ||
| 77 | [_trans_ULm] = _trans_cube_ULm_inverse, | ||
| 78 | [_trans_UBr] = _trans_cube_UBr_inverse, | ||
| 79 | [_trans_UBm] = _trans_cube_UBm_inverse, | ||
| 80 | [_trans_URr] = _trans_cube_ULr_inverse, | ||
| 81 | [_trans_URm] = _trans_cube_URm_inverse, | ||
| 82 | [_trans_DFr] = _trans_cube_DFr_inverse, | ||
| 83 | [_trans_DFm] = _trans_cube_DFm_inverse, | ||
| 84 | [_trans_DLr] = _trans_cube_DLr_inverse, | ||
| 85 | [_trans_DLm] = _trans_cube_DRm_inverse, | ||
| 86 | [_trans_DBr] = _trans_cube_DBr_inverse, | ||
| 87 | [_trans_DBm] = _trans_cube_DBm_inverse, | ||
| 88 | [_trans_DRr] = _trans_cube_DRr_inverse, | ||
| 89 | [_trans_DRm] = _trans_cube_DLm_inverse, | ||
| 90 | [_trans_RUr] = _trans_cube_FRr_inverse, | ||
| 91 | [_trans_RUm] = _trans_cube_FLm_inverse, | ||
| 92 | [_trans_RFr] = _trans_cube_LFr_inverse, | ||
| 93 | [_trans_RFm] = _trans_cube_RFm_inverse, | ||
| 94 | [_trans_RDr] = _trans_cube_BLr_inverse, | ||
| 95 | [_trans_RDm] = _trans_cube_BRm_inverse, | ||
| 96 | [_trans_RBr] = _trans_cube_RBr_inverse, | ||
| 97 | [_trans_RBm] = _trans_cube_LBm_inverse, | ||
| 98 | [_trans_LUr] = _trans_cube_FLr_inverse, | ||
| 99 | [_trans_LUm] = _trans_cube_FRm_inverse, | ||
| 100 | [_trans_LFr] = _trans_cube_RFr_inverse, | ||
| 101 | [_trans_LFm] = _trans_cube_LFm_inverse, | ||
| 102 | [_trans_LDr] = _trans_cube_BRr_inverse, | ||
| 103 | [_trans_LDm] = _trans_cube_BLm_inverse, | ||
| 104 | [_trans_LBr] = _trans_cube_LBr_inverse, | ||
| 105 | [_trans_LBm] = _trans_cube_RBm_inverse, | ||
| 106 | [_trans_FUr] = _trans_cube_FUr_inverse, | ||
| 107 | [_trans_FUm] = _trans_cube_FUm_inverse, | ||
| 108 | [_trans_FRr] = _trans_cube_RUr_inverse, | ||
| 109 | [_trans_FRm] = _trans_cube_LUm_inverse, | ||
| 110 | [_trans_FDr] = _trans_cube_BUr_inverse, | ||
| 111 | [_trans_FDm] = _trans_cube_BUm_inverse, | ||
| 112 | [_trans_FLr] = _trans_cube_LUr_inverse, | ||
| 113 | [_trans_FLm] = _trans_cube_RUm_inverse, | ||
| 114 | [_trans_BUr] = _trans_cube_FDr_inverse, | ||
| 115 | [_trans_BUm] = _trans_cube_FDm_inverse, | ||
| 116 | [_trans_BRr] = _trans_cube_LDr_inverse, | ||
| 117 | [_trans_BRm] = _trans_cube_RDm_inverse, | ||
| 118 | [_trans_BDr] = _trans_cube_BDr_inverse, | ||
| 119 | [_trans_BDm] = _trans_cube_BDm_inverse, | ||
| 120 | [_trans_BLr] = _trans_cube_RDr_inverse, | ||
| 121 | [_trans_BLm] = _trans_cube_LDm_inverse, | ||
| 122 | }; | ||
| 123 | |||
| 124 | _static cube_t | ||
| 125 | transform_edges(cube_t c, uint8_t t) | ||
| 22 | { | 126 | { |
| 23 | switch (t) { | 127 | cube_t ret, trans_cube, trans_inv; |
| 24 | case _trans_UFr: | 128 | |
| 25 | return _trans_edges_rotation(UFr, c); | 129 | DBG_ASSERT(t < 48, zero, |
| 26 | case _trans_ULr: | 130 | "transform: invalid transformation %" PRIu8 |
| 27 | return _trans_edges_rotation(ULr, c); | 131 | ", must be between 0 and 47\n", t); |
| 28 | case _trans_UBr: | 132 | |
| 29 | return _trans_edges_rotation(UBr, c); | 133 | trans_cube = cube_trans_table[t]; |
| 30 | case _trans_URr: | 134 | trans_inv = cube_trans_table_inverse[t]; |
| 31 | return _trans_edges_rotation(URr, c); | 135 | |
| 32 | case _trans_DFr: | 136 | ret = compose_edges(trans_cube, c); |
| 33 | return _trans_edges_rotation(DFr, c); | 137 | ret = compose_edges(ret, trans_inv); |
| 34 | case _trans_DLr: | 138 | |
| 35 | return _trans_edges_rotation(DLr, c); | 139 | return ret; |
| 36 | case _trans_DBr: | ||
| 37 | return _trans_edges_rotation(DBr, c); | ||
| 38 | case _trans_DRr: | ||
| 39 | return _trans_edges_rotation(DRr, c); | ||
| 40 | case _trans_RUr: | ||
| 41 | return _trans_edges_rotation(RUr, c); | ||
| 42 | case _trans_RFr: | ||
| 43 | return _trans_edges_rotation(RFr, c); | ||
| 44 | case _trans_RDr: | ||
| 45 | return _trans_edges_rotation(RDr, c); | ||
| 46 | case _trans_RBr: | ||
| 47 | return _trans_edges_rotation(RBr, c); | ||
| 48 | case _trans_LUr: | ||
| 49 | return _trans_edges_rotation(LUr, c); | ||
| 50 | case _trans_LFr: | ||
| 51 | return _trans_edges_rotation(LFr, c); | ||
| 52 | case _trans_LDr: | ||
| 53 | return _trans_edges_rotation(LDr, c); | ||
| 54 | case _trans_LBr: | ||
| 55 | return _trans_edges_rotation(LBr, c); | ||
| 56 | case _trans_FUr: | ||
| 57 | return _trans_edges_rotation(FUr, c); | ||
| 58 | case _trans_FRr: | ||
| 59 | return _trans_edges_rotation(FRr, c); | ||
| 60 | case _trans_FDr: | ||
| 61 | return _trans_edges_rotation(FDr, c); | ||
| 62 | case _trans_FLr: | ||
| 63 | return _trans_edges_rotation(FLr, c); | ||
| 64 | case _trans_BUr: | ||
| 65 | return _trans_edges_rotation(BUr, c); | ||
| 66 | case _trans_BRr: | ||
| 67 | return _trans_edges_rotation(BRr, c); | ||
| 68 | case _trans_BDr: | ||
| 69 | return _trans_edges_rotation(BDr, c); | ||
| 70 | case _trans_BLr: | ||
| 71 | return _trans_edges_rotation(BLr, c); | ||
| 72 | case _trans_UFm: | ||
| 73 | return _trans_edges_mirrored(UFm, c); | ||
| 74 | case _trans_ULm: | ||
| 75 | return _trans_edges_mirrored(ULm, c); | ||
| 76 | case _trans_UBm: | ||
| 77 | return _trans_edges_mirrored(UBm, c); | ||
| 78 | case _trans_URm: | ||
| 79 | return _trans_edges_mirrored(URm, c); | ||
| 80 | case _trans_DFm: | ||
| 81 | return _trans_edges_mirrored(DFm, c); | ||
| 82 | case _trans_DLm: | ||
| 83 | return _trans_edges_mirrored(DLm, c); | ||
| 84 | case _trans_DBm: | ||
| 85 | return _trans_edges_mirrored(DBm, c); | ||
| 86 | case _trans_DRm: | ||
| 87 | return _trans_edges_mirrored(DRm, c); | ||
| 88 | case _trans_RUm: | ||
| 89 | return _trans_edges_mirrored(RUm, c); | ||
| 90 | case _trans_RFm: | ||
| 91 | return _trans_edges_mirrored(RFm, c); | ||
| 92 | case _trans_RDm: | ||
| 93 | return _trans_edges_mirrored(RDm, c); | ||
| 94 | case _trans_RBm: | ||
| 95 | return _trans_edges_mirrored(RBm, c); | ||
| 96 | case _trans_LUm: | ||
| 97 | return _trans_edges_mirrored(LUm, c); | ||
| 98 | case _trans_LFm: | ||
| 99 | return _trans_edges_mirrored(LFm, c); | ||
| 100 | case _trans_LDm: | ||
| 101 | return _trans_edges_mirrored(LDm, c); | ||
| 102 | case _trans_LBm: | ||
| 103 | return _trans_edges_mirrored(LBm, c); | ||
| 104 | case _trans_FUm: | ||
| 105 | return _trans_edges_mirrored(FUm, c); | ||
| 106 | case _trans_FRm: | ||
| 107 | return _trans_edges_mirrored(FRm, c); | ||
| 108 | case _trans_FDm: | ||
| 109 | return _trans_edges_mirrored(FDm, c); | ||
| 110 | case _trans_FLm: | ||
| 111 | return _trans_edges_mirrored(FLm, c); | ||
| 112 | case _trans_BUm: | ||
| 113 | return _trans_edges_mirrored(BUm, c); | ||
| 114 | case _trans_BRm: | ||
| 115 | return _trans_edges_mirrored(BRm, c); | ||
| 116 | case _trans_BDm: | ||
| 117 | return _trans_edges_mirrored(BDm, c); | ||
| 118 | case _trans_BLm: | ||
| 119 | return _trans_edges_mirrored(BLm, c); | ||
| 120 | default: | ||
| 121 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 122 | return zero_fast; | ||
| 123 | } | ||
| 124 | } | 140 | } |
| 125 | 141 | ||
| 126 | _static cube_fast_t | 142 | _static cube_t |
| 127 | transform_corners(cube_fast_t c, uint8_t t) | 143 | transform_corners(cube_t c, uint8_t t) |
| 128 | { | 144 | { |
| 129 | switch (t) { | 145 | cube_t ret, trans_cube, trans_inv; |
| 130 | case _trans_UFr: | 146 | |
| 131 | return _trans_corners_rotation(UFr, c); | 147 | DBG_ASSERT(t < 48, zero, |
| 132 | case _trans_ULr: | 148 | "transform: invalid transformation %" PRIu8 |
| 133 | return _trans_corners_rotation(ULr, c); | 149 | ", must be between 0 and 47\n", t); |
| 134 | case _trans_UBr: | 150 | |
| 135 | return _trans_corners_rotation(UBr, c); | 151 | trans_cube = cube_trans_table[t]; |
| 136 | case _trans_URr: | 152 | trans_inv = cube_trans_table_inverse[t]; |
| 137 | return _trans_corners_rotation(URr, c); | 153 | |
| 138 | case _trans_DFr: | 154 | ret = compose_corners(trans_cube, c); |
| 139 | return _trans_corners_rotation(DFr, c); | 155 | ret = compose_corners(ret, trans_inv); |
| 140 | case _trans_DLr: | 156 | |
| 141 | return _trans_corners_rotation(DLr, c); | 157 | return t < 24 ? ret : invertco(ret); |
| 142 | case _trans_DBr: | ||
| 143 | return _trans_corners_rotation(DBr, c); | ||
| 144 | case _trans_DRr: | ||
| 145 | return _trans_corners_rotation(DRr, c); | ||
| 146 | case _trans_RUr: | ||
| 147 | return _trans_corners_rotation(RUr, c); | ||
| 148 | case _trans_RFr: | ||
| 149 | return _trans_corners_rotation(RFr, c); | ||
| 150 | case _trans_RDr: | ||
| 151 | return _trans_corners_rotation(RDr, c); | ||
| 152 | case _trans_RBr: | ||
| 153 | return _trans_corners_rotation(RBr, c); | ||
| 154 | case _trans_LUr: | ||
| 155 | return _trans_corners_rotation(LUr, c); | ||
| 156 | case _trans_LFr: | ||
| 157 | return _trans_corners_rotation(LFr, c); | ||
| 158 | case _trans_LDr: | ||
| 159 | return _trans_corners_rotation(LDr, c); | ||
| 160 | case _trans_LBr: | ||
| 161 | return _trans_corners_rotation(LBr, c); | ||
| 162 | case _trans_FUr: | ||
| 163 | return _trans_corners_rotation(FUr, c); | ||
| 164 | case _trans_FRr: | ||
| 165 | return _trans_corners_rotation(FRr, c); | ||
| 166 | case _trans_FDr: | ||
| 167 | return _trans_corners_rotation(FDr, c); | ||
| 168 | case _trans_FLr: | ||
| 169 | return _trans_corners_rotation(FLr, c); | ||
| 170 | case _trans_BUr: | ||
| 171 | return _trans_corners_rotation(BUr, c); | ||
| 172 | case _trans_BRr: | ||
| 173 | return _trans_corners_rotation(BRr, c); | ||
| 174 | case _trans_BDr: | ||
| 175 | return _trans_corners_rotation(BDr, c); | ||
| 176 | case _trans_BLr: | ||
| 177 | return _trans_corners_rotation(BLr, c); | ||
| 178 | case _trans_UFm: | ||
| 179 | return _trans_corners_mirrored(UFm, c); | ||
| 180 | case _trans_ULm: | ||
| 181 | return _trans_corners_mirrored(ULm, c); | ||
| 182 | case _trans_UBm: | ||
| 183 | return _trans_corners_mirrored(UBm, c); | ||
| 184 | case _trans_URm: | ||
| 185 | return _trans_corners_mirrored(URm, c); | ||
| 186 | case _trans_DFm: | ||
| 187 | return _trans_corners_mirrored(DFm, c); | ||
| 188 | case _trans_DLm: | ||
| 189 | return _trans_corners_mirrored(DLm, c); | ||
| 190 | case _trans_DBm: | ||
| 191 | return _trans_corners_mirrored(DBm, c); | ||
| 192 | case _trans_DRm: | ||
| 193 | return _trans_corners_mirrored(DRm, c); | ||
| 194 | case _trans_RUm: | ||
| 195 | return _trans_corners_mirrored(RUm, c); | ||
| 196 | case _trans_RFm: | ||
| 197 | return _trans_corners_mirrored(RFm, c); | ||
| 198 | case _trans_RDm: | ||
| 199 | return _trans_corners_mirrored(RDm, c); | ||
| 200 | case _trans_RBm: | ||
| 201 | return _trans_corners_mirrored(RBm, c); | ||
| 202 | case _trans_LUm: | ||
| 203 | return _trans_corners_mirrored(LUm, c); | ||
| 204 | case _trans_LFm: | ||
| 205 | return _trans_corners_mirrored(LFm, c); | ||
| 206 | case _trans_LDm: | ||
| 207 | return _trans_corners_mirrored(LDm, c); | ||
| 208 | case _trans_LBm: | ||
| 209 | return _trans_corners_mirrored(LBm, c); | ||
| 210 | case _trans_FUm: | ||
| 211 | return _trans_corners_mirrored(FUm, c); | ||
| 212 | case _trans_FRm: | ||
| 213 | return _trans_corners_mirrored(FRm, c); | ||
| 214 | case _trans_FDm: | ||
| 215 | return _trans_corners_mirrored(FDm, c); | ||
| 216 | case _trans_FLm: | ||
| 217 | return _trans_corners_mirrored(FLm, c); | ||
| 218 | case _trans_BUm: | ||
| 219 | return _trans_corners_mirrored(BUm, c); | ||
| 220 | case _trans_BRm: | ||
| 221 | return _trans_corners_mirrored(BRm, c); | ||
| 222 | case _trans_BDm: | ||
| 223 | return _trans_corners_mirrored(BDm, c); | ||
| 224 | case _trans_BLm: | ||
| 225 | return _trans_corners_mirrored(BLm, c); | ||
| 226 | default: | ||
| 227 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 228 | return zero_fast; | ||
| 229 | } | ||
| 230 | } | 158 | } |
| 231 | 159 | ||
| 232 | _static cube_fast_t | 160 | _static cube_t |
| 233 | transform(cube_fast_t c, uint8_t t) | 161 | transform(cube_t c, uint8_t t) |
| 234 | { | 162 | { |
| 235 | switch (t) { | 163 | cube_t ret, trans_cube, trans_inv; |
| 236 | case _trans_UFr: | 164 | |
| 237 | return _trans_rotation(UFr, c); | 165 | DBG_ASSERT(t < 48, zero, |
| 238 | case _trans_ULr: | 166 | "transform: invalid transformation %" PRIu8 |
| 239 | return _trans_rotation(ULr, c); | 167 | ", must be between 0 and 47\n", t); |
| 240 | case _trans_UBr: | 168 | |
| 241 | return _trans_rotation(UBr, c); | 169 | trans_cube = cube_trans_table[t]; |
| 242 | case _trans_URr: | 170 | trans_inv = cube_trans_table_inverse[t]; |
| 243 | return _trans_rotation(URr, c); | 171 | |
| 244 | case _trans_DFr: | 172 | ret = compose(trans_cube, c); |
| 245 | return _trans_rotation(DFr, c); | 173 | ret = compose(ret, trans_inv); |
| 246 | case _trans_DLr: | 174 | |
| 247 | return _trans_rotation(DLr, c); | 175 | return t < 24 ? ret : invertco(ret); |
| 248 | case _trans_DBr: | ||
| 249 | return _trans_rotation(DBr, c); | ||
| 250 | case _trans_DRr: | ||
| 251 | return _trans_rotation(DRr, c); | ||
| 252 | case _trans_RUr: | ||
| 253 | return _trans_rotation(RUr, c); | ||
| 254 | case _trans_RFr: | ||
| 255 | return _trans_rotation(RFr, c); | ||
| 256 | case _trans_RDr: | ||
| 257 | return _trans_rotation(RDr, c); | ||
| 258 | case _trans_RBr: | ||
| 259 | return _trans_rotation(RBr, c); | ||
| 260 | case _trans_LUr: | ||
| 261 | return _trans_rotation(LUr, c); | ||
| 262 | case _trans_LFr: | ||
| 263 | return _trans_rotation(LFr, c); | ||
| 264 | case _trans_LDr: | ||
| 265 | return _trans_rotation(LDr, c); | ||
| 266 | case _trans_LBr: | ||
| 267 | return _trans_rotation(LBr, c); | ||
| 268 | case _trans_FUr: | ||
| 269 | return _trans_rotation(FUr, c); | ||
| 270 | case _trans_FRr: | ||
| 271 | return _trans_rotation(FRr, c); | ||
| 272 | case _trans_FDr: | ||
| 273 | return _trans_rotation(FDr, c); | ||
| 274 | case _trans_FLr: | ||
| 275 | return _trans_rotation(FLr, c); | ||
| 276 | case _trans_BUr: | ||
| 277 | return _trans_rotation(BUr, c); | ||
| 278 | case _trans_BRr: | ||
| 279 | return _trans_rotation(BRr, c); | ||
| 280 | case _trans_BDr: | ||
| 281 | return _trans_rotation(BDr, c); | ||
| 282 | case _trans_BLr: | ||
| 283 | return _trans_rotation(BLr, c); | ||
| 284 | case _trans_UFm: | ||
| 285 | return _trans_mirrored(UFm, c); | ||
| 286 | case _trans_ULm: | ||
| 287 | return _trans_mirrored(ULm, c); | ||
| 288 | case _trans_UBm: | ||
| 289 | return _trans_mirrored(UBm, c); | ||
| 290 | case _trans_URm: | ||
| 291 | return _trans_mirrored(URm, c); | ||
| 292 | case _trans_DFm: | ||
| 293 | return _trans_mirrored(DFm, c); | ||
| 294 | case _trans_DLm: | ||
| 295 | return _trans_mirrored(DLm, c); | ||
| 296 | case _trans_DBm: | ||
| 297 | return _trans_mirrored(DBm, c); | ||
| 298 | case _trans_DRm: | ||
| 299 | return _trans_mirrored(DRm, c); | ||
| 300 | case _trans_RUm: | ||
| 301 | return _trans_mirrored(RUm, c); | ||
| 302 | case _trans_RFm: | ||
| 303 | return _trans_mirrored(RFm, c); | ||
| 304 | case _trans_RDm: | ||
| 305 | return _trans_mirrored(RDm, c); | ||
| 306 | case _trans_RBm: | ||
| 307 | return _trans_mirrored(RBm, c); | ||
| 308 | case _trans_LUm: | ||
| 309 | return _trans_mirrored(LUm, c); | ||
| 310 | case _trans_LFm: | ||
| 311 | return _trans_mirrored(LFm, c); | ||
| 312 | case _trans_LDm: | ||
| 313 | return _trans_mirrored(LDm, c); | ||
| 314 | case _trans_LBm: | ||
| 315 | return _trans_mirrored(LBm, c); | ||
| 316 | case _trans_FUm: | ||
| 317 | return _trans_mirrored(FUm, c); | ||
| 318 | case _trans_FRm: | ||
| 319 | return _trans_mirrored(FRm, c); | ||
| 320 | case _trans_FDm: | ||
| 321 | return _trans_mirrored(FDm, c); | ||
| 322 | case _trans_FLm: | ||
| 323 | return _trans_mirrored(FLm, c); | ||
| 324 | case _trans_BUm: | ||
| 325 | return _trans_mirrored(BUm, c); | ||
| 326 | case _trans_BRm: | ||
| 327 | return _trans_mirrored(BRm, c); | ||
| 328 | case _trans_BDm: | ||
| 329 | return _trans_mirrored(BDm, c); | ||
| 330 | case _trans_BLm: | ||
| 331 | return _trans_mirrored(BLm, c); | ||
| 332 | default: | ||
| 333 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 334 | return zero_fast; | ||
| 335 | } | ||
| 336 | } | 176 | } |
diff --git a/src/cube_transform_with_switch.h b/src/cube_transform_with_switch.h new file mode 100644 index 0000000..de62bf5 --- /dev/null +++ b/src/cube_transform_with_switch.h | |||
| @@ -0,0 +1,336 @@ | |||
| 1 | #define _trans_edges_rotation(T, c) \ | ||
| 2 | compose_edges(compose_edges(_trans_cube_ ## T, c), \ | ||
| 3 | _trans_cube_ ## T ## _inverse) | ||
| 4 | #define _trans_edges_mirrored(T, c) _trans_edges_rotation(T, c) | ||
| 5 | |||
| 6 | #define _trans_corners_rotation(T, c) \ | ||
| 7 | compose_corners(compose_corners(_trans_cube_ ## T, c), \ | ||
| 8 | _trans_cube_ ## T ## _inverse) | ||
| 9 | #define _trans_corners_mirrored(T, c) \ | ||
| 10 | invertco(compose_corners( \ | ||
| 11 | compose_corners(_trans_cube_ ## T, c), _trans_cube_ ## T ## _inverse)) | ||
| 12 | |||
| 13 | #define _trans_rotation(T, c) \ | ||
| 14 | compose(compose(_trans_cube_ ## T, c), \ | ||
| 15 | _trans_cube_ ## T ## _inverse) | ||
| 16 | #define _trans_mirrored(T, c) \ | ||
| 17 | invertco(compose(compose(_trans_cube_ ## T, c), \ | ||
| 18 | _trans_cube_ ## T ## _inverse)) | ||
| 19 | |||
| 20 | _static cube_t | ||
| 21 | transform_edges(cube_t c, uint8_t t) | ||
| 22 | { | ||
| 23 | switch (t) { | ||
| 24 | case _trans_UFr: | ||
| 25 | return _trans_edges_rotation(UFr, c); | ||
| 26 | case _trans_ULr: | ||
| 27 | return _trans_edges_rotation(ULr, c); | ||
| 28 | case _trans_UBr: | ||
| 29 | return _trans_edges_rotation(UBr, c); | ||
| 30 | case _trans_URr: | ||
| 31 | return _trans_edges_rotation(URr, c); | ||
| 32 | case _trans_DFr: | ||
| 33 | return _trans_edges_rotation(DFr, c); | ||
| 34 | case _trans_DLr: | ||
| 35 | return _trans_edges_rotation(DLr, c); | ||
| 36 | case _trans_DBr: | ||
| 37 | return _trans_edges_rotation(DBr, c); | ||
| 38 | case _trans_DRr: | ||
| 39 | return _trans_edges_rotation(DRr, c); | ||
| 40 | case _trans_RUr: | ||
| 41 | return _trans_edges_rotation(RUr, c); | ||
| 42 | case _trans_RFr: | ||
| 43 | return _trans_edges_rotation(RFr, c); | ||
| 44 | case _trans_RDr: | ||
| 45 | return _trans_edges_rotation(RDr, c); | ||
| 46 | case _trans_RBr: | ||
| 47 | return _trans_edges_rotation(RBr, c); | ||
| 48 | case _trans_LUr: | ||
| 49 | return _trans_edges_rotation(LUr, c); | ||
| 50 | case _trans_LFr: | ||
| 51 | return _trans_edges_rotation(LFr, c); | ||
| 52 | case _trans_LDr: | ||
| 53 | return _trans_edges_rotation(LDr, c); | ||
| 54 | case _trans_LBr: | ||
| 55 | return _trans_edges_rotation(LBr, c); | ||
| 56 | case _trans_FUr: | ||
| 57 | return _trans_edges_rotation(FUr, c); | ||
| 58 | case _trans_FRr: | ||
| 59 | return _trans_edges_rotation(FRr, c); | ||
| 60 | case _trans_FDr: | ||
| 61 | return _trans_edges_rotation(FDr, c); | ||
| 62 | case _trans_FLr: | ||
| 63 | return _trans_edges_rotation(FLr, c); | ||
| 64 | case _trans_BUr: | ||
| 65 | return _trans_edges_rotation(BUr, c); | ||
| 66 | case _trans_BRr: | ||
| 67 | return _trans_edges_rotation(BRr, c); | ||
| 68 | case _trans_BDr: | ||
| 69 | return _trans_edges_rotation(BDr, c); | ||
| 70 | case _trans_BLr: | ||
| 71 | return _trans_edges_rotation(BLr, c); | ||
| 72 | case _trans_UFm: | ||
| 73 | return _trans_edges_mirrored(UFm, c); | ||
| 74 | case _trans_ULm: | ||
| 75 | return _trans_edges_mirrored(ULm, c); | ||
| 76 | case _trans_UBm: | ||
| 77 | return _trans_edges_mirrored(UBm, c); | ||
| 78 | case _trans_URm: | ||
| 79 | return _trans_edges_mirrored(URm, c); | ||
| 80 | case _trans_DFm: | ||
| 81 | return _trans_edges_mirrored(DFm, c); | ||
| 82 | case _trans_DLm: | ||
| 83 | return _trans_edges_mirrored(DLm, c); | ||
| 84 | case _trans_DBm: | ||
| 85 | return _trans_edges_mirrored(DBm, c); | ||
| 86 | case _trans_DRm: | ||
| 87 | return _trans_edges_mirrored(DRm, c); | ||
| 88 | case _trans_RUm: | ||
| 89 | return _trans_edges_mirrored(RUm, c); | ||
| 90 | case _trans_RFm: | ||
| 91 | return _trans_edges_mirrored(RFm, c); | ||
| 92 | case _trans_RDm: | ||
| 93 | return _trans_edges_mirrored(RDm, c); | ||
| 94 | case _trans_RBm: | ||
| 95 | return _trans_edges_mirrored(RBm, c); | ||
| 96 | case _trans_LUm: | ||
| 97 | return _trans_edges_mirrored(LUm, c); | ||
| 98 | case _trans_LFm: | ||
| 99 | return _trans_edges_mirrored(LFm, c); | ||
| 100 | case _trans_LDm: | ||
| 101 | return _trans_edges_mirrored(LDm, c); | ||
| 102 | case _trans_LBm: | ||
| 103 | return _trans_edges_mirrored(LBm, c); | ||
| 104 | case _trans_FUm: | ||
| 105 | return _trans_edges_mirrored(FUm, c); | ||
| 106 | case _trans_FRm: | ||
| 107 | return _trans_edges_mirrored(FRm, c); | ||
| 108 | case _trans_FDm: | ||
| 109 | return _trans_edges_mirrored(FDm, c); | ||
| 110 | case _trans_FLm: | ||
| 111 | return _trans_edges_mirrored(FLm, c); | ||
| 112 | case _trans_BUm: | ||
| 113 | return _trans_edges_mirrored(BUm, c); | ||
| 114 | case _trans_BRm: | ||
| 115 | return _trans_edges_mirrored(BRm, c); | ||
| 116 | case _trans_BDm: | ||
| 117 | return _trans_edges_mirrored(BDm, c); | ||
| 118 | case _trans_BLm: | ||
| 119 | return _trans_edges_mirrored(BLm, c); | ||
| 120 | default: | ||
| 121 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 122 | return zero; | ||
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 | _static cube_t | ||
| 127 | transform_corners(cube_t c, uint8_t t) | ||
| 128 | { | ||
| 129 | switch (t) { | ||
| 130 | case _trans_UFr: | ||
| 131 | return _trans_corners_rotation(UFr, c); | ||
| 132 | case _trans_ULr: | ||
| 133 | return _trans_corners_rotation(ULr, c); | ||
| 134 | case _trans_UBr: | ||
| 135 | return _trans_corners_rotation(UBr, c); | ||
| 136 | case _trans_URr: | ||
| 137 | return _trans_corners_rotation(URr, c); | ||
| 138 | case _trans_DFr: | ||
| 139 | return _trans_corners_rotation(DFr, c); | ||
| 140 | case _trans_DLr: | ||
| 141 | return _trans_corners_rotation(DLr, c); | ||
| 142 | case _trans_DBr: | ||
| 143 | return _trans_corners_rotation(DBr, c); | ||
| 144 | case _trans_DRr: | ||
| 145 | return _trans_corners_rotation(DRr, c); | ||
| 146 | case _trans_RUr: | ||
| 147 | return _trans_corners_rotation(RUr, c); | ||
| 148 | case _trans_RFr: | ||
| 149 | return _trans_corners_rotation(RFr, c); | ||
| 150 | case _trans_RDr: | ||
| 151 | return _trans_corners_rotation(RDr, c); | ||
| 152 | case _trans_RBr: | ||
| 153 | return _trans_corners_rotation(RBr, c); | ||
| 154 | case _trans_LUr: | ||
| 155 | return _trans_corners_rotation(LUr, c); | ||
| 156 | case _trans_LFr: | ||
| 157 | return _trans_corners_rotation(LFr, c); | ||
| 158 | case _trans_LDr: | ||
| 159 | return _trans_corners_rotation(LDr, c); | ||
| 160 | case _trans_LBr: | ||
| 161 | return _trans_corners_rotation(LBr, c); | ||
| 162 | case _trans_FUr: | ||
| 163 | return _trans_corners_rotation(FUr, c); | ||
| 164 | case _trans_FRr: | ||
| 165 | return _trans_corners_rotation(FRr, c); | ||
| 166 | case _trans_FDr: | ||
| 167 | return _trans_corners_rotation(FDr, c); | ||
| 168 | case _trans_FLr: | ||
| 169 | return _trans_corners_rotation(FLr, c); | ||
| 170 | case _trans_BUr: | ||
| 171 | return _trans_corners_rotation(BUr, c); | ||
| 172 | case _trans_BRr: | ||
| 173 | return _trans_corners_rotation(BRr, c); | ||
| 174 | case _trans_BDr: | ||
| 175 | return _trans_corners_rotation(BDr, c); | ||
| 176 | case _trans_BLr: | ||
| 177 | return _trans_corners_rotation(BLr, c); | ||
| 178 | case _trans_UFm: | ||
| 179 | return _trans_corners_mirrored(UFm, c); | ||
| 180 | case _trans_ULm: | ||
| 181 | return _trans_corners_mirrored(ULm, c); | ||
| 182 | case _trans_UBm: | ||
| 183 | return _trans_corners_mirrored(UBm, c); | ||
| 184 | case _trans_URm: | ||
| 185 | return _trans_corners_mirrored(URm, c); | ||
| 186 | case _trans_DFm: | ||
| 187 | return _trans_corners_mirrored(DFm, c); | ||
| 188 | case _trans_DLm: | ||
| 189 | return _trans_corners_mirrored(DLm, c); | ||
| 190 | case _trans_DBm: | ||
| 191 | return _trans_corners_mirrored(DBm, c); | ||
| 192 | case _trans_DRm: | ||
| 193 | return _trans_corners_mirrored(DRm, c); | ||
| 194 | case _trans_RUm: | ||
| 195 | return _trans_corners_mirrored(RUm, c); | ||
| 196 | case _trans_RFm: | ||
| 197 | return _trans_corners_mirrored(RFm, c); | ||
| 198 | case _trans_RDm: | ||
| 199 | return _trans_corners_mirrored(RDm, c); | ||
| 200 | case _trans_RBm: | ||
| 201 | return _trans_corners_mirrored(RBm, c); | ||
| 202 | case _trans_LUm: | ||
| 203 | return _trans_corners_mirrored(LUm, c); | ||
| 204 | case _trans_LFm: | ||
| 205 | return _trans_corners_mirrored(LFm, c); | ||
| 206 | case _trans_LDm: | ||
| 207 | return _trans_corners_mirrored(LDm, c); | ||
| 208 | case _trans_LBm: | ||
| 209 | return _trans_corners_mirrored(LBm, c); | ||
| 210 | case _trans_FUm: | ||
| 211 | return _trans_corners_mirrored(FUm, c); | ||
| 212 | case _trans_FRm: | ||
| 213 | return _trans_corners_mirrored(FRm, c); | ||
| 214 | case _trans_FDm: | ||
| 215 | return _trans_corners_mirrored(FDm, c); | ||
| 216 | case _trans_FLm: | ||
| 217 | return _trans_corners_mirrored(FLm, c); | ||
| 218 | case _trans_BUm: | ||
| 219 | return _trans_corners_mirrored(BUm, c); | ||
| 220 | case _trans_BRm: | ||
| 221 | return _trans_corners_mirrored(BRm, c); | ||
| 222 | case _trans_BDm: | ||
| 223 | return _trans_corners_mirrored(BDm, c); | ||
| 224 | case _trans_BLm: | ||
| 225 | return _trans_corners_mirrored(BLm, c); | ||
| 226 | default: | ||
| 227 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 228 | return zero; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | _static cube_t | ||
| 233 | transform(cube_t c, uint8_t t) | ||
| 234 | { | ||
| 235 | switch (t) { | ||
| 236 | case _trans_UFr: | ||
| 237 | return _trans_rotation(UFr, c); | ||
| 238 | case _trans_ULr: | ||
| 239 | return _trans_rotation(ULr, c); | ||
| 240 | case _trans_UBr: | ||
| 241 | return _trans_rotation(UBr, c); | ||
| 242 | case _trans_URr: | ||
| 243 | return _trans_rotation(URr, c); | ||
| 244 | case _trans_DFr: | ||
| 245 | return _trans_rotation(DFr, c); | ||
| 246 | case _trans_DLr: | ||
| 247 | return _trans_rotation(DLr, c); | ||
| 248 | case _trans_DBr: | ||
| 249 | return _trans_rotation(DBr, c); | ||
| 250 | case _trans_DRr: | ||
| 251 | return _trans_rotation(DRr, c); | ||
| 252 | case _trans_RUr: | ||
| 253 | return _trans_rotation(RUr, c); | ||
| 254 | case _trans_RFr: | ||
| 255 | return _trans_rotation(RFr, c); | ||
| 256 | case _trans_RDr: | ||
| 257 | return _trans_rotation(RDr, c); | ||
| 258 | case _trans_RBr: | ||
| 259 | return _trans_rotation(RBr, c); | ||
| 260 | case _trans_LUr: | ||
| 261 | return _trans_rotation(LUr, c); | ||
| 262 | case _trans_LFr: | ||
| 263 | return _trans_rotation(LFr, c); | ||
| 264 | case _trans_LDr: | ||
| 265 | return _trans_rotation(LDr, c); | ||
| 266 | case _trans_LBr: | ||
| 267 | return _trans_rotation(LBr, c); | ||
| 268 | case _trans_FUr: | ||
| 269 | return _trans_rotation(FUr, c); | ||
| 270 | case _trans_FRr: | ||
| 271 | return _trans_rotation(FRr, c); | ||
| 272 | case _trans_FDr: | ||
| 273 | return _trans_rotation(FDr, c); | ||
| 274 | case _trans_FLr: | ||
| 275 | return _trans_rotation(FLr, c); | ||
| 276 | case _trans_BUr: | ||
| 277 | return _trans_rotation(BUr, c); | ||
| 278 | case _trans_BRr: | ||
| 279 | return _trans_rotation(BRr, c); | ||
| 280 | case _trans_BDr: | ||
| 281 | return _trans_rotation(BDr, c); | ||
| 282 | case _trans_BLr: | ||
| 283 | return _trans_rotation(BLr, c); | ||
| 284 | case _trans_UFm: | ||
| 285 | return _trans_mirrored(UFm, c); | ||
| 286 | case _trans_ULm: | ||
| 287 | return _trans_mirrored(ULm, c); | ||
| 288 | case _trans_UBm: | ||
| 289 | return _trans_mirrored(UBm, c); | ||
| 290 | case _trans_URm: | ||
| 291 | return _trans_mirrored(URm, c); | ||
| 292 | case _trans_DFm: | ||
| 293 | return _trans_mirrored(DFm, c); | ||
| 294 | case _trans_DLm: | ||
| 295 | return _trans_mirrored(DLm, c); | ||
| 296 | case _trans_DBm: | ||
| 297 | return _trans_mirrored(DBm, c); | ||
| 298 | case _trans_DRm: | ||
| 299 | return _trans_mirrored(DRm, c); | ||
| 300 | case _trans_RUm: | ||
| 301 | return _trans_mirrored(RUm, c); | ||
| 302 | case _trans_RFm: | ||
| 303 | return _trans_mirrored(RFm, c); | ||
| 304 | case _trans_RDm: | ||
| 305 | return _trans_mirrored(RDm, c); | ||
| 306 | case _trans_RBm: | ||
| 307 | return _trans_mirrored(RBm, c); | ||
| 308 | case _trans_LUm: | ||
| 309 | return _trans_mirrored(LUm, c); | ||
| 310 | case _trans_LFm: | ||
| 311 | return _trans_mirrored(LFm, c); | ||
| 312 | case _trans_LDm: | ||
| 313 | return _trans_mirrored(LDm, c); | ||
| 314 | case _trans_LBm: | ||
| 315 | return _trans_mirrored(LBm, c); | ||
| 316 | case _trans_FUm: | ||
| 317 | return _trans_mirrored(FUm, c); | ||
| 318 | case _trans_FRm: | ||
| 319 | return _trans_mirrored(FRm, c); | ||
| 320 | case _trans_FDm: | ||
| 321 | return _trans_mirrored(FDm, c); | ||
| 322 | case _trans_FLm: | ||
| 323 | return _trans_mirrored(FLm, c); | ||
| 324 | case _trans_BUm: | ||
| 325 | return _trans_mirrored(BUm, c); | ||
| 326 | case _trans_BRm: | ||
| 327 | return _trans_mirrored(BRm, c); | ||
| 328 | case _trans_BDm: | ||
| 329 | return _trans_mirrored(BDm, c); | ||
| 330 | case _trans_BLm: | ||
| 331 | return _trans_mirrored(BLm, c); | ||
| 332 | default: | ||
| 333 | DBG_LOG("transform error, unknown transformation\n"); | ||
| 334 | return zero; | ||
| 335 | } | ||
| 336 | } | ||
diff --git a/src/solve_generic.h b/src/solve_generic.h index 6cdcc33..b5d1e2d 100644 --- a/src/solve_generic.h +++ b/src/solve_generic.h | |||
| @@ -1,19 +1,19 @@ | |||
| 1 | typedef struct { | 1 | typedef struct { |
| 2 | cube_fast_t cube; | 2 | cube_t cube; |
| 3 | uint8_t depth; | 3 | uint8_t depth; |
| 4 | int64_t maxsols; | 4 | int64_t maxsols; |
| 5 | char **nextsol; | 5 | char **nextsol; |
| 6 | int64_t *nsols; | 6 | int64_t *nsols; |
| 7 | uint8_t nmoves; | 7 | uint8_t nmoves; |
| 8 | uint8_t moves[20]; | 8 | uint8_t moves[20]; |
| 9 | uint8_t (*estimate)(cube_fast_t); | 9 | uint8_t (*estimate)(cube_t); |
| 10 | } dfsarg_generic_t; | 10 | } dfsarg_generic_t; |
| 11 | 11 | ||
| 12 | _static void solve_generic_appendsolution(dfsarg_generic_t *); | 12 | _static void solve_generic_appendsolution(dfsarg_generic_t *); |
| 13 | _static int solve_generic_dfs(dfsarg_generic_t *); | 13 | _static int solve_generic_dfs(dfsarg_generic_t *); |
| 14 | _static int64_t solve_generic(cube_t, const char *, int8_t, int8_t, int64_t, | 14 | _static int64_t solve_generic(cube_t, const char *, int8_t, int8_t, int64_t, |
| 15 | int8_t, char *, uint8_t (*)(cube_fast_t)); | 15 | int8_t, char *, uint8_t (*)(cube_t)); |
| 16 | _static uint8_t estimate_simple(cube_fast_t); | 16 | _static uint8_t estimate_simple(cube_t); |
| 17 | _static int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); | 17 | _static int64_t solve_simple(cube_t, int8_t, int8_t, int64_t, int8_t, char *); |
| 18 | 18 | ||
| 19 | int64_t | 19 | int64_t |
| @@ -135,7 +135,7 @@ solve_generic( | |||
| 135 | int64_t maxsols, | 135 | int64_t maxsols, |
| 136 | int8_t optimal, | 136 | int8_t optimal, |
| 137 | char *sols, | 137 | char *sols, |
| 138 | uint8_t (*estimate)(cube_fast_t) | 138 | uint8_t (*estimate)(cube_t) |
| 139 | /* TODO: add validator */ | 139 | /* TODO: add validator */ |
| 140 | /* TODO: maybe add data for estimate */ | 140 | /* TODO: maybe add data for estimate */ |
| 141 | /* TODO: add moveset (and allowednext?) */ | 141 | /* TODO: add moveset (and allowednext?) */ |
| @@ -190,7 +190,7 @@ solve_generic( | |||
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | arg = (dfsarg_generic_t) { | 192 | arg = (dfsarg_generic_t) { |
| 193 | .cube = cubetofast(cube), | 193 | .cube = cube, |
| 194 | .maxsols = maxsols, | 194 | .maxsols = maxsols, |
| 195 | .nextsol = &sols, | 195 | .nextsol = &sols, |
| 196 | .nsols = &ret, | 196 | .nsols = &ret, |
| @@ -223,9 +223,9 @@ solve_generic( | |||
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | _static uint8_t | 225 | _static uint8_t |
| 226 | estimate_simple(cube_fast_t cube) | 226 | estimate_simple(cube_t cube) |
| 227 | { | 227 | { |
| 228 | return issolved_fast(cube) ? 0 : 1; | 228 | return issolved(cube) ? 0 : 1; |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | _static int64_t | 231 | _static int64_t |
diff --git a/src/solve_h48.h b/src/solve_h48.h index abf7a86..8691d49 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h | |||
| @@ -20,14 +20,14 @@ | |||
| 20 | #define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8))) | 20 | #define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8))) |
| 21 | 21 | ||
| 22 | typedef struct { | 22 | typedef struct { |
| 23 | cube_fast_t cube; | 23 | cube_t cube; |
| 24 | uint8_t depth; | 24 | uint8_t depth; |
| 25 | uint8_t maxdepth; | 25 | uint8_t maxdepth; |
| 26 | uint16_t *n; | 26 | uint16_t *n; |
| 27 | uint32_t *buf32; | 27 | uint32_t *buf32; |
| 28 | uint8_t *visited; | 28 | uint8_t *visited; |
| 29 | uint64_t *selfsim; | 29 | uint64_t *selfsim; |
| 30 | cube_fast_t *rep; | 30 | cube_t *rep; |
| 31 | } dfsarg_cocsep_t; | 31 | } dfsarg_cocsep_t; |
| 32 | 32 | ||
| 33 | typedef struct { | 33 | typedef struct { |
| @@ -36,14 +36,14 @@ typedef struct { | |||
| 36 | uint32_t *cocsepdata; | 36 | uint32_t *cocsepdata; |
| 37 | uint32_t *buf32; | 37 | uint32_t *buf32; |
| 38 | uint64_t *selfsim; | 38 | uint64_t *selfsim; |
| 39 | cube_fast_t *crep; | 39 | cube_t *crep; |
| 40 | } bfsarg_esep_t; | 40 | } bfsarg_esep_t; |
| 41 | 41 | ||
| 42 | _static_inline int64_t coord_h48(cube_fast_t, const uint32_t *, uint8_t); | 42 | _static_inline int64_t coord_h48(cube_t, const uint32_t *, uint8_t); |
| 43 | _static_inline int64_t coord_h48_edges(cube_fast_t, int64_t, uint8_t, uint8_t); | 43 | _static_inline int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); |
| 44 | _static_inline cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); | 44 | _static_inline cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); |
| 45 | 45 | ||
| 46 | _static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | 46 | _static size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 47 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); | 47 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); |
| 48 | _static size_t gendata_h48(void *, uint8_t, uint8_t); | 48 | _static size_t gendata_h48(void *, uint8_t, uint8_t); |
| 49 | _static uint64_t gendata_esep_bfs(bfsarg_esep_t *); | 49 | _static uint64_t gendata_esep_bfs(bfsarg_esep_t *); |
| @@ -54,7 +54,7 @@ _static_inline uint8_t get_esep_pval(const uint32_t *, int64_t); | |||
| 54 | _static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t); | 54 | _static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t); |
| 55 | 55 | ||
| 56 | _static_inline int64_t | 56 | _static_inline int64_t |
| 57 | coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | 57 | coord_h48(cube_t c, const uint32_t *cocsepdata, uint8_t h) |
| 58 | { | 58 | { |
| 59 | int64_t cocsep, coclass; | 59 | int64_t cocsep, coclass; |
| 60 | uint32_t data; | 60 | uint32_t data; |
| @@ -62,7 +62,7 @@ coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | |||
| 62 | 62 | ||
| 63 | DBG_ASSERT(h <= 11, -1, "coord_h48: h must be between 0 and 11\n"); | 63 | DBG_ASSERT(h <= 11, -1, "coord_h48: h must be between 0 and 11\n"); |
| 64 | 64 | ||
| 65 | cocsep = coord_fast_cocsep(c); | 65 | cocsep = coord_cocsep(c); |
| 66 | data = cocsepdata[cocsep]; | 66 | data = cocsepdata[cocsep]; |
| 67 | coclass = (int64_t)COCLASS(data); | 67 | coclass = (int64_t)COCLASS(data); |
| 68 | ttrep = (int64_t)TTREP(data); | 68 | ttrep = (int64_t)TTREP(data); |
| @@ -71,14 +71,14 @@ coord_h48(cube_fast_t c, const uint32_t *cocsepdata, uint8_t h) | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | _static_inline int64_t | 73 | _static_inline int64_t |
| 74 | coord_h48_edges(cube_fast_t c, int64_t coclass, uint8_t t, uint8_t h) | 74 | coord_h48_edges(cube_t c, int64_t coclass, uint8_t t, uint8_t h) |
| 75 | { | 75 | { |
| 76 | cube_fast_t d; | 76 | cube_t d; |
| 77 | int64_t esep, eo, edges; | 77 | int64_t esep, eo, edges; |
| 78 | 78 | ||
| 79 | d = transform_edges(c, t); | 79 | d = transform_edges(c, t); |
| 80 | esep = coord_fast_esep(d); | 80 | esep = coord_esep(d); |
| 81 | eo = coord_fast_eo(d); | 81 | eo = coord_eo(d); |
| 82 | edges = (esep << (int64_t)h) + (eo >> (11 - (int64_t)h)); | 82 | edges = (esep << (int64_t)h) + (eo >> (11 - (int64_t)h)); |
| 83 | 83 | ||
| 84 | return coclass * H48_ESIZE(h) + edges; | 84 | return coclass * H48_ESIZE(h) + edges; |
| @@ -89,12 +89,12 @@ This function does not necessarily return a cube whose coordinate is | |||
| 89 | the given value, because it works up to symmetry. This means that the | 89 | the given value, because it works up to symmetry. This means that the |
| 90 | returned cube is a transformed cube of one that gives the correct value. | 90 | returned cube is a transformed cube of one that gives the correct value. |
| 91 | */ | 91 | */ |
| 92 | _static_inline cube_fast_t | 92 | _static_inline cube_t |
| 93 | invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) { | 93 | invcoord_h48(int64_t i, const cube_t *crep, uint8_t h) { |
| 94 | cube_fast_t ret; | 94 | cube_t ret; |
| 95 | int64_t hh, coclass, ee, esep, eo; | 95 | int64_t hh, coclass, ee, esep, eo; |
| 96 | 96 | ||
| 97 | DBG_ASSERT(h <= 11, cubetofast(zero), | 97 | DBG_ASSERT(h <= 11, zero, |
| 98 | "invcoord_h48: h must be between 0 and 11\n"); | 98 | "invcoord_h48: h must be between 0 and 11\n"); |
| 99 | 99 | ||
| 100 | hh = (int64_t)h; | 100 | hh = (int64_t)h; |
| @@ -103,9 +103,9 @@ invcoord_h48(int64_t i, const cube_fast_t *crep, uint8_t h) { | |||
| 103 | esep = ee >> hh; | 103 | esep = ee >> hh; |
| 104 | eo = (ee & ((1 << hh) - 1)) << (11 - hh); | 104 | eo = (ee & ((1 << hh) - 1)) << (11 - hh); |
| 105 | 105 | ||
| 106 | ret = invcoord_fast_esep(esep); | 106 | ret = invcoord_esep(esep); |
| 107 | copy_corners_fast(&ret, crep[coclass]); | 107 | copy_corners(&ret, crep[coclass]); |
| 108 | set_eo_fast(&ret, eo); | 108 | set_eo(&ret, eo); |
| 109 | 109 | ||
| 110 | return ret; | 110 | return ret; |
| 111 | } | 111 | } |
| @@ -122,7 +122,7 @@ After the data as described above, more auxiliary information is appended: | |||
| 122 | of positions having that pruning value. | 122 | of positions having that pruning value. |
| 123 | */ | 123 | */ |
| 124 | _static size_t | 124 | _static size_t |
| 125 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep) | 125 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) |
| 126 | { | 126 | { |
| 127 | uint32_t *buf32, *info, cc; | 127 | uint32_t *buf32, *info, cc; |
| 128 | uint16_t n; | 128 | uint16_t n; |
| @@ -135,7 +135,7 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep) | |||
| 135 | memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); | 135 | memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); |
| 136 | 136 | ||
| 137 | arg = (dfsarg_cocsep_t) { | 137 | arg = (dfsarg_cocsep_t) { |
| 138 | .cube = cubetofast(solvedcube()), | 138 | .cube = solved, |
| 139 | .n = &n, | 139 | .n = &n, |
| 140 | .buf32 = buf32, | 140 | .buf32 = buf32, |
| 141 | .visited = visited, | 141 | .visited = visited, |
| @@ -175,10 +175,10 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) | |||
| 175 | uint32_t cc, class, ttrep, depth, olddepth; | 175 | uint32_t cc, class, ttrep, depth, olddepth; |
| 176 | uint64_t t, is; | 176 | uint64_t t, is; |
| 177 | int64_t i, j; | 177 | int64_t i, j; |
| 178 | cube_fast_t d; | 178 | cube_t d; |
| 179 | dfsarg_cocsep_t nextarg; | 179 | dfsarg_cocsep_t nextarg; |
| 180 | 180 | ||
| 181 | i = coord_fast_cocsep(arg->cube); | 181 | i = coord_cocsep(arg->cube); |
| 182 | olddepth = (uint8_t)(arg->buf32[i] & 0xFF); | 182 | olddepth = (uint8_t)(arg->buf32[i] & 0xFF); |
| 183 | if (olddepth < arg->depth || get_visited(arg->visited, i)) | 183 | if (olddepth < arg->depth || get_visited(arg->visited, i)) |
| 184 | return 0; | 184 | return 0; |
| @@ -190,7 +190,7 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) | |||
| 190 | 190 | ||
| 191 | for (t = 0, cc = 0; t < 48; t++) { | 191 | for (t = 0, cc = 0; t < 48; t++) { |
| 192 | d = transform_corners(arg->cube, t); | 192 | d = transform_corners(arg->cube, t); |
| 193 | j = coord_fast_cocsep(d); | 193 | j = coord_cocsep(d); |
| 194 | is = (i == j); | 194 | is = (i == j); |
| 195 | arg->selfsim[*arg->n] |= is << t; | 195 | arg->selfsim[*arg->n] |= is << t; |
| 196 | set_visited(arg->visited, j); | 196 | set_visited(arg->visited, j); |
| @@ -231,7 +231,7 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) | |||
| 231 | bfsarg_esep_t arg; | 231 | bfsarg_esep_t arg; |
| 232 | int64_t sc, cc, tot, esep_max; | 232 | int64_t sc, cc, tot, esep_max; |
| 233 | uint64_t selfsim[COCSEP_CLASSES]; | 233 | uint64_t selfsim[COCSEP_CLASSES]; |
| 234 | cube_fast_t crep[COCSEP_CLASSES]; | 234 | cube_t crep[COCSEP_CLASSES]; |
| 235 | size_t cocsepsize, infosize; | 235 | size_t cocsepsize, infosize; |
| 236 | 236 | ||
| 237 | esep_max = (int64_t)ESEP_MAX(h); | 237 | esep_max = (int64_t)ESEP_MAX(h); |
| @@ -241,7 +241,7 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) | |||
| 241 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); | 241 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); |
| 242 | memset(buf32, 0xFF, ESEP_TABLESIZE(h, k)); | 242 | memset(buf32, 0xFF, ESEP_TABLESIZE(h, k)); |
| 243 | 243 | ||
| 244 | sc = coord_h48(cubetofast(solved), cocsepdata, h); | 244 | sc = coord_h48(solved, cocsepdata, h); |
| 245 | set_esep_pval(buf32, sc, 0); | 245 | set_esep_pval(buf32, sc, 0); |
| 246 | info[1] = 1; | 246 | info[1] = 1; |
| 247 | arg = (bfsarg_esep_t) { | 247 | arg = (bfsarg_esep_t) { |
| @@ -281,7 +281,7 @@ gendata_esep_bfs(bfsarg_esep_t *arg) | |||
| 281 | uint8_t c, m, x; | 281 | uint8_t c, m, x; |
| 282 | uint32_t cc; | 282 | uint32_t cc; |
| 283 | int64_t i, j, k, t, cocsep_coord, sim, esep_max; | 283 | int64_t i, j, k, t, cocsep_coord, sim, esep_max; |
| 284 | cube_fast_t cube, moved, transd; | 284 | cube_t cube, moved, transd; |
| 285 | 285 | ||
| 286 | esep_max = (uint64_t)ESEP_MAX(arg->h); | 286 | esep_max = (uint64_t)ESEP_MAX(arg->h); |
| 287 | 287 | ||
diff --git a/test/001_pieces/pieces_tests.c b/test/001_pieces/pieces_tests.c index f3d8d4e..1ef2fd0 100644 --- a/test/001_pieces/pieces_tests.c +++ b/test/001_pieces/pieces_tests.c | |||
| @@ -1,13 +1,12 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | uint8_t corner(cube_fast_t, int); | 3 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 4 | uint8_t edge(cube_fast_t, int); | ||
| 5 | 4 | ||
| 6 | int main(void) { | 5 | int main(void) { |
| 7 | int i; | 6 | int i; |
| 7 | uint8_t corner[8], edge[12]; | ||
| 8 | char str[STRLENMAX], *aux; | 8 | char str[STRLENMAX], *aux; |
| 9 | cube_t cube; | 9 | cube_t cube; |
| 10 | cube_fast_t fast; | ||
| 11 | 10 | ||
| 12 | aux = str; | 11 | aux = str; |
| 13 | while (fgets(aux, STRLENMAX, stdin) != NULL) | 12 | while (fgets(aux, STRLENMAX, stdin) != NULL) |
| @@ -15,13 +14,13 @@ int main(void) { | |||
| 15 | aux++; | 14 | aux++; |
| 16 | 15 | ||
| 17 | cube = readcube("H48", str); | 16 | cube = readcube("H48", str); |
| 18 | fast = cubetofast(cube); | 17 | pieces(&cube, corner, edge); |
| 19 | 18 | ||
| 20 | for (i = 0; i < 8; i++) | 19 | for (i = 0; i < 8; i++) |
| 21 | printf("%" PRIu8 " ", corner(fast, i)); | 20 | printf("%" PRIu8 " ", corner[i]); |
| 22 | printf("\n"); | 21 | printf("\n"); |
| 23 | for (i = 0; i < 12; i++) | 22 | for (i = 0; i < 12; i++) |
| 24 | printf("%" PRIu8 " ", edge(fast, i)); | 23 | printf("%" PRIu8 " ", edge[i]); |
| 25 | printf("\n"); | 24 | printf("\n"); |
| 26 | 25 | ||
| 27 | return 0; | 26 | return 0; |
diff --git a/test/002_cube_conversion/00_solved.in b/test/002_cube_conversion/00_solved.in deleted file mode 100644 index dff224d..0000000 --- a/test/002_cube_conversion/00_solved.in +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
diff --git a/test/002_cube_conversion/00_solved.out b/test/002_cube_conversion/00_solved.out deleted file mode 100644 index dff224d..0000000 --- a/test/002_cube_conversion/00_solved.out +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
diff --git a/test/002_cube_conversion/01_scrambled.in b/test/002_cube_conversion/01_scrambled.in deleted file mode 100644 index 453cc8a..0000000 --- a/test/002_cube_conversion/01_scrambled.in +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | BL1 DB0 UL1 DF0 BR1 UF1 DL0 FL1 UB0 DR1 FR1 UR1 UBR2 UBL1 DFR2 DBL2 DBR0 DFL0 UFR0 UFL2 | ||
diff --git a/test/002_cube_conversion/01_scrambled.out b/test/002_cube_conversion/01_scrambled.out deleted file mode 100644 index 453cc8a..0000000 --- a/test/002_cube_conversion/01_scrambled.out +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | BL1 DB0 UL1 DF0 BR1 UF1 DL0 FL1 UB0 DR1 FR1 UR1 UBR2 UBL1 DFR2 DBL2 DBR0 DFL0 UFR0 UFL2 | ||
diff --git a/test/002_cube_conversion/cube_conversion_tests.c b/test/002_cube_conversion/cube_conversion_tests.c deleted file mode 100644 index df03eb6..0000000 --- a/test/002_cube_conversion/cube_conversion_tests.c +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | bool equal(cube_t, cube_t); | ||
| 4 | |||
| 5 | int main(void) { | ||
| 6 | char cubestr[STRLENMAX]; | ||
| 7 | cube_t cube, cube2; | ||
| 8 | cube_fast_t fast; | ||
| 9 | |||
| 10 | fgets(cubestr, STRLENMAX, stdin); | ||
| 11 | cube = readcube("H48", cubestr); | ||
| 12 | fast = cubetofast(cube); | ||
| 13 | cube2 = fasttocube(fast); | ||
| 14 | |||
| 15 | if (iserror(cube)) { | ||
| 16 | printf("Error reading cube\n"); | ||
| 17 | } else if (iserror(cube2)) { | ||
| 18 | printf("Error converting cube\n"); | ||
| 19 | } else { | ||
| 20 | writecube("H48", cube2, cubestr); | ||
| 21 | printf("%s\n", cubestr); | ||
| 22 | } | ||
| 23 | |||
| 24 | return 0; | ||
| 25 | } | ||
diff --git a/test/071_coord_eo/coord_eo_tests.c b/test/071_coord_eo/coord_eo_tests.c index 5eec4fc..3defb8b 100644 --- a/test/071_coord_eo/coord_eo_tests.c +++ b/test/071_coord_eo/coord_eo_tests.c | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_eo(cube_fast_t); | 3 | int64_t coord_eo(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | int main(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | cube_fast_t fast; | ||
| 9 | int64_t result; | 8 | int64_t result; |
| 10 | 9 | ||
| 11 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 12 | cube = readcube("H48", str); | 11 | cube = readcube("H48", str); |
| 13 | fast = cubetofast(cube); | ||
| 14 | 12 | ||
| 15 | result = coord_fast_eo(fast); | 13 | result = coord_eo(cube); |
| 16 | 14 | ||
| 17 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 18 | 16 | ||
diff --git a/test/072_coord_co/coord_co_tests.c b/test/072_coord_co/coord_co_tests.c index 8461324..c7af24c 100644 --- a/test/072_coord_co/coord_co_tests.c +++ b/test/072_coord_co/coord_co_tests.c | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_co(cube_fast_t); | 3 | int64_t coord_co(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | int main(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | cube_fast_t fast; | ||
| 9 | int64_t result; | 8 | int64_t result; |
| 10 | 9 | ||
| 11 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 12 | cube = readcube("H48", str); | 11 | cube = readcube("H48", str); |
| 13 | fast = cubetofast(cube); | ||
| 14 | 12 | ||
| 15 | result = coord_fast_co(fast); | 13 | result = coord_co(cube); |
| 16 | 14 | ||
| 17 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 18 | 16 | ||
diff --git a/test/073_coord_csep/coord_csep_tests.c b/test/073_coord_csep/coord_csep_tests.c index c4113d3..a6e13c5 100644 --- a/test/073_coord_csep/coord_csep_tests.c +++ b/test/073_coord_csep/coord_csep_tests.c | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_csep(cube_fast_t); | 3 | int64_t coord_csep(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | int main(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | cube_fast_t fast; | ||
| 9 | int64_t result; | 8 | int64_t result; |
| 10 | 9 | ||
| 11 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 12 | cube = readcube("H48", str); | 11 | cube = readcube("H48", str); |
| 13 | fast = cubetofast(cube); | ||
| 14 | 12 | ||
| 15 | result = coord_fast_csep(fast); | 13 | result = coord_csep(cube); |
| 16 | 14 | ||
| 17 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 18 | 16 | ||
diff --git a/test/074_coord_esep/coord_esep_tests.c b/test/074_coord_esep/coord_esep_tests.c index fa21d67..0ed3ef3 100644 --- a/test/074_coord_esep/coord_esep_tests.c +++ b/test/074_coord_esep/coord_esep_tests.c | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_esep(cube_fast_t); | 3 | int64_t coord_esep(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | int main(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | cube_fast_t fast; | ||
| 9 | int64_t result; | 8 | int64_t result; |
| 10 | 9 | ||
| 11 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 12 | cube = readcube("H48", str); | 11 | cube = readcube("H48", str); |
| 13 | fast = cubetofast(cube); | ||
| 14 | 12 | ||
| 15 | result = coord_fast_esep(fast); | 13 | result = coord_esep(cube); |
| 16 | 14 | ||
| 17 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 18 | 16 | ||
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index cd4868c..9c01a50 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c | |||
| @@ -1,32 +1,32 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_eo(cube_fast_t); | 3 | int64_t coord_eo(cube_t); |
| 4 | void set_eo_fast(cube_fast_t *, int64_t); | 4 | void set_eo(cube_t *, int64_t); |
| 5 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | ||
| 5 | 6 | ||
| 6 | int main(void) { | 7 | int main(void) { |
| 7 | char str[STRLENMAX]; | 8 | char str[STRLENMAX]; |
| 8 | cube_t cube; | 9 | cube_t cube; |
| 9 | cube_fast_t fast; | 10 | uint8_t edge[12], corner[8]; |
| 10 | int64_t eo; | 11 | int64_t eo; |
| 11 | 12 | ||
| 12 | fgets(str, STRLENMAX, stdin); | 13 | fgets(str, STRLENMAX, stdin); |
| 13 | cube = readcube("H48", str); | 14 | cube = readcube("H48", str); |
| 14 | fast = cubetofast(cube); | ||
| 15 | fgets(str, STRLENMAX, stdin); | 15 | fgets(str, STRLENMAX, stdin); |
| 16 | eo = atoi(str); | 16 | eo = atoi(str); |
| 17 | 17 | ||
| 18 | set_eo_fast(&fast, eo); | 18 | set_eo(&cube, eo); |
| 19 | 19 | ||
| 20 | cube = fasttocube(fast); | ||
| 21 | if (iserror(cube)) { | 20 | if (iserror(cube)) { |
| 22 | printf("Error setting EO\n"); | 21 | printf("Error setting EO\n"); |
| 23 | } else if (!isconsistent(cube)) { | 22 | } else if (!isconsistent(cube)) { |
| 23 | pieces(&cube, corner, edge); | ||
| 24 | fprintf(stderr, "edges: "); | 24 | fprintf(stderr, "edges: "); |
| 25 | for (int i = 0; i < 12; i++) | 25 | for (int i = 0; i < 12; i++) |
| 26 | fprintf(stderr, "%d ", cube.edge[i]); | 26 | fprintf(stderr, "%d ", edge[i]); |
| 27 | fprintf(stderr, "\n"); | 27 | fprintf(stderr, "\n"); |
| 28 | for (int i = 0; i < 8; i++) | 28 | for (int i = 0; i < 8; i++) |
| 29 | fprintf(stderr, "%d ", cube.corner[i]); | 29 | fprintf(stderr, "%d ", corner[i]); |
| 30 | fprintf(stderr, "\n"); | 30 | fprintf(stderr, "\n"); |
| 31 | printf("Setting EO resulted in inconsistent cube\n"); | 31 | printf("Setting EO resulted in inconsistent cube\n"); |
| 32 | } else { | 32 | } else { |
diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c index fe59089..446a849 100644 --- a/test/076_copy_corners/copy_corners_tests.c +++ b/test/076_copy_corners/copy_corners_tests.c | |||
| @@ -1,23 +1,19 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void copy_corners_fast(cube_fast_t *, cube_fast_t); | 3 | void copy_corners(cube_t *, cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | int main(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2; | 7 | cube_t c1, c2; |
| 8 | cube_fast_t f1, f2; | ||
| 9 | 8 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 9 | fgets(str, STRLENMAX, stdin); |
| 11 | c1 = readcube("H48", str); | 10 | c1 = readcube("H48", str); |
| 12 | f1 = cubetofast(c1); | ||
| 13 | 11 | ||
| 14 | fgets(str, STRLENMAX, stdin); | 12 | fgets(str, STRLENMAX, stdin); |
| 15 | c2 = readcube("H48", str); | 13 | c2 = readcube("H48", str); |
| 16 | f2 = cubetofast(c2); | ||
| 17 | 14 | ||
| 18 | copy_corners_fast(&f1, f2); | 15 | copy_corners(&c1, c2); |
| 19 | 16 | ||
| 20 | c1 = fasttocube(f1); | ||
| 21 | if (iserror(c1)) { | 17 | if (iserror(c1)) { |
| 22 | printf("Error setting EO\n"); | 18 | printf("Error setting EO\n"); |
| 23 | } else if (!isconsistent(c1)) { | 19 | } else if (!isconsistent(c1)) { |
diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c index b428f89..9afcb73 100644 --- a/test/077_copy_edges/copy_edges_tests.c +++ b/test/077_copy_edges/copy_edges_tests.c | |||
| @@ -1,23 +1,19 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void copy_edges_fast(cube_fast_t *, cube_fast_t); | 3 | void copy_edges(cube_t *, cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | int main(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2; | 7 | cube_t c1, c2; |
| 8 | cube_fast_t f1, f2; | ||
| 9 | 8 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 9 | fgets(str, STRLENMAX, stdin); |
| 11 | c1 = readcube("H48", str); | 10 | c1 = readcube("H48", str); |
| 12 | f1 = cubetofast(c1); | ||
| 13 | 11 | ||
| 14 | fgets(str, STRLENMAX, stdin); | 12 | fgets(str, STRLENMAX, stdin); |
| 15 | c2 = readcube("H48", str); | 13 | c2 = readcube("H48", str); |
| 16 | f2 = cubetofast(c2); | ||
| 17 | 14 | ||
| 18 | copy_edges_fast(&f1, f2); | 15 | copy_edges(&c1, c2); |
| 19 | 16 | ||
| 20 | c1 = fasttocube(f1); | ||
| 21 | if (iserror(c1)) { | 17 | if (iserror(c1)) { |
| 22 | printf("Error setting EO\n"); | 18 | printf("Error setting EO\n"); |
| 23 | } else if (!isconsistent(c1)) { | 19 | } else if (!isconsistent(c1)) { |
diff --git a/test/078_invcoord_esep/invcoord_esep_tests.c b/test/078_invcoord_esep/invcoord_esep_tests.c index 17ea2ff..0b83175 100644 --- a/test/078_invcoord_esep/invcoord_esep_tests.c +++ b/test/078_invcoord_esep/invcoord_esep_tests.c | |||
| @@ -1,21 +1,19 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int64_t coord_fast_esep(cube_fast_t); | 3 | int64_t coord_esep(cube_t); |
| 4 | cube_fast_t invcoord_fast_esep(int64_t); | 4 | cube_t invcoord_esep(int64_t); |
| 5 | 5 | ||
| 6 | int main(void) { | 6 | int main(void) { |
| 7 | char str[STRLENMAX]; | 7 | char str[STRLENMAX]; |
| 8 | cube_t cube; | 8 | cube_t cube; |
| 9 | cube_fast_t fast; | ||
| 10 | int64_t i; | 9 | int64_t i; |
| 11 | 10 | ||
| 12 | fgets(str, STRLENMAX, stdin); | 11 | fgets(str, STRLENMAX, stdin); |
| 13 | cube = readcube("H48", str); | 12 | cube = readcube("H48", str); |
| 14 | fast = cubetofast(cube); | ||
| 15 | 13 | ||
| 16 | i = coord_fast_esep(fast); | 14 | i = coord_esep(cube); |
| 17 | fast = invcoord_fast_esep(i); | 15 | cube = invcoord_esep(i); |
| 18 | i = coord_fast_esep(fast); | 16 | i = coord_esep(cube); |
| 19 | 17 | ||
| 20 | printf("%" PRId64 "\n", i); | 18 | printf("%" PRId64 "\n", i); |
| 21 | 19 | ||
diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c index bba261b..9d8f03c 100644 --- a/test/100_gendata_cocsep/gendata_cocsep_tests.c +++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c | |||
| @@ -2,12 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | 3 | #define COCSEP_CLASSES 3393 |
| 4 | 4 | ||
| 5 | size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 6 | 6 | ||
| 7 | int main(void) { | 7 | int main(void) { |
| 8 | uint32_t buf[300000], i; | 8 | uint32_t buf[300000], i; |
| 9 | uint64_t selfsim[COCSEP_CLASSES]; | 9 | uint64_t selfsim[COCSEP_CLASSES]; |
| 10 | cube_fast_t rep[COCSEP_CLASSES]; | 10 | cube_t rep[COCSEP_CLASSES]; |
| 11 | size_t result; | 11 | size_t result; |
| 12 | 12 | ||
| 13 | result = gendata_cocsep(buf, selfsim, rep); | 13 | result = gendata_cocsep(buf, selfsim, rep); |
diff --git a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c index 02b5377..195f9ba 100644 --- a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c +++ b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c | |||
| @@ -9,23 +9,23 @@ | |||
| 9 | 9 | ||
| 10 | #define COCSEP_CLASSES 3393 | 10 | #define COCSEP_CLASSES 3393 |
| 11 | 11 | ||
| 12 | size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | 12 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 13 | int64_t coord_fast_cocsep(cube_fast_t); | 13 | int64_t coord_cocsep(cube_t); |
| 14 | 14 | ||
| 15 | int main(void) { | 15 | int main(void) { |
| 16 | char str[STRLENMAX]; | 16 | char str[STRLENMAX]; |
| 17 | uint32_t buf[300000], data; | 17 | uint32_t buf[300000], data; |
| 18 | int64_t coord, coclass; | 18 | int64_t coord, coclass; |
| 19 | uint64_t selfsim[COCSEP_CLASSES], sim, t; | 19 | uint64_t selfsim[COCSEP_CLASSES], sim, t; |
| 20 | cube_fast_t fast, rep[COCSEP_CLASSES]; | 20 | cube_t cube, rep[COCSEP_CLASSES]; |
| 21 | 21 | ||
| 22 | gendata_cocsep(buf, selfsim, rep); | 22 | gendata_cocsep(buf, selfsim, rep); |
| 23 | 23 | ||
| 24 | /* All cases in the same test so we do not generate data many times */ | 24 | /* All cases in the same test so we do not generate data many times */ |
| 25 | 25 | ||
| 26 | while (fgets(str, STRLENMAX, stdin) != NULL) { | 26 | while (fgets(str, STRLENMAX, stdin) != NULL) { |
| 27 | fast = cubetofast(readcube("H48", str)); | 27 | cube = readcube("H48", str); |
| 28 | coord = coord_fast_cocsep(fast); | 28 | coord = coord_cocsep(cube); |
| 29 | data = buf[coord]; | 29 | data = buf[coord]; |
| 30 | coclass = (data & (0xFFFU << 16)) >> 16; | 30 | coclass = (data & (0xFFFU << 16)) >> 16; |
| 31 | sim = selfsim[coclass]; | 31 | sim = selfsim[coclass]; |
diff --git a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c index 5022608..b0668df 100644 --- a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c +++ b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c | |||
| @@ -2,10 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | 3 | #define COCSEP_CLASSES 3393 |
| 4 | 4 | ||
| 5 | size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 6 | int64_t coord_h48(cube_fast_t, const uint32_t *, uint8_t); | 6 | int64_t coord_h48(cube_t, const uint32_t *, uint8_t); |
| 7 | cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); | 7 | cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); |
| 8 | cube_fast_t transform(cube_fast_t, uint8_t); | 8 | cube_t transform(cube_t, uint8_t); |
| 9 | 9 | ||
| 10 | int main(void) { | 10 | int main(void) { |
| 11 | char str[STRLENMAX]; | 11 | char str[STRLENMAX]; |
| @@ -15,8 +15,7 @@ int main(void) { | |||
| 15 | uint32_t cocsepdata[300000]; | 15 | uint32_t cocsepdata[300000]; |
| 16 | uint64_t selfsim[COCSEP_CLASSES]; | 16 | uint64_t selfsim[COCSEP_CLASSES]; |
| 17 | int64_t c, cc; | 17 | int64_t c, cc; |
| 18 | cube_t cube; | 18 | cube_t cube, invc, rep[COCSEP_CLASSES]; |
| 19 | cube_fast_t fast, invc, rep[COCSEP_CLASSES]; | ||
| 20 | 19 | ||
| 21 | gendata_cocsep(cocsepdata, selfsim, rep); | 20 | gendata_cocsep(cocsepdata, selfsim, rep); |
| 22 | 21 | ||
| @@ -24,12 +23,11 @@ int main(void) { | |||
| 24 | h = 11; | 23 | h = 11; |
| 25 | while (fgets(str, STRLENMAX, stdin) != NULL) { | 24 | while (fgets(str, STRLENMAX, stdin) != NULL) { |
| 26 | cube = readcube("H48", str); | 25 | cube = readcube("H48", str); |
| 27 | fast = cubetofast(cube); | 26 | c = coord_h48(cube, cocsepdata, h); |
| 28 | c = coord_h48(fast, cocsepdata, h); | ||
| 29 | invc = invcoord_h48(c, rep, h); | 27 | invc = invcoord_h48(c, rep, h); |
| 30 | for (t = 0, found = false; t < 48; t++) { | 28 | for (t = 0, found = false; t < 48; t++) { |
| 31 | fast = transform(invc, t); | 29 | cube = transform(invc, t); |
| 32 | cc = coord_h48(fast, cocsepdata, h); | 30 | cc = coord_h48(cube, cocsepdata, h); |
| 33 | found = found || cc == c; | 31 | found = found || cc == c; |
| 34 | } | 32 | } |
| 35 | printf("%d %s\n", i, found ? "ok" : "ERROR"); | 33 | printf("%d %s\n", i, found ? "ok" : "ERROR"); |
diff --git a/test/test.h b/test/test.h index ab40bde..1bbb9fc 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -6,16 +6,14 @@ | |||
| 6 | 6 | ||
| 7 | #define STRLENMAX 10000 | 7 | #define STRLENMAX 10000 |
| 8 | 8 | ||
| 9 | #ifdef CUBE_AVX2 | ||
| 10 | #include <immintrin.h> | ||
| 11 | typedef __m256i cube_t; | ||
| 12 | #else | ||
| 9 | typedef struct { | 13 | typedef struct { |
| 10 | uint8_t corner[8]; | 14 | uint8_t corner[8]; |
| 11 | uint8_t edge[12]; | 15 | uint8_t edge[12]; |
| 12 | } cube_t; | 16 | } cube_t; |
| 13 | |||
| 14 | #ifdef CUBE_AVX2 | ||
| 15 | #include <immintrin.h> | ||
| 16 | typedef __m256i cube_fast_t; | ||
| 17 | #else | ||
| 18 | typedef cube_t cube_fast_t; | ||
| 19 | #endif | 17 | #endif |
| 20 | 18 | ||
| 21 | /* Basic functions used in most tests */ | 19 | /* Basic functions used in most tests */ |
| @@ -26,5 +24,3 @@ bool issolvable(cube_t); | |||
| 26 | bool issolved(cube_t); | 24 | bool issolved(cube_t); |
| 27 | cube_t readcube(char *, char *); | 25 | cube_t readcube(char *, char *); |
| 28 | void writecube(char *, cube_t, char *); | 26 | void writecube(char *, cube_t, char *); |
| 29 | cube_t fasttocube(cube_fast_t); | ||
| 30 | cube_fast_t cubetofast(cube_t); | ||
