Revision 6f1dbce1
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/solvers/SolverCube2.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
private void fillCornerTwists(int[] output, int[][] corners, int[] perm) |
42 | 42 |
{ |
43 |
// TODO |
|
43 |
for(int i=0; i<8; i++) |
|
44 |
{ |
|
45 |
int[] c = corners[perm[i]]; |
|
46 |
|
|
47 |
if( c[0]==mFaceColors[0] || c[0]==mFaceColors[1] ) output[i] = 0; |
|
48 |
else if( c[1]==mFaceColors[0] || c[1]==mFaceColors[1] ) output[i] = 1; |
|
49 |
else output[i] = 2; |
|
50 |
} |
|
44 | 51 |
} |
45 | 52 |
|
46 | 53 |
//////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
78 | 85 |
output[6] = cornerIndex(corners, 0,3,5); |
79 | 86 |
output[7] = cornerIndex(corners, 0,4,3); |
80 | 87 |
|
81 |
if( output[0]==-1 ) { android.util.Log.e("D ", "135"); return ERROR_CORNER_135_MISSING; }
|
|
82 |
if( output[1]==-1 ) { android.util.Log.e("D ", "134"); return ERROR_CORNER_134_MISSING; }
|
|
83 |
if( output[2]==-1 ) { android.util.Log.e("D ", "125"); return ERROR_CORNER_125_MISSING; }
|
|
84 |
if( output[3]==-1 ) { android.util.Log.e("D ", "124"); return ERROR_CORNER_124_MISSING; }
|
|
85 |
if( output[4]==-1 ) { android.util.Log.e("D ", "035"); return ERROR_CORNER_035_MISSING; }
|
|
86 |
if( output[5]==-1 ) { android.util.Log.e("D ", "034"); return ERROR_CORNER_034_MISSING; }
|
|
87 |
if( output[6]==-1 ) { android.util.Log.e("D ", "025"); return ERROR_CORNER_025_MISSING; }
|
|
88 |
if( output[7]==-1 ) { android.util.Log.e("D ", "024"); return ERROR_CORNER_024_MISSING; }
|
|
88 |
if( output[0]==-1 ) return ERROR_CORNER_125_MISSING;
|
|
89 |
if( output[1]==-1 ) return ERROR_CORNER_124_MISSING;
|
|
90 |
if( output[2]==-1 ) return ERROR_CORNER_135_MISSING;
|
|
91 |
if( output[3]==-1 ) return ERROR_CORNER_134_MISSING;
|
|
92 |
if( output[4]==-1 ) return ERROR_CORNER_025_MISSING;
|
|
93 |
if( output[5]==-1 ) return ERROR_CORNER_024_MISSING;
|
|
94 |
if( output[6]==-1 ) return ERROR_CORNER_035_MISSING;
|
|
95 |
if( output[7]==-1 ) return ERROR_CORNER_034_MISSING;
|
|
89 | 96 |
|
90 | 97 |
return 0; |
91 | 98 |
} |
... | ... | |
118 | 125 |
mFaceColors[3] = findColor(corners,mFaceColors[4],mFaceColors[1]); |
119 | 126 |
mFaceColors[5] = findColor(corners,mFaceColors[1],mFaceColors[2]); |
120 | 127 |
|
121 |
for(int i=0; i<6; i++) android.util.Log.e("D", "face "+i+" : "+mFaceColors[i]); |
|
122 |
|
|
123 | 128 |
for(int i=0; i<6; i++) |
124 | 129 |
{ |
125 | 130 |
int color = mFaceColors[i]; |
... | ... | |
177 | 182 |
corners[7][0] = object.getCubitFaceStickerIndex(7,1); |
178 | 183 |
corners[7][1] = object.getCubitFaceStickerIndex(7,3); |
179 | 184 |
corners[7][2] = object.getCubitFaceStickerIndex(7,5); |
180 |
/* |
|
181 |
for(int i=0; i<8; i++) |
|
182 |
for(int f=0; f<3; f++) |
|
183 |
{ |
|
184 |
android.util.Log.e("D", "cubit "+i+" face "+f+" : "+corners[i][f]); |
|
185 |
} |
|
186 |
*/ |
|
185 |
|
|
187 | 186 |
int result0 = computeFaceColors(corners); |
188 | 187 |
if( result0<0 ) return result0; |
189 | 188 |
|
... | ... | |
202 | 201 |
perm[6] = corner_perm[7]>1 ? corner_perm[7]-1 : corner_perm[7]; |
203 | 202 |
|
204 | 203 |
int perm_num = TablebaseHelpers.computePermutationNum(perm); |
205 |
/* |
|
206 |
android.util.Log.e("D", "corner perm num="+perm_num); |
|
207 |
|
|
208 |
for(int i=0; i<8; i++) |
|
209 |
{ |
|
210 |
android.util.Log.e("D", "8perm "+i+" "+corner_perm[i]); |
|
211 |
} |
|
212 |
for(int i=0; i<7; i++) |
|
213 |
{ |
|
214 |
android.util.Log.e("D", "7perm "+i+" "+perm[i]); |
|
215 |
} |
|
216 |
*/ |
|
217 | 204 |
int[] twist = new int[8]; |
218 | 205 |
fillCornerTwists(twist,corners,corner_perm); |
219 | 206 |
|
... | ... | |
234 | 221 |
{ |
235 | 222 |
case 0: return R.string.color_yellow4; |
236 | 223 |
case 1: return R.string.color_white4; |
237 |
case 2: return R.string.color_green4;
|
|
238 |
case 3: return R.string.color_blue4;
|
|
224 |
case 2: return R.string.color_blue4;
|
|
225 |
case 3: return R.string.color_green4;
|
|
239 | 226 |
case 4: return R.string.color_red4; |
240 | 227 |
case 5: return R.string.color_orange4; |
241 | 228 |
} |
... | ... | |
251 | 238 |
{ |
252 | 239 |
case 0: return R.string.color_yellow3; |
253 | 240 |
case 1: return R.string.color_white3; |
254 |
case 2: return R.string.color_green3;
|
|
255 |
case 3: return R.string.color_blue3;
|
|
241 |
case 2: return R.string.color_blue3;
|
|
242 |
case 3: return R.string.color_green3;
|
|
256 | 243 |
case 4: return R.string.color_red3; |
257 | 244 |
case 5: return R.string.color_orange3; |
258 | 245 |
} |
Also available in: Unified diff
2x2 solver class finished.