Revision 754f7231
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/solvers/SolverSkewbDiamond.java | ||
---|---|---|
86 | 86 |
return perm; |
87 | 87 |
} |
88 | 88 |
|
89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
90 |
|
|
91 |
private int computeCornerTwist(int[] corner, int color ) |
|
92 |
{ |
|
93 |
if( corner[3]==color ) return 0; |
|
94 |
if( corner[2]==color ) return 1; |
|
95 |
if( corner[1]==color ) return 2; |
|
96 |
if( corner[0]==color ) return 3; |
|
97 |
|
|
98 |
return -1; |
|
99 |
} |
|
100 |
|
|
89 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
90 | 102 |
|
91 | 103 |
private int[] getCornersTwist(int[] corners_perm, int[][] corners) |
92 | 104 |
{ |
93 | 105 |
int[] twist = new int[6]; |
94 | 106 |
|
95 |
twist[0] = retCornerTwist(corners[corners_perm[0]], mFaceColors[1],mFaceColors[4]);
|
|
96 |
twist[1] = retCornerTwist(corners[corners_perm[1]], mFaceColors[1],mFaceColors[6]);
|
|
97 |
twist[2] = retCornerTwist(corners[corners_perm[2]], mFaceColors[3],mFaceColors[6]);
|
|
98 |
twist[3] = retCornerTwist(corners[corners_perm[3]], mFaceColors[3],mFaceColors[4]);
|
|
99 |
twist[4] = retCornerTwist(corners[corners_perm[4]], mFaceColors[1],mFaceColors[3]);
|
|
100 |
twist[5] = retCornerTwist(corners[corners_perm[5]], mFaceColors[4],mFaceColors[6]);
|
|
107 |
twist[0] = computeCornerTwist( corners[corners_perm[0]], mFaceColors[1] );
|
|
108 |
twist[1] = computeCornerTwist( corners[corners_perm[1]], mFaceColors[1] );
|
|
109 |
twist[2] = computeCornerTwist( corners[corners_perm[2]], mFaceColors[3] );
|
|
110 |
twist[3] = computeCornerTwist( corners[corners_perm[3]], mFaceColors[3] );
|
|
111 |
twist[4] = computeCornerTwist( corners[corners_perm[4]], mFaceColors[1] );
|
|
112 |
twist[5] = computeCornerTwist( corners[corners_perm[5]], mFaceColors[4] );
|
|
101 | 113 |
|
102 | 114 |
return twist; |
103 | 115 |
} |
... | ... | |
134 | 146 |
{ |
135 | 147 |
int t= twist[i]; |
136 | 148 |
if( t==1 || t==3 ) return -1; |
137 |
|
|
138 |
if( i<5 ) |
|
139 |
{ |
|
140 |
if( t==2 ) total++; |
|
141 |
total *= 2; |
|
142 |
} |
|
149 |
if( i<5 && t==2 ) total+=(1<<i); |
|
143 | 150 |
} |
144 | 151 |
|
145 | 152 |
return total; |
... | ... | |
335 | 342 |
getCorners(object,corners); |
336 | 343 |
getCenters(object,centers); |
337 | 344 |
|
338 |
//for(int j=0; j<8; j++) android.util.Log.e("D", "center "+j+" : "+centers[j]); |
|
339 |
|
|
340 | 345 |
int result1 = checkAllCentersPresent(centers); |
341 | 346 |
if( result1<0 ) return result1; |
342 | 347 |
|
... | ... | |
485 | 490 |
{ |
486 | 491 |
if( mSolver==null ) |
487 | 492 |
{ |
488 |
mSolver = ImplementedTablebasesList.createPacked(res,ObjectType.DIAM_2); |
|
493 |
//mSolver = ImplementedTablebasesList.createPacked(res,ObjectType.DIAM_2); |
|
494 |
|
|
495 |
mSolver = ImplementedTablebasesList.createUnpacked(ObjectType.DIAM_2); |
|
496 |
if( mSolver!=null ) mSolver.createTablebase(); |
|
489 | 497 |
} |
490 | 498 |
|
491 | 499 |
return mSolver!=null ? mSolver.solution(index) : null; |
492 |
|
|
493 |
/* |
|
494 |
|
|
495 |
TablebasesSkewbDiamond tb = new TablebasesSkewbDiamond(); |
|
496 |
int[] q = {0,0,3,3,3,0, 3,0,2,0,0,0,0,3}; |
|
497 |
int i= tb.getIndex(q); |
|
498 |
android.util.Log.e("D", "AAAA index="+i); |
|
499 |
int[] a = tb.getQuats(i); |
|
500 |
android.util.Log.e("D", "AAAA quats="+a[0]+" "+a[1]+" "+a[2]+" "+a[3]+" "+a[4]+" "+a[5]+" "+ |
|
501 |
a[6]+" "+a[7]+" "+a[8]+" "+a[9]+" "+a[10]+" "+a[11]+" "+a[12]+" "+a[13]); |
|
502 |
int j= tb.getIndex(a); |
|
503 |
android.util.Log.e("D", "AAAA index="+j); |
|
504 |
|
|
505 |
return null; |
|
506 |
|
|
507 |
*/ |
|
508 | 500 |
} |
509 | 501 |
} |
510 | 502 |
|
Also available in: Unified diff
Diamond Skewb solver should be fully working now.