Revision 9ba7f3f6
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java | ||
---|---|---|
21 | 21 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
22 | 22 |
import org.distorted.objectlib.helpers.ObjectSignature; |
23 | 23 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
24 |
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator; |
|
24 | 25 |
import org.distorted.objectlib.main.InitData; |
25 | 26 |
import org.distorted.objectlib.touchcontrol.TouchControlCuboids; |
26 | 27 |
import org.distorted.objectlib.main.ObjectType; |
27 | 28 |
import org.distorted.objectlib.helpers.ObjectShape; |
28 |
import org.distorted.objectlib.scrambling.ScrambleState; |
|
29 | 29 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
30 | 30 |
|
31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
39 | 39 |
new Static3D(0,0,1) |
40 | 40 |
}; |
41 | 41 |
|
42 |
private ScrambleState[] mStates;
|
|
42 |
private int[][] mEdges;
|
|
43 | 43 |
private float[][] mCuts; |
44 | 44 |
private int[][] mBasicAngle; |
45 | 45 |
|
... | ... | |
88 | 88 |
|
89 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
90 | 90 |
|
91 |
private int[] createEdges(int size, boolean full, int vertex)
|
|
91 |
public int[][] getScrambleEdges()
|
|
92 | 92 |
{ |
93 |
if( size==1 ) return null; |
|
94 |
|
|
95 |
if( full ) |
|
96 |
{ |
|
97 |
int[] ret = new int[9*size]; |
|
98 |
|
|
99 |
for(int l=0; l<size; l++) |
|
100 |
{ |
|
101 |
ret[9*l ] = l; |
|
102 |
ret[9*l+1] =-1; |
|
103 |
ret[9*l+2] = vertex; |
|
104 |
ret[9*l+3] = l; |
|
105 |
ret[9*l+4] = 1; |
|
106 |
ret[9*l+5] = vertex; |
|
107 |
ret[9*l+6] = l; |
|
108 |
ret[9*l+7] = 2; |
|
109 |
ret[9*l+8] = vertex; |
|
110 |
} |
|
111 |
|
|
112 |
return ret; |
|
113 |
} |
|
114 |
else |
|
115 |
{ |
|
116 |
int[] ret = new int[6*size]; |
|
117 |
|
|
118 |
for(int l=0; l<size; l++) |
|
119 |
{ |
|
120 |
ret[6*l ] = l; |
|
121 |
ret[6*l+1] = 1; |
|
122 |
ret[6*l+2] = vertex; |
|
123 |
ret[6*l+3] = l; |
|
124 |
ret[6*l+4] =-1; |
|
125 |
ret[6*l+5] = vertex; |
|
126 |
} |
|
127 |
|
|
128 |
return ret; |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 |
|
|
134 |
public ScrambleState[] getScrambleStates() |
|
135 |
{ |
|
136 |
if( mStates==null ) |
|
93 |
if( mEdges==null ) |
|
137 | 94 |
{ |
138 | 95 |
int[] numLayers = getNumLayers(); |
139 | 96 |
|
... | ... | |
141 | 98 |
int Y = numLayers[1]; |
142 | 99 |
int Z = numLayers[2]; |
143 | 100 |
|
144 |
int[][] mX = new int[16][]; |
|
145 |
int[][] mY = new int[16][]; |
|
146 |
int[][] mZ = new int[16][]; |
|
147 |
|
|
148 |
for(int i=0; i<16; i++) |
|
149 |
{ |
|
150 |
mX[i] = createEdges(X,Y==Z,i); |
|
151 |
mY[i] = createEdges(Y,X==Z,i); |
|
152 |
mZ[i] = createEdges(Z,X==Y,i); |
|
153 |
} |
|
154 |
|
|
155 | 101 |
if( X>1 && Y>1 && Z>1 ) |
156 | 102 |
{ |
157 |
mStates = new ScrambleState[] |
|
158 |
{ |
|
159 |
new ScrambleState( new int[][] { mX[ 1], mY[ 2], mZ[ 3] } ), // 0 0 |
|
160 |
new ScrambleState( new int[][] { null, mY[ 4], mZ[ 5] } ), // 1 x |
|
161 |
new ScrambleState( new int[][] { mX[ 6], null, mZ[ 7] } ), // 2 y |
|
162 |
new ScrambleState( new int[][] { mX[ 8], mY[ 9], null } ), // 3 z |
|
163 |
new ScrambleState( new int[][] { mX[10], null, mZ[ 7] } ), // 4 xy |
|
164 |
new ScrambleState( new int[][] { mX[11], mY[ 9], null } ), // 5 xz |
|
165 |
new ScrambleState( new int[][] { null, mY[12], mZ[ 5] } ), // 6 yx |
|
166 |
new ScrambleState( new int[][] { mX[ 8], mY[13], null } ), // 7 yz |
|
167 |
new ScrambleState( new int[][] { null, mY[ 4], mZ[14] } ), // 8 zx |
|
168 |
new ScrambleState( new int[][] { mX[ 6], null, mZ[15] } ), // 9 zy |
|
169 |
new ScrambleState( new int[][] { null, null, mZ[ 5] } ), // 10 xyx |
|
170 |
new ScrambleState( new int[][] { null, mY[ 4], null } ), // 11 xzx |
|
171 |
new ScrambleState( new int[][] { null, null, mZ[ 7] } ), // 12 yxy |
|
172 |
new ScrambleState( new int[][] { mX[ 6], null, null } ), // 13 yzy |
|
173 |
new ScrambleState( new int[][] { null, mY[ 9], null } ), // 14 zxz |
|
174 |
new ScrambleState( new int[][] { mX[ 8], null, null } ), // 15 zyz |
|
175 |
}; |
|
176 |
} |
|
177 |
else if( X==1 && Y==1 && Z==1 ) |
|
178 |
{ |
|
179 |
int[] state = new int[] {0,-1,0,0,1,0,0,2,0}; |
|
180 |
|
|
181 |
mStates = new ScrambleState[] |
|
182 |
{ |
|
183 |
new ScrambleState( new int[][] { state, state, state } ) |
|
184 |
}; |
|
103 |
mEdges = ScrambleEdgeGenerator.getScrambleEdgesCuboid(X,Y,Z); |
|
185 | 104 |
} |
186 | 105 |
else |
187 | 106 |
{ |
188 |
mStates = new ScrambleState[] |
|
107 |
int size = 3*(X+Y+Z); |
|
108 |
int[] edge = new int[2*size]; |
|
109 |
|
|
110 |
for(int i=0; i<size; i++) |
|
189 | 111 |
{ |
190 |
new ScrambleState( new int[][] { mX[ 0], mY[ 0], mZ[ 0] } )
|
|
191 |
};
|
|
192 |
} |
|
112 |
edge[2*i ] = i;
|
|
113 |
edge[2*i+1] = 0;
|
|
114 |
}
|
|
193 | 115 |
|
116 |
mEdges = new int[][] { edge }; |
|
117 |
} |
|
194 | 118 |
} |
195 | 119 |
|
196 |
return mStates;
|
|
120 |
return mEdges;
|
|
197 | 121 |
} |
198 | 122 |
|
199 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.