diff options
Diffstat (limited to 'old/maybe-useful-coord.c')
| -rw-r--r-- | old/maybe-useful-coord.c | 181 |
1 files changed, 0 insertions, 181 deletions
diff --git a/old/maybe-useful-coord.c b/old/maybe-useful-coord.c deleted file mode 100644 index 9ab2971..0000000 --- a/old/maybe-useful-coord.c +++ /dev/null | |||
| @@ -1,181 +0,0 @@ | |||
| 1 | int | ||
| 2 | array_ep_to_epos(int *ep, int *ss) | ||
| 3 | { | ||
| 4 | int epos[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
| 5 | int eps[4]; | ||
| 6 | int i, j, is; | ||
| 7 | |||
| 8 | for (i = 0, is = 0; i < 12; i++) { | ||
| 9 | for (j = 0; j < 4; j++) { | ||
| 10 | if (ep[i] == ss[j]) { | ||
| 11 | eps[is++] = j; | ||
| 12 | epos[i] = 1; | ||
| 13 | } | ||
| 14 | } | ||
| 15 | } | ||
| 16 | |||
| 17 | for (i = 0; i < 4; i++) | ||
| 18 | swap(&epos[ss[i]], &epos[i+8]); | ||
| 19 | |||
| 20 | return 24 * subset_to_index(epos, 12, 4) + perm_to_index(eps, 4); | ||
| 21 | } | ||
| 22 | |||
| 23 | void | ||
| 24 | epos_to_compatible_ep(int epos, int *ep, int *ss) | ||
| 25 | { | ||
| 26 | int i, j, k, other[8]; | ||
| 27 | bool flag; | ||
| 28 | |||
| 29 | for (i = 0; i < 12; i++) | ||
| 30 | ep[i] = -1; | ||
| 31 | |||
| 32 | epos_to_partial_ep(epos, ep, ss); | ||
| 33 | |||
| 34 | for (i = 0, j = 0; i < 12; i++) { | ||
| 35 | flag = false; | ||
| 36 | for (k = 0; k < 4; k++) | ||
| 37 | flag = flag || (i == ss[k]); | ||
| 38 | if (!flag) | ||
| 39 | other[j++] = i; | ||
| 40 | } | ||
| 41 | |||
| 42 | for (i = 0, j = 0; i < 12; i++) | ||
| 43 | if (ep[i] == -1) | ||
| 44 | ep[i] = other[j++]; | ||
| 45 | } | ||
| 46 | |||
| 47 | void | ||
| 48 | epos_to_partial_ep(int epos, int *ep, int *ss) | ||
| 49 | { | ||
| 50 | int i, is, eposs[12], eps[4]; | ||
| 51 | |||
| 52 | index_to_perm(epos % FACTORIAL4, 4, eps); | ||
| 53 | index_to_subset(epos / FACTORIAL4, 12, 4, eposs); | ||
| 54 | |||
| 55 | for (i = 0; i < 4; i++) | ||
| 56 | swap(&eposs[ss[i]], &eposs[i+8]); | ||
| 57 | |||
| 58 | for (i = 0, is = 0; i < 12; i++) | ||
| 59 | if (eposs[i]) | ||
| 60 | ep[i] = ss[eps[is++]]; | ||
| 61 | } | ||
| 62 | |||
| 63 | void | ||
| 64 | fix_eorleoud(CubeArray *arr) | ||
| 65 | { | ||
| 66 | int i; | ||
| 67 | |||
| 68 | for (i = 0; i < 12; i++) { | ||
| 69 | if ((edge_slice(i) == 0 && edge_slice(arr->ep[i]) != 0) || | ||
| 70 | (edge_slice(i) != 0 && edge_slice(arr->ep[i]) == 0)) { | ||
| 71 | arr->eorl[i] = 1 - arr->eofb[i]; | ||
| 72 | } else { | ||
| 73 | arr->eorl[i] = arr->eofb[i]; | ||
| 74 | } | ||
| 75 | |||
| 76 | if ((edge_slice(i) == 2 && edge_slice(arr->ep[i]) != 2) || | ||
| 77 | (edge_slice(i) != 2 && edge_slice(arr->ep[i]) == 2)) { | ||
| 78 | arr->eoud[i] = 1 - arr->eofb[i]; | ||
| 79 | } else { | ||
| 80 | arr->eoud[i] = arr->eofb[i]; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | void | ||
| 86 | fix_cofbcorl(CubeArray *arr) | ||
| 87 | { | ||
| 88 | int i; | ||
| 89 | |||
| 90 | for (i = 0; i < 8; i++) { | ||
| 91 | if (i % 2 == arr->cp[i] % 2) { | ||
| 92 | arr->cofb[i] = arr->coud[i]; | ||
| 93 | arr->corl[i] = arr->coud[i]; | ||
| 94 | } else { | ||
| 95 | if (arr->cp[i] % 2 == 0) { | ||
| 96 | arr->cofb[i] = (arr->coud[i]+1)%3; | ||
| 97 | arr->corl[i] = (arr->coud[i]+2)%3; | ||
| 98 | } else { | ||
| 99 | arr->cofb[i] = (arr->coud[i]+2)%3; | ||
| 100 | arr->corl[i] = (arr->coud[i]+1)%3; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | Cube | ||
| 107 | admissible_ep(Cube cube, PieceFilter f) | ||
| 108 | { | ||
| 109 | CubeArray *arr = new_cubearray(cube, f); | ||
| 110 | Cube ret; | ||
| 111 | bool used[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
| 112 | int i, j; | ||
| 113 | |||
| 114 | for (i = 0; i < 12; i++) | ||
| 115 | if (arr->ep[i] != -1) | ||
| 116 | used[arr->ep[i]] = true; | ||
| 117 | |||
| 118 | for (i = 0, j = 0; i < 12; i++) { | ||
| 119 | for ( ; j < 11 && used[j]; j++); | ||
| 120 | if (arr->ep[i] == -1) | ||
| 121 | arr->ep[i] = j++; | ||
| 122 | } | ||
| 123 | |||
| 124 | ret = arrays_to_cube(arr, pf_ep); | ||
| 125 | free_cubearray(arr, f); | ||
| 126 | |||
| 127 | return ret; | ||
| 128 | } | ||
| 129 | |||
| 130 | int | ||
| 131 | edge_slice(Edge e) { | ||
| 132 | if (e < 0 || e > 11) | ||
| 133 | return -1; | ||
| 134 | |||
| 135 | if (e == FR || e == FL || e == BL || e == BR) | ||
| 136 | return 0; | ||
| 137 | if (e == UR || e == UL || e == DR || e == DL) | ||
| 138 | return 1; | ||
| 139 | |||
| 140 | return 2; | ||
| 141 | } | ||
| 142 | |||
| 143 | int | ||
| 144 | piece_orientation(Cube cube, int piece, char *orientation) | ||
| 145 | { | ||
| 146 | int arr[12], n, b, x; | ||
| 147 | |||
| 148 | if (!strcmp(orientation, "eofb")) { | ||
| 149 | x = cube.eofb; | ||
| 150 | n = 12; | ||
| 151 | b = 2; | ||
| 152 | } else if (!strcmp(orientation, "eorl")) { | ||
| 153 | x = cube.eorl; | ||
| 154 | n = 12; | ||
| 155 | b = 2; | ||
| 156 | } else if (!strcmp(orientation, "eoud")) { | ||
| 157 | x = cube.eoud; | ||
| 158 | n = 12; | ||
| 159 | b = 2; | ||
| 160 | } else if (!strcmp(orientation, "coud")) { | ||
| 161 | x = cube.coud; | ||
| 162 | n = 8; | ||
| 163 | b = 3; | ||
| 164 | } else if (!strcmp(orientation, "corl")) { | ||
| 165 | x = cube.corl; | ||
| 166 | n = 8; | ||
| 167 | b = 3; | ||
| 168 | } else if (!strcmp(orientation, "cofb")) { | ||
| 169 | x = cube.cofb; | ||
| 170 | n = 8; | ||
| 171 | b = 3; | ||
| 172 | } else { | ||
| 173 | return -1; | ||
| 174 | } | ||
| 175 | |||
| 176 | int_to_sum_zero_array(x, b, n, arr); | ||
| 177 | if (piece < n) | ||
| 178 | return arr[piece]; | ||
| 179 | |||
| 180 | return -1; | ||
| 181 | } | ||
