Revision e42a9e87
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
454 | 454 |
if( mSolvedFunctionIndex==0 ) return isSolved0(); |
455 | 455 |
if( mSolvedFunctionIndex==1 ) return isSolved1(); |
456 | 456 |
if( mSolvedFunctionIndex==2 ) return isSolved2(); |
457 |
if( mSolvedFunctionIndex==3 ) return isSolved3(); |
|
457 | 458 |
|
458 | 459 |
return false; |
459 | 460 |
} |
... | ... | |
588 | 589 |
} |
589 | 590 |
|
590 | 591 |
return ( qX==qY && qX==qZ ) || ( qY==mulQuat(qX,2) && qZ==mulQuat(qX,8) ); |
592 |
} |
|
593 |
|
|
594 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
595 |
// Square-2 is solved iff |
|
596 |
// a) all of its cubits are rotated with the same quat |
|
597 |
// b) its two 'middle' cubits are rotated with the same quat, the 6 'front' and 6 'back' |
|
598 |
// edges and corners with this quat multiplied by QUATS[18] (i.e. those are upside down) |
|
599 |
// and all the 12 left and right edges and corners also with the same quat multiplied by |
|
600 |
// QUATS[12] - i.e. also upside down. |
|
601 |
|
|
602 |
public boolean isSolved3() |
|
603 |
{ |
|
604 |
int index = CUBITS[0].mQuatIndex; |
|
605 |
|
|
606 |
if( CUBITS[1].mQuatIndex!=index ) return false; |
|
607 |
|
|
608 |
boolean solved = true; |
|
609 |
|
|
610 |
for(int i=2; i<NUM_CUBITS; i++) |
|
611 |
{ |
|
612 |
if( CUBITS[i].mQuatIndex!=index ) |
|
613 |
{ |
|
614 |
solved = false; |
|
615 |
break; |
|
616 |
} |
|
617 |
} |
|
591 | 618 |
|
619 |
if( solved ) return true; |
|
620 |
|
|
621 |
int indexX = mulQuat(index,12); // QUATS[12] = 180deg (1,0,0) |
|
622 |
int indexZ = mulQuat(index,18); // QUATS[18] = 180deg (0,0,1) |
|
623 |
|
|
624 |
for(int i= 2; i< 18; i+=2) if( CUBITS[i].mQuatIndex != indexZ ) return false; |
|
625 |
for(int i= 3; i< 18; i+=2) if( CUBITS[i].mQuatIndex != indexX ) return false; |
|
626 |
for(int i=18; i<NUM_CUBITS; i+=2) if( CUBITS[i].mQuatIndex != indexX ) return false; |
|
627 |
for(int i=19; i<NUM_CUBITS; i+=2) if( CUBITS[i].mQuatIndex != indexZ ) return false; |
|
628 |
|
|
629 |
return true; |
|
592 | 630 |
} |
593 | 631 |
|
594 | 632 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySquare.java | ||
---|---|---|
220 | 220 |
return FACE_COLORS[face]; |
221 | 221 |
} |
222 | 222 |
|
223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
224 |
|
|
225 |
int getSolvedFunctionIndex() |
|
226 |
{ |
|
227 |
return 0; |
|
228 |
} |
|
229 |
|
|
230 | 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
231 | 224 |
// PUBLIC API |
232 | 225 |
|
src/main/java/org/distorted/objects/TwistySquare1.java | ||
---|---|---|
260 | 260 |
return CENTERS; |
261 | 261 |
} |
262 | 262 |
|
263 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
264 |
|
|
265 |
int getSolvedFunctionIndex() |
|
266 |
{ |
|
267 |
return 0; |
|
268 |
} |
|
269 |
|
|
263 | 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
264 | 271 |
|
265 | 272 |
int getNumStickerTypes(int numLayers) |
src/main/java/org/distorted/objects/TwistySquare2.java | ||
---|---|---|
182 | 182 |
} |
183 | 183 |
|
184 | 184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
185 |
// Square-2 is solved iff |
|
186 |
// a) all of its cubits are rotated with the same quat |
|
187 |
// b) its two 'middle' cubits are rotated with the same quat, the 6 'front' and 6 'back' |
|
188 |
// edges and corners with this quat multiplied by QUATS[18] (i.e. those are upside down) |
|
189 |
// and all the 12 left and right edges and corners also with the same quat multiplied by |
|
190 |
// QUATS[12] - i.e. also upside down. |
|
191 |
|
|
192 |
private static final int[] S18 = new int[] {18}; |
|
193 |
private static final int[] S12 = new int[] {12}; |
|
194 | 185 |
|
195 | 186 |
int[] getSolvedQuats(int cubit, int numLayers) |
196 | 187 |
{ |
197 |
switch(cubit) |
|
198 |
{ |
|
199 |
case 0: case 1: return null; |
|
200 |
case 2: case 4: case 6: case 8: |
|
201 |
case 10: case 12: case 14: case 16: |
|
202 |
case 19: case 21: case 23: case 25: return S18; |
|
203 |
case 3: case 5: case 7: case 9: |
|
204 |
case 11: case 13: case 15: case 17: |
|
205 |
case 18: case 20: case 22: case 24: return S12; |
|
206 |
} |
|
207 |
|
|
208 | 188 |
return null; |
209 | 189 |
} |
210 | 190 |
|
... | ... | |
281 | 261 |
return CENTERS; |
282 | 262 |
} |
283 | 263 |
|
264 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
265 |
|
|
266 |
int getSolvedFunctionIndex() |
|
267 |
{ |
|
268 |
return 3; |
|
269 |
} |
|
270 |
|
|
284 | 271 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
285 | 272 |
|
286 | 273 |
int getNumStickerTypes(int numLayers) |
Also available in: Unified diff
Fix the Square-2 isSolved() (it was wrong even before!)