Revision 8db55f55
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyBandaged3Plate.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.main.DistortedTexture; |
26 | 26 |
import org.distorted.library.mesh.MeshSquare; |
27 | 27 |
import org.distorted.library.type.Static4D; |
28 |
import org.distorted.helpers.BandagedState;
|
|
28 |
import org.distorted.helpers.ScrambleStateGraph;
|
|
29 | 29 |
import org.distorted.main.R; |
30 | 30 |
|
31 | 31 |
import java.util.Random; |
... | ... | |
35 | 35 |
class TwistyBandaged3Plate extends TwistyBandagedAbstract |
36 | 36 |
{ |
37 | 37 |
private int mCurrState; |
38 |
private boolean mUseX; |
|
39 |
private boolean mUseY; |
|
40 |
private boolean mUseZ; |
|
38 |
private int mIndexExcluded; |
|
41 | 39 |
|
42 | 40 |
// The 16 'significant' states of the 3Plate bandaged cube. |
43 | 41 |
// One State means one arrangement of the three 2x2 'plates'. Such State precisely defines which |
... | ... | |
52 | 50 |
// then we will land in state 10. If we make move (2,2), we will land in state 13. There are no other |
53 | 51 |
// 'x' moves that lead to a 'significant' state. |
54 | 52 |
|
55 |
private final BandagedState[] mStates = new BandagedState[]
|
|
53 |
private final ScrambleStateGraph[] mStates = new ScrambleStateGraph[]
|
|
56 | 54 |
{ |
57 |
new BandagedState( new int[] { 2,-1, 1, 2, 1, 6 }, new int[] { 0,-1, 5, 0, 1, 3 }, new int[] { 2,-1, 2, 2, 1, 4 } ),
|
|
58 |
new BandagedState( new int[] { 2, 1, 0 }, null , new int[] { 2, 1,10, 2, 2, 7 } ),
|
|
59 |
new BandagedState( null , new int[] { 0,-1,11, 0, 2, 8 }, new int[] { 2, 1, 0 } ),
|
|
60 |
new BandagedState( new int[] { 2, 1,12, 2, 2, 9 }, new int[] { 0,-1, 0 }, null ),
|
|
61 |
new BandagedState( new int[] { 2,-1,10, 2, 2,13 }, null , new int[] { 2,-1, 0 } ),
|
|
62 |
new BandagedState( null , new int[] { 0, 1, 0 }, new int[] { 2,-1,11, 2, 2,14 } ),
|
|
63 |
new BandagedState( new int[] { 2,-1, 0 }, new int[] { 0, 1,12, 0, 2,15 }, null ),
|
|
64 |
new BandagedState( null , new int[] { 2,-2, 7, 2,-1, 7, 2, 1, 7, 2, 2, 7}, new int[] { 2,-1,10, 2, 2, 1 } ),
|
|
65 |
new BandagedState( new int[] { 0,-2, 8, 0,-1, 8, 0, 1, 8, 0, 2, 8}, new int[] { 0, 1,11, 0, 2, 2 }, null ),
|
|
66 |
new BandagedState( new int[] { 2,-1,12, 2, 2, 3 }, null , new int[] { 0,-2, 9, 0,-1, 9, 0, 1, 9, 0, 2, 9} ),
|
|
67 |
new BandagedState( new int[] { 2,-1,13, 2, 1, 4 }, new int[] { 2,-2,10, 2,-1,10, 2, 1,10, 2, 2,10}, new int[] { 2,-1, 1, 2, 1, 7 } ),
|
|
68 |
new BandagedState( new int[] { 0,-2,11, 0,-1,11, 0, 1,11, 0, 2,11}, new int[] { 0,-1, 8, 0, 1, 2 }, new int[] { 2,-1,14, 2, 1, 5 } ),
|
|
69 |
new BandagedState( new int[] { 2,-1, 3, 2, 1, 9 }, new int[] { 0,-1, 6, 0, 1,15 }, new int[] { 0,-2,12, 0,-1,12, 0, 1,12, 0, 2,12} ),
|
|
70 |
new BandagedState( new int[] { 2, 1,10, 2, 2, 4 }, new int[] { 2,-2,13, 2,-1,13, 2, 1,13, 2, 2,13}, null ),
|
|
71 |
new BandagedState( new int[] { 0,-2,14, 0,-1,14, 0, 1,14, 0, 2,14}, null , new int[] { 2, 1,11, 2, 2, 5 } ),
|
|
72 |
new BandagedState( null , new int[] { 0,-1,12, 0, 2, 6 }, new int[] { 0,-2,15, 0,-1,15, 0, 1,15, 0, 2,15} )
|
|
55 |
new ScrambleStateGraph( new int[][] {{ 2,-1, 1, 2, 1, 6 }, { 0,-1, 5, 0, 1, 3 }, { 2,-1, 2, 2, 1, 4 }} ),
|
|
56 |
new ScrambleStateGraph( new int[][] {{ 2, 1, 0 }, { }, { 2, 1,10, 2, 2, 7 }} ),
|
|
57 |
new ScrambleStateGraph( new int[][] {{ }, { 0,-1,11, 0, 2, 8 }, { 2, 1, 0 }} ),
|
|
58 |
new ScrambleStateGraph( new int[][] {{ 2, 1,12, 2, 2, 9 }, { 0,-1, 0 }, { }} ),
|
|
59 |
new ScrambleStateGraph( new int[][] {{ 2,-1,10, 2, 2,13 }, { }, { 2,-1, 0 }} ),
|
|
60 |
new ScrambleStateGraph( new int[][] {{ }, { 0, 1, 0 }, { 2,-1,11, 2, 2,14 }} ),
|
|
61 |
new ScrambleStateGraph( new int[][] {{ 2,-1, 0 }, { 0, 1,12, 0, 2,15 }, { }} ),
|
|
62 |
new ScrambleStateGraph( new int[][] {{ }, { 2,-2, 7, 2,-1, 7, 2, 1, 7, 2, 2, 7}, { 2,-1,10, 2, 2, 1 }} ),
|
|
63 |
new ScrambleStateGraph( new int[][] {{ 0,-2, 8, 0,-1, 8, 0, 1, 8, 0, 2, 8}, { 0, 1,11, 0, 2, 2 }, { }} ),
|
|
64 |
new ScrambleStateGraph( new int[][] {{ 2,-1,12, 2, 2, 3 }, { }, { 0,-2, 9, 0,-1, 9, 0, 1, 9, 0, 2, 9}} ),
|
|
65 |
new ScrambleStateGraph( new int[][] {{ 2,-1,13, 2, 1, 4 }, { 2,-2,10, 2,-1,10, 2, 1,10, 2, 2,10}, { 2,-1, 1, 2, 1, 7 }} ),
|
|
66 |
new ScrambleStateGraph( new int[][] {{ 0,-2,11, 0,-1,11, 0, 1,11, 0, 2,11}, { 0,-1, 8, 0, 1, 2 }, { 2,-1,14, 2, 1, 5 }} ),
|
|
67 |
new ScrambleStateGraph( new int[][] {{ 2,-1, 3, 2, 1, 9 }, { 0,-1, 6, 0, 1,15 }, { 0,-2,12, 0,-1,12, 0, 1,12, 0, 2,12}} ),
|
|
68 |
new ScrambleStateGraph( new int[][] {{ 2, 1,10, 2, 2, 4 }, { 2,-2,13, 2,-1,13, 2, 1,13, 2, 2,13}, { }} ),
|
|
69 |
new ScrambleStateGraph( new int[][] {{ 0,-2,14, 0,-1,14, 0, 1,14, 0, 2,14}, { }, { 2, 1,11, 2, 2, 5 }} ),
|
|
70 |
new ScrambleStateGraph( new int[][] {{ }, { 0,-1,12, 0, 2, 6 }, { 0,-2,15, 0,-1,15, 0, 1,15, 0, 2,15}} )
|
|
73 | 71 |
}; |
74 | 72 |
|
75 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
126 | 124 |
{ |
127 | 125 |
if( curr==0 ) |
128 | 126 |
{ |
129 |
mCurrState = 0; |
|
130 |
mUseX = true; |
|
131 |
mUseY = true; |
|
132 |
mUseZ = true; |
|
127 |
mCurrState = 0; |
|
128 |
mIndexExcluded =-1; |
|
133 | 129 |
} |
134 | 130 |
|
135 |
int total = mStates[mCurrState].getTotal(mUseX,mUseY,mUseZ);
|
|
131 |
int total = mStates[mCurrState].getTotal(mIndexExcluded);
|
|
136 | 132 |
int random= rnd.nextInt(total); |
137 |
int[] info= mStates[mCurrState].getInfo(random,mUseX,mUseY,mUseZ);
|
|
133 |
int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
|
|
138 | 134 |
|
139 | 135 |
scramble[curr][0] = info[0]; |
140 | 136 |
scramble[curr][1] = info[1]; |
141 | 137 |
scramble[curr][2] = info[2]; |
142 | 138 |
|
143 |
mCurrState = info[3]; |
|
144 |
|
|
145 |
switch(info[0]) |
|
146 |
{ |
|
147 |
case 0: mUseX = false; mUseY = true ; mUseZ = true ; break; |
|
148 |
case 1: mUseX = true ; mUseY = false; mUseZ = true ; break; |
|
149 |
case 2: mUseX = true ; mUseY = true ; mUseZ = false; break; |
|
150 |
} |
|
139 |
mCurrState = info[3]; |
|
140 |
mIndexExcluded = info[0]; |
|
151 | 141 |
} |
152 | 142 |
|
153 | 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Preparation for unification of scrambling. Scrambling of all objects will be done by a generic funtion, only fed a certain data structure by the objects. The data structure is going to be the ScrambleStateGraph - a directed state graph of all states we can come across while scrambling.
Make the ScrambleStateGraph support any number of axis, not only 3 as it did up till now. Also, correct one problem in BangadageCubeEvil's StageGraph: its state number 114 was incorrect, missing one move.