Revision bfac9e97
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/solvers/SolverCuboid323.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import android.content.res.Resources; |
| 13 | 13 |
|
| 14 |
import org.distorted.library.type.Static3D; |
|
| 15 |
import org.distorted.library.type.Static4D; |
|
| 14 | 16 |
import org.distorted.main.R; |
| 15 | 17 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 18 |
import org.distorted.objectlib.helpers.QuatGroupGenerator; |
|
| 16 | 19 |
import org.distorted.objectlib.main.ObjectSignatures; |
| 17 | 20 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 | 21 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
| ... | ... | |
| 33 | 36 |
TablebasesAbstract mSolver; |
| 34 | 37 |
private final int[] mFaceColors; |
| 35 | 38 |
private int mErrorColor1, mErrorColor2, mErrorColor3; |
| 39 |
private Static4D[] mQuats; |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 42 |
|
|
| 43 |
private void initializeQuats() |
|
| 44 |
{
|
|
| 45 |
int[] tmp2 = {2,2,2};
|
|
| 46 |
int[] tmp4 = {4,4};
|
|
| 47 |
int[][] angles = new int[][] { tmp2,tmp4,tmp2 };
|
|
| 48 |
Static3D[] axis = new Static3D[] { new Static3D(1,0,0), new Static3D(0,1,0), new Static3D(0,0,1) };
|
|
| 49 |
mQuats = QuatGroupGenerator.computeGroup(axis,angles); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
|
|
| 54 |
private int mulQuat(int q1, int q2) |
|
| 55 |
{
|
|
| 56 |
if( mQuats==null ) initializeQuats(); |
|
| 57 |
return TablebasesAbstract.mulQuat(q1,q2,mQuats); |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
private void rotatePermutations(int[] corner, int[] edge8, int quat) |
|
| 63 |
{
|
|
| 64 |
int[] quats = TBCuboid323.quatsFromPermutations(corner,edge8); |
|
| 65 |
int num = quats.length; |
|
| 66 |
|
|
| 67 |
for( int i=0; i<num; i++ ) quats[i] = mulQuat(quat,quats[i]); |
|
| 68 |
|
|
| 69 |
TBCuboid323.cornerFromQuats(corner,quats); |
|
| 70 |
TBCuboid323.edgeFromQuats(edge8,quats); |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 74 |
// when we input the position, edge1 can be anywhere. We need to rotate the permutations so that |
|
| 75 |
// edge1 is always in the front (i.e. so that edge[1] is 1 or 3) |
|
| 76 |
|
|
| 77 |
private void normalizePermutations(int[] corner, int[] edge8) |
|
| 78 |
{
|
|
| 79 |
switch(edge8[1]) |
|
| 80 |
{
|
|
| 81 |
case 0: case 2: rotatePermutations(corner,edge8,3); |
|
| 82 |
break; |
|
| 83 |
case 4: case 5: rotatePermutations(corner,edge8,4); |
|
| 84 |
break; |
|
| 85 |
case 6: case 7: rotatePermutations(corner,edge8,2); |
|
| 86 |
break; |
|
| 87 |
} |
|
| 88 |
} |
|
| 36 | 89 |
|
| 37 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 | 91 |
|
| ... | ... | |
| 287 | 340 |
//android.util.Log.e("D", "upper: "+mUpper);
|
| 288 | 341 |
for(int i=0; i<6; i++) android.util.Log.e("D", "face color: "+mFaceColors[i]);
|
| 289 | 342 |
|
| 290 |
int[] edge_perm = new int[8]; |
|
| 291 |
int result2 = retEdgePermutation(edge_perm,edges); |
|
| 343 |
int[] edge_perm8 = new int[8];
|
|
| 344 |
int result2 = retEdgePermutation(edge_perm8,edges);
|
|
| 292 | 345 |
if( result2<0 ) return result2; |
| 293 | 346 |
|
| 294 | 347 |
TablebaseHelpers.displayTable(corner_perm, "CORNER PERM"); |
| 295 |
TablebaseHelpers.displayTable(edge_perm, "EDGE PERM8"); |
|
| 348 |
TablebaseHelpers.displayTable(edge_perm8, "EDGE PERM8"); |
|
| 349 |
|
|
| 350 |
normalizePermutations(corner_perm,edge_perm8); |
|
| 296 | 351 |
|
| 297 |
int[] edge_perm2 = TBCuboid323.edgePermTo7(edge_perm);
|
|
| 352 |
int[] edge_perm7 = TBCuboid323.edgePermTo7(edge_perm8);
|
|
| 298 | 353 |
|
| 299 |
TablebaseHelpers.displayTable(edge_perm2, "EDGE PERM7");
|
|
| 354 |
TablebaseHelpers.displayTable(edge_perm7, "EDGE PERM7");
|
|
| 300 | 355 |
|
| 301 | 356 |
int corner_perm_num = TablebaseHelpers.computePermutationNum(corner_perm); |
| 302 |
int edge_perm_num = TablebaseHelpers.computePermutationNum(edge_perm2);
|
|
| 357 |
int edge_perm_num = TablebaseHelpers.computePermutationNum(edge_perm7);
|
|
| 303 | 358 |
boolean inPlace = isFrontEdgeInItsPlace(edges); |
| 304 | 359 |
|
| 305 | 360 |
android.util.Log.e("D", "corner_perm_num: "+corner_perm_num+" edge_perm_num: "+edge_perm_num+" inPlace: "+inPlace);
|
Also available in: Unified diff
CU_323 solver: corrections.