Revision 9ba7f3f6
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/objects/TwistyMixup.java | ||
---|---|---|
13 | 13 |
import org.distorted.library.type.Static4D; |
14 | 14 |
import org.distorted.objectlib.main.InitData; |
15 | 15 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
16 |
import org.distorted.objectlib.scrambling.ScrambleState; |
|
17 | 16 |
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron; |
18 | 17 |
|
19 | 18 |
import java.io.InputStream; |
... | ... | |
32 | 31 |
new Static3D(0,0,1) |
33 | 32 |
}; |
34 | 33 |
|
35 |
ScrambleState[] mStates;
|
|
34 |
int[][] mEdges;
|
|
36 | 35 |
int[][] mBasicAngle; |
37 | 36 |
float[][] mCuts; |
38 | 37 |
float[][] mPosition; |
... | ... | |
321 | 320 |
|
322 | 321 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
323 | 322 |
|
324 |
public ScrambleState[] getScrambleStates()
|
|
323 |
private void insertSection(int[] table, int startIndex, int size, int startAlg, int state)
|
|
325 | 324 |
{ |
326 |
if( mStates==null )
|
|
325 |
for(int i=0; i<size; i++)
|
|
327 | 326 |
{ |
328 |
int[][] m = new int[16][]; |
|
329 |
|
|
330 |
for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0, 1,i,0, 2,i, |
|
331 |
1,-3,i,1,-2,i,1,-1,i,1,1,i,1,2,i,1,3,i,1,4,i, |
|
332 |
2,-1,i,2, 1,i,2, 2,i }; |
|
333 |
|
|
334 |
mStates = new ScrambleState[] |
|
335 |
{ |
|
336 |
new ScrambleState( new int[][] { m[ 1], m[ 2], m[ 3] } ), // 0 0 |
|
337 |
new ScrambleState( new int[][] { null, m[ 4], m[ 5] } ), // 1 x |
|
338 |
new ScrambleState( new int[][] { m[ 6], null, m[ 7] } ), // 2 y |
|
339 |
new ScrambleState( new int[][] { m[ 8], m[ 9], null } ), // 3 z |
|
340 |
new ScrambleState( new int[][] { m[10], null, m[ 7] } ), // 4 xy |
|
341 |
new ScrambleState( new int[][] { m[11], m[ 9], null } ), // 5 xz |
|
342 |
new ScrambleState( new int[][] { null, m[12], m[ 5] } ), // 6 yx |
|
343 |
new ScrambleState( new int[][] { m[ 8], m[13], null } ), // 7 yz |
|
344 |
new ScrambleState( new int[][] { null, m[ 4], m[14] } ), // 8 zx |
|
345 |
new ScrambleState( new int[][] { m[ 6], null, m[15] } ), // 9 zy |
|
346 |
new ScrambleState( new int[][] { null, null, m[ 5] } ), // 10 xyx |
|
347 |
new ScrambleState( new int[][] { null, m[ 4], null } ), // 11 xzx |
|
348 |
new ScrambleState( new int[][] { null, null, m[ 7] } ), // 12 yxy |
|
349 |
new ScrambleState( new int[][] { m[ 6], null, null } ), // 13 yzy |
|
350 |
new ScrambleState( new int[][] { null, m[ 9], null } ), // 14 zxz |
|
351 |
new ScrambleState( new int[][] { m[ 8], null, null } ), // 15 zyz |
|
352 |
}; |
|
327 |
table[2*(i+startIndex) ] = startAlg +i; |
|
328 |
table[2*(i+startIndex)+1] = state; |
|
329 |
} |
|
330 |
} |
|
331 |
|
|
332 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
333 |
|
|
334 |
private int[] createEdge(int stateX, int stateY, int stateZ) |
|
335 |
{ |
|
336 |
int size = 13; |
|
337 |
int num = 0; |
|
338 |
if( stateX>=0 ) num += size; |
|
339 |
if( stateY>=0 ) num += size; |
|
340 |
if( stateZ>=0 ) num += size; |
|
341 |
|
|
342 |
int[] ret = new int[2*num]; |
|
343 |
|
|
344 |
if( stateX>=0 ) |
|
345 |
{ |
|
346 |
insertSection(ret,0,size,0,stateX); |
|
347 |
if( stateY>=0 ) |
|
348 |
{ |
|
349 |
insertSection(ret,size,size,size,stateY); |
|
350 |
if( stateZ>=0 ) insertSection(ret,2*size,size,2*size,stateZ); |
|
351 |
} |
|
352 |
else |
|
353 |
{ |
|
354 |
insertSection(ret,size,size,2*size,stateZ); |
|
355 |
} |
|
356 |
} |
|
357 |
else |
|
358 |
{ |
|
359 |
if( stateY>=0 ) |
|
360 |
{ |
|
361 |
insertSection(ret,0,size,size,stateY); |
|
362 |
if( stateZ>=0 ) insertSection(ret,size,size,2*size,stateZ); |
|
363 |
} |
|
364 |
else |
|
365 |
{ |
|
366 |
insertSection(ret,0,size,2*size,stateZ); |
|
367 |
} |
|
368 |
} |
|
369 |
|
|
370 |
return ret; |
|
371 |
} |
|
372 |
|
|
373 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
374 |
// same as in a non-flat cuboids |
|
375 |
|
|
376 |
public int[][] getScrambleEdges() |
|
377 |
{ |
|
378 |
if( mEdges==null ) |
|
379 |
{ |
|
380 |
mEdges = new int[][] |
|
381 |
{ |
|
382 |
createEdge( 1, 2, 3), // 0 0 |
|
383 |
createEdge(-1, 4, 5), // 1 x |
|
384 |
createEdge( 6,-1, 7), // 2 y |
|
385 |
createEdge( 8, 9,-1), // 3 z |
|
386 |
createEdge(10,-1, 7), // 4 xy |
|
387 |
createEdge(11, 9,-1), // 5 xz |
|
388 |
createEdge(-1,12, 5), // 6 yx |
|
389 |
createEdge( 8,13,-1), // 7 yz |
|
390 |
createEdge(-1, 4,14), // 8 zx |
|
391 |
createEdge( 6,-1,15), // 9 zy |
|
392 |
createEdge(-1,-1, 5), // 10 xyx |
|
393 |
createEdge(-1, 4,-1), // 11 xzx |
|
394 |
createEdge(-1,-1, 7), // 12 yxy |
|
395 |
createEdge( 6,-1,-1), // 13 yzy |
|
396 |
createEdge(-1, 9,-1), // 14 zxz |
|
397 |
createEdge( 8,-1,-1), // 15 zyz |
|
398 |
}; |
|
353 | 399 |
} |
354 | 400 |
|
355 |
return mStates;
|
|
401 |
return mEdges;
|
|
356 | 402 |
} |
357 | 403 |
|
358 | 404 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.