Revision 91792184
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.type.Static4D; |
32 | 32 |
import org.distorted.main.R; |
33 | 33 |
|
34 |
import java.util.Random; |
|
35 |
|
|
36 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 35 |
|
38 | 36 |
public class TwistySkewb extends TwistyObject |
... | ... | |
53 | 51 |
COLOR_RED , COLOR_ORANGE |
54 | 52 |
}; |
55 | 53 |
|
56 |
private int mCurrState; |
|
57 |
private int mIndexExcluded; |
|
58 |
private final ScrambleState[] mStates; |
|
59 |
private int[][] mScrambleTable; |
|
60 |
private int[] mNumOccurences; |
|
54 |
private ScrambleState[] mStates; |
|
61 | 55 |
private int[] mBasicAngle; |
62 | 56 |
private Static4D[] mQuats; |
63 | 57 |
private int[][] mCornerMap,mEdgeMap,mCenterMap; |
... | ... | |
69 | 63 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
70 | 64 |
{ |
71 | 65 |
super(size, 2*size-2, quat, texture, mesh, effects, moves, ObjectList.SKEW, res, scrWidth); |
66 |
} |
|
72 | 67 |
|
73 |
int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 };
|
|
68 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
74 | 69 |
|
75 |
mStates = new ScrambleState[] |
|
70 |
ScrambleState[] getScrambleStates() |
|
71 |
{ |
|
72 |
if( mStates==null ) |
|
76 | 73 |
{ |
77 |
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} ) |
|
78 |
}; |
|
74 |
int size = getNumLayers(); |
|
75 |
int[] tmp = {0,-1,0, 0,1,0, size-1,-1,0, size-1,1,0 }; |
|
76 |
|
|
77 |
mStates = new ScrambleState[] |
|
78 |
{ |
|
79 |
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} ) |
|
80 |
}; |
|
81 |
} |
|
82 |
|
|
83 |
return mStates; |
|
79 | 84 |
} |
80 | 85 |
|
81 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
558 | 563 |
return 2.0f; |
559 | 564 |
} |
560 | 565 |
|
561 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
562 |
|
|
563 |
private void initializeScrambling() |
|
564 |
{ |
|
565 |
int numLayers = getNumLayers(); |
|
566 |
|
|
567 |
if( mScrambleTable ==null ) |
|
568 |
{ |
|
569 |
mScrambleTable = new int[NUM_AXIS][numLayers]; |
|
570 |
} |
|
571 |
if( mNumOccurences ==null ) |
|
572 |
{ |
|
573 |
int max=0; |
|
574 |
|
|
575 |
for (ScrambleState mState : mStates) |
|
576 |
{ |
|
577 |
int tmp = mState.getTotal(-1); |
|
578 |
if (max < tmp) max = tmp; |
|
579 |
} |
|
580 |
|
|
581 |
mNumOccurences = new int[max]; |
|
582 |
} |
|
583 |
|
|
584 |
for(int i=0; i<NUM_AXIS; i++) |
|
585 |
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0; |
|
586 |
} |
|
587 |
|
|
588 | 566 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
589 | 567 |
// PUBLIC API |
590 | 568 |
|
591 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles) |
|
592 |
{ |
|
593 |
if( curr==0 ) |
|
594 |
{ |
|
595 |
mCurrState = 0; |
|
596 |
mIndexExcluded =-1; |
|
597 |
initializeScrambling(); |
|
598 |
} |
|
599 |
|
|
600 |
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences); |
|
601 |
|
|
602 |
scramble[curr][0] = info[0]; |
|
603 |
scramble[curr][1] = info[1]; |
|
604 |
scramble[curr][2] = info[2]; |
|
605 |
|
|
606 |
mCurrState = info[3]; |
|
607 |
mIndexExcluded = info[0]; |
|
608 |
} |
|
609 |
|
|
610 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
611 |
|
|
612 | 569 |
public Static3D[] getRotationAxis() |
613 | 570 |
{ |
614 | 571 |
return ROT_AXIS; |
Also available in: Unified diff
Make object scrambling abstract (well, almost - with exception of Square-1 - this theoretically could also be done the generic way, but this would require almost 20000 'ScrambleStates')