20 |
20 |
|
21 |
21 |
public class TBSkewb extends TablebasesAbstract
|
22 |
22 |
{
|
|
23 |
public static final int[] FIXED= {0,3,5,6};
|
|
24 |
public static final int[] FREE = {1,2,4,7};
|
|
25 |
|
23 |
26 |
private static final int[][] freeIndex = { {1,3,2},{0,2,3},{3,1,0},{2,0,1} };
|
24 |
27 |
|
25 |
28 |
private static final int[][][] centerQuats =
|
... | ... | |
142 |
145 |
return 9;
|
143 |
146 |
}
|
144 |
147 |
|
145 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146 |
|
|
147 |
|
public static void fillInQuats(int[] output, int[] perm, int[] twist)
|
148 |
|
{
|
149 |
|
output[0] = fixedQuats[0][twist[0]];
|
150 |
|
output[1] = freeQuats[0][perm[0]][twist[1]];
|
151 |
|
output[2] = freeQuats[1][perm[1]][twist[2]];
|
152 |
|
output[3] = fixedQuats[1][twist[3]];
|
153 |
|
output[4] = freeQuats[2][perm[2]][twist[3]];
|
154 |
|
output[5] = fixedQuats[2][twist[5]];
|
155 |
|
output[6] = fixedQuats[3][twist[6]];
|
156 |
|
output[7] = freeQuats[3][perm[3]][twist[7]];
|
157 |
|
}
|
158 |
|
|
159 |
148 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160 |
149 |
|
161 |
150 |
public static int computeLocation(int index, int quat)
|
... | ... | |
212 |
201 |
|
213 |
202 |
public static void computeCornerTwists(int[] twists, int[] quats)
|
214 |
203 |
{
|
215 |
|
twists[0] = retFixed(0,quats[0]);
|
216 |
|
twists[3] = retFixed(1,quats[3]);
|
217 |
|
twists[5] = retFixed(2,quats[5]);
|
218 |
|
twists[6] = retFixed(3,quats[6]);
|
219 |
|
|
220 |
|
twists[1] = retFree(0,quats[1]);
|
221 |
|
twists[2] = retFree(1,quats[2]);
|
222 |
|
twists[4] = retFree(2,quats[4]);
|
223 |
|
twists[7] = retFree(3,quats[7]);
|
|
204 |
for(int i=0; i<4; i++) twists[FIXED[i]] = retFixed(i,quats[FIXED[i]]);
|
|
205 |
for(int i=0; i<4; i++) twists[FREE[i]] = retFree(i,quats[FREE[i]]);
|
|
206 |
}
|
|
207 |
|
|
208 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
209 |
|
|
210 |
public static void fillInQuats(int[] quats, int[] perm, int[] twist)
|
|
211 |
{
|
|
212 |
for(int i=0; i<4; i++)
|
|
213 |
{
|
|
214 |
int fixed = FIXED[i];
|
|
215 |
int free = FREE[i];
|
|
216 |
int twFi = twist[fixed];
|
|
217 |
int twFr = twist[free];
|
|
218 |
int pe = perm[i];
|
|
219 |
|
|
220 |
quats[fixed] = fixedQuats[i][twFi];
|
|
221 |
quats[free ] = freeQuats[i][pe][twFr];
|
|
222 |
}
|
224 |
223 |
}
|
225 |
224 |
|
226 |
225 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
250 |
249 |
|
251 |
250 |
private void fillCenterQuats(int[] quats, int[] perm)
|
252 |
251 |
{
|
253 |
|
for(int i=0; i<6; i++)
|
254 |
|
{
|
255 |
|
quats[8+i] = centerQuats[i][perm[i]][0];
|
256 |
|
}
|
|
252 |
for(int i=0; i<6; i++) quats[8+i] = centerQuats[i][perm[i]][0];
|
257 |
253 |
}
|
258 |
254 |
|
259 |
255 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
280 |
276 |
|
281 |
277 |
public int[] getQuats(int index)
|
282 |
278 |
{
|
283 |
|
int[] locationFree = new int[4];
|
|
279 |
int[] permFree = new int[4];
|
284 |
280 |
int center_perm_num = (index%360);
|
285 |
281 |
index /= 360;
|
286 |
282 |
int totalTwist = (index%2187);
|
287 |
|
locationFree[0] = (index/2187);
|
|
283 |
permFree[0] = (index/2187);
|
288 |
284 |
|
289 |
285 |
int[] quats = new int[14];
|
290 |
286 |
int[] center_perm = new int[6];
|
... | ... | |
299 |
295 |
totalTwist /= 3;
|
300 |
296 |
}
|
301 |
297 |
|
302 |
|
int total = twist[1]+twist[2]+twist[4];
|
|
298 |
int total = twist[FREE[0]]+twist[FREE[1]]+twist[FREE[2]];
|
303 |
299 |
twist[7] = ((6-total)%3);
|
304 |
|
|
305 |
|
int sumFixedTwists = ((twist[0]+twist[3]+twist[5]+twist[6])%3);
|
306 |
|
locationFree[1] = freeIndex[locationFree[0]][sumFixedTwists];
|
307 |
|
fillUpToEvenPerm(locationFree);
|
308 |
|
|
309 |
|
quats[0] = fixedQuats[0][twist[0]];
|
310 |
|
quats[3] = fixedQuats[1][twist[3]];
|
311 |
|
quats[5] = fixedQuats[2][twist[5]];
|
312 |
|
quats[6] = fixedQuats[3][twist[6]];
|
313 |
|
|
314 |
|
quats[1] = freeQuats[0][locationFree[0]][twist[1]];
|
315 |
|
quats[2] = freeQuats[1][locationFree[1]][twist[2]];
|
316 |
|
quats[4] = freeQuats[2][locationFree[2]][twist[4]];
|
317 |
|
quats[7] = freeQuats[3][locationFree[3]][twist[7]];
|
318 |
|
|
319 |
|
//android.util.Log.e("D", "QUATS center_perm: "+center_perm_num+" totalTwist="+totalTwist+" locationOfFree0="+locationOfFree0);
|
320 |
|
//android.util.Log.e("D", "QUATS t0="+twist[0]+" t1="+twist[1]+" t2="+twist[2]+" t3="+twist[3]+" t4="+twist[4]+" t5="+twist[5]+" t6="+twist[6]+" t7="+twist[7]);
|
|
300 |
int sumFixedTwists = twist[FIXED[0]]+twist[FIXED[1]]+twist[FIXED[2]]+twist[FIXED[3]];
|
|
301 |
permFree[1] = freeIndex[permFree[0]][sumFixedTwists%3];
|
|
302 |
fillUpToEvenPerm(permFree);
|
|
303 |
fillInQuats(quats,permFree,twist);
|
321 |
304 |
|
322 |
305 |
return quats;
|
323 |
306 |
}
|
... | ... | |
333 |
316 |
int totalTwist = twist[0]+ 3*(twist[1]+ 3*(twist[2]+ 3*(twist[3]+ 3*(twist[4]+ 3*(twist[5]+ 3*twist[6])))));
|
334 |
317 |
int locationOfFree0 = computeLocation(0,quats[1]);
|
335 |
318 |
|
336 |
|
//android.util.Log.e("D", "INDEX center_perm: "+center_perm_num+" totalTwist="+totalTwist+" locationOfFree0="+locationOfFree0);
|
337 |
|
//android.util.Log.e("D", "INDEX t0="+twist[0]+" t1="+twist[1]+" t2="+twist[2]+" t3="+twist[3]+" t4="+twist[4]+" t5="+twist[5]+" t6="+twist[6]+" t7="+twist[7]);
|
338 |
|
|
339 |
319 |
return center_perm_num+ 360*(totalTwist + 2187*locationOfFree0);
|
340 |
320 |
}
|
341 |
321 |
}
|
Skewb solver: full TB version works now.