Revision 9ba7f3f6
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/objects/TwistyVoid.java | ||
---|---|---|
17 | 17 |
import org.distorted.objectlib.helpers.ObjectSignature; |
18 | 18 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
19 | 19 |
import org.distorted.objectlib.main.InitData; |
20 |
import org.distorted.objectlib.scrambling.ScrambleState; |
|
21 | 20 |
import org.distorted.objectlib.main.ObjectType; |
22 | 21 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
23 | 22 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
... | ... | |
38 | 37 |
new Static3D(0,0,1) |
39 | 38 |
}; |
40 | 39 |
|
41 |
private ScrambleState[] mStates;
|
|
40 |
private int[][] mEdges;
|
|
42 | 41 |
private int[][] mBasicAngle; |
43 | 42 |
private float[][] mCuts; |
44 | 43 |
private float[][] mPositions; |
... | ... | |
76 | 75 |
return 0xff222222; |
77 | 76 |
} |
78 | 77 |
|
78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
79 |
|
|
80 |
private void insertSection(int[] table, int startIndex, int size, int startAlg, int state) |
|
81 |
{ |
|
82 |
for(int i=0; i<size; i++) |
|
83 |
{ |
|
84 |
table[2*(i+startIndex) ] = startAlg +i; |
|
85 |
table[2*(i+startIndex)+1] = state; |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
90 |
|
|
91 |
private int[] createEdge(int stateX, int stateY, int stateZ) |
|
92 |
{ |
|
93 |
int size = 8; |
|
94 |
int num = 0; |
|
95 |
if( stateX>=0 ) num += size; |
|
96 |
if( stateY>=0 ) num += size; |
|
97 |
if( stateZ>=0 ) num += size; |
|
98 |
|
|
99 |
int[] ret = new int[2*num]; |
|
100 |
|
|
101 |
if( stateX>=0 ) |
|
102 |
{ |
|
103 |
insertSection(ret,0,size,0,stateX); |
|
104 |
if( stateY>=0 ) |
|
105 |
{ |
|
106 |
insertSection(ret,size,size,size+1,stateY); |
|
107 |
if( stateZ>=0 ) insertSection(ret,2*size,size,2*size+2,stateZ); |
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
if( stateZ>=0 ) insertSection(ret,size,size,2*size+2,stateZ); |
|
112 |
} |
|
113 |
} |
|
114 |
else |
|
115 |
{ |
|
116 |
if( stateY>=0 ) |
|
117 |
{ |
|
118 |
insertSection(ret,0,size,size+1,stateY); |
|
119 |
if( stateZ>=0 ) insertSection(ret,size,size,2*size+2,stateZ); |
|
120 |
} |
|
121 |
else |
|
122 |
{ |
|
123 |
if( stateZ>=0 ) insertSection(ret,0,size,2*size+2,stateZ); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
return ret; |
|
128 |
} |
|
129 |
|
|
79 | 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
80 | 131 |
// Normal 3x3, but without the 180 deg move of the middle layer. |
81 | 132 |
// We need to rotate the middle layer here (by swiping it is not possible) because otherwise the |
82 | 133 |
// phantom centers would always stay at their initial positions which would defeat the point here. |
83 | 134 |
|
84 |
public ScrambleState[] getScrambleStates()
|
|
135 |
public int[][] getScrambleEdges()
|
|
85 | 136 |
{ |
86 |
if( mStates==null )
|
|
137 |
if( mEdges==null )
|
|
87 | 138 |
{ |
88 |
int[][] m = new int[16][]; |
|
89 |
|
|
90 |
for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i, 2,-1,i,2,1,i,2,2,i}; |
|
91 |
|
|
92 |
mStates = new ScrambleState[] |
|
93 |
{ |
|
94 |
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0 |
|
95 |
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x |
|
96 |
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y |
|
97 |
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z |
|
98 |
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy |
|
99 |
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz |
|
100 |
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx |
|
101 |
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz |
|
102 |
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx |
|
103 |
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy |
|
104 |
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx |
|
105 |
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx |
|
106 |
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy |
|
107 |
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy |
|
108 |
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz |
|
109 |
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz |
|
110 |
}; |
|
139 |
mEdges = new int[][] |
|
140 |
{ |
|
141 |
createEdge( 1, 2, 3), // 0 0 |
|
142 |
createEdge(-1, 4, 5), // 1 x |
|
143 |
createEdge( 6,-1, 7), // 2 y |
|
144 |
createEdge( 8, 9,-1), // 3 z |
|
145 |
createEdge(10,-1, 7), // 4 xy |
|
146 |
createEdge(11, 9,-1), // 5 xz |
|
147 |
createEdge(-1,12, 5), // 6 yx |
|
148 |
createEdge( 8,13,-1), // 7 yz |
|
149 |
createEdge(-1, 4,14), // 8 zx |
|
150 |
createEdge( 6,-1,15), // 9 zy |
|
151 |
createEdge(-1,-1, 5), // 10 xyx |
|
152 |
createEdge(-1, 4,-1), // 11 xzx |
|
153 |
createEdge(-1,-1, 7), // 12 yxy |
|
154 |
createEdge( 6,-1,-1), // 13 yzy |
|
155 |
createEdge(-1, 9,-1), // 14 zxz |
|
156 |
createEdge( 8,-1,-1), // 15 zyz |
|
157 |
}; |
|
111 | 158 |
} |
112 | 159 |
|
113 |
return mStates;
|
|
160 |
return mEdges;
|
|
114 | 161 |
} |
115 | 162 |
|
116 | 163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
131 | 178 |
|
132 | 179 |
public boolean[][] getLayerRotatable(int[] numLayers) |
133 | 180 |
{ |
134 |
boolean[] tmp = new boolean[] {true,true,true};
|
|
181 |
boolean[] tmp = new boolean[] {true,false,true};
|
|
135 | 182 |
return new boolean[][] { tmp,tmp,tmp }; |
136 | 183 |
} |
137 | 184 |
|
Also available in: Unified diff
Move scrambling to a new model where there are spearete scrambling 'algorithms' and 'edges' of the scrambling graph.
Now each edge can contain a whole algorithm, i.e. a sequence of moves leading from state to state, which permits construction of scrambling for more complicated bandaged objects such as the AI cube.
Unchecked as of yet, probably still a lot of bugs.