Revision a480ee80
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
197 | 197 |
super(size, 2*size-2, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth); |
198 | 198 |
} |
199 | 199 |
|
200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 |
|
|
202 |
int[] getSolvedQuats(int cubit, int numLayers) |
|
203 |
{ |
|
204 |
int status = retCubitSolvedStatus(cubit,numLayers); |
|
205 |
return status<0 ? null : buildSolvedQuats(MovementSkewb.FACE_AXIS[status],QUATS); |
|
206 |
} |
|
207 |
|
|
200 | 208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
201 | 209 |
|
202 | 210 |
private int getNumCorners() |
... | ... | |
605 | 613 |
} |
606 | 614 |
} |
607 | 615 |
|
608 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
609 |
// The Skewb is solved if and only if: |
|
610 |
// |
|
611 |
// 1) all of its corner and edge cubits are rotated with the same quat |
|
612 |
// 2) all its face cubits are rotated with the same quat like the corner ones, |
|
613 |
// and optionally they also might be upside down. |
|
614 |
// |
|
615 |
// i.e. |
|
616 |
// cubits [ 8] and [ 9] - might be extra QUAT[1] |
|
617 |
// cubits [10] and [11] - might be extra QUAT[2] |
|
618 |
// cubits [12] and [13] - might be extra QUAT[3] |
|
619 |
|
|
620 |
public boolean isSolved() |
|
621 |
{ |
|
622 |
int q = CUBITS[0].mQuatIndex; |
|
623 |
|
|
624 |
int numLayers = getNumLayers(); |
|
625 |
int numCorners = getNumCorners(); |
|
626 |
int numEdges = getNumEdges(numLayers); |
|
627 |
int cornersAndEdges= numCorners + numEdges; |
|
628 |
int centersPerFace = getNumCentersPerFace(numLayers); |
|
629 |
int cubit, q1=q; |
|
630 |
|
|
631 |
for(cubit=0; cubit<cornersAndEdges; cubit++) |
|
632 |
{ |
|
633 |
if( CUBITS[cubit].mQuatIndex != q ) return false; |
|
634 |
} |
|
635 |
|
|
636 |
for(int face=0; face<6; face++) |
|
637 |
{ |
|
638 |
if( face%2==0 ) q1 = mulQuat(q, (face/2)+1); |
|
639 |
|
|
640 |
for(int center=0; center<centersPerFace; center++) |
|
641 |
{ |
|
642 |
if( CUBITS[cubit].mQuatIndex != q && CUBITS[cubit].mQuatIndex != q1 ) return false; |
|
643 |
cubit++; |
|
644 |
} |
|
645 |
} |
|
646 |
|
|
647 |
return true; |
|
648 |
} |
|
649 |
|
|
650 | 616 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
651 | 617 |
|
652 | 618 |
public int getObjectName(int numLayers) |
Also available in: Unified diff
Standarize the 'isSolved()' method: now all objects, except one (Dino4) have a standard isSolved().
This incidentally also fixes detection of the solved state in case of Diamond4, i.e. a Master FTO.