Revision 91792184
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyMinx.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.type.Static3D; |
30 | 30 |
import org.distorted.library.type.Static4D; |
31 | 31 |
|
32 |
import java.util.Random; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
abstract class TwistyMinx extends TwistyObject |
... | ... | |
81 | 79 |
MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY |
82 | 80 |
}; |
83 | 81 |
|
84 |
private int mCurrState; |
|
85 |
private int mIndexExcluded; |
|
86 | 82 |
private ScrambleState[] mStates; |
87 |
private int[][] mScrambleTable; |
|
88 |
private int[] mNumOccurences; |
|
89 | 83 |
private int[] mBasicAngle; |
90 | 84 |
private int[] mFaceMap; |
91 | 85 |
Static4D[] mQuats; |
... | ... | |
105 | 99 |
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth) |
106 | 100 |
{ |
107 | 101 |
super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth); |
108 |
|
|
109 |
initializeScrambleStates(numLayers); |
|
110 | 102 |
} |
111 | 103 |
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
|
106 |
ScrambleState[] getScrambleStates() |
|
107 |
{ |
|
108 |
if( mStates==null ) |
|
109 |
{ |
|
110 |
int numLayers = getNumLayers(); |
|
111 |
initializeScrambleStates(numLayers); |
|
112 |
} |
|
113 |
|
|
114 |
return mStates; |
|
115 |
} |
|
112 | 116 |
|
113 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
114 | 118 |
|
... | ... | |
553 | 557 |
return 2.0f; |
554 | 558 |
} |
555 | 559 |
|
556 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
557 |
|
|
558 |
private void initializeScrambling() |
|
559 |
{ |
|
560 |
int numLayers = getNumLayers(); |
|
561 |
|
|
562 |
if( mScrambleTable ==null ) |
|
563 |
{ |
|
564 |
mScrambleTable = new int[NUM_AXIS][numLayers]; |
|
565 |
} |
|
566 |
if( mNumOccurences ==null ) |
|
567 |
{ |
|
568 |
int max=0; |
|
569 |
|
|
570 |
for (ScrambleState mState : mStates) |
|
571 |
{ |
|
572 |
int tmp = mState.getTotal(-1); |
|
573 |
if (max < tmp) max = tmp; |
|
574 |
} |
|
575 |
|
|
576 |
mNumOccurences = new int[max]; |
|
577 |
} |
|
578 |
|
|
579 |
for(int i=0; i<NUM_AXIS; i++) |
|
580 |
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0; |
|
581 |
} |
|
582 |
|
|
583 | 560 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
584 | 561 |
// PUBLIC API |
585 | 562 |
|
586 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles) |
|
587 |
{ |
|
588 |
if( curr==0 ) |
|
589 |
{ |
|
590 |
mCurrState = 0; |
|
591 |
mIndexExcluded =-1; |
|
592 |
initializeScrambling(); |
|
593 |
} |
|
594 |
|
|
595 |
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences); |
|
596 |
|
|
597 |
scramble[curr][0] = info[0]; |
|
598 |
scramble[curr][1] = info[1]; |
|
599 |
scramble[curr][2] = info[2]; |
|
600 |
|
|
601 |
mCurrState = info[3]; |
|
602 |
mIndexExcluded = info[0]; |
|
603 |
} |
|
604 |
|
|
605 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
606 |
|
|
607 | 563 |
public Static3D[] getRotationAxis() |
608 | 564 |
{ |
609 | 565 |
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')