Revision a72a4b6a
Added by Leszek Koltunski about 2 years ago
src/main/java/org/distorted/objectlib/scrambling/ObjectScrambler.java | ||
---|---|---|
54 | 54 |
private int[][] mQuatMult; |
55 | 55 |
|
56 | 56 |
// type=2 , i.e. locally created bandaged cuboids |
57 |
private static ObjectSignature mSignature; |
|
58 | 57 |
private ArrayList<ScrambleStateBandagedCuboid> mBandagedStates; |
59 | 58 |
|
60 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
106 | 105 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 106 |
// PUBLIC API |
108 | 107 |
|
109 |
private void randomizeNewScramble0(int[][] scramble, Random rnd, int curr, int total)
|
|
108 |
private void randomizeNewScramble0(int[][] scramble, Random rnd, int curr) |
|
110 | 109 |
{ |
111 | 110 |
if( curr==0 ) |
112 | 111 |
{ |
... | ... | |
346 | 345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
347 | 346 |
// TYPE 1 |
348 | 347 |
|
349 |
private void randomizeNewScramble1(int[][] scramble, Random rnd, int curr, int total)
|
|
348 |
private void randomizeNewScramble1(int[][] scramble, Random rnd, int curr) |
|
350 | 349 |
{ |
351 | 350 |
int layer, nextAngle; |
352 | 351 |
|
... | ... | |
415 | 414 |
ScrambleStateBandagedCuboid currState = mBandagedStates.get(curr); |
416 | 415 |
int indexExcluded = curr>0 ? scramble[curr-1][0] : ScrambleStateBandagedCuboid.AXIS_NONE; |
417 | 416 |
int numMoves = currState.numMoves(indexExcluded); |
417 |
ObjectSignature signature; |
|
418 | 418 |
|
419 | 419 |
if( numMoves==0 ) |
420 | 420 |
{ |
... | ... | |
427 | 427 |
scramble[curr][0] = 0; |
428 | 428 |
scramble[curr][1] = 0; |
429 | 429 |
scramble[curr][2] = 0; |
430 |
signature = currState.getSignature(); |
|
430 | 431 |
} |
431 | 432 |
else |
432 | 433 |
{ |
433 | 434 |
int randMove = rnd.nextInt(numMoves); |
434 | 435 |
int moveIndex = currState.getNthMove(randMove,indexExcluded); |
435 |
mSignature = currState.getMove(moveIndex);
|
|
436 |
signature = currState.getMove(moveIndex);
|
|
436 | 437 |
currState.fillOutScramble(scramble[curr],moveIndex); |
437 | 438 |
} |
438 | 439 |
|
439 |
ScrambleStateBandagedCuboid nextState = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], mSignature);
|
|
440 |
ScrambleStateBandagedCuboid nextState = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], signature);
|
|
440 | 441 |
mBandagedStates.add(nextState); |
441 | 442 |
} |
442 | 443 |
|
... | ... | |
471 | 472 |
|
472 | 473 |
int randMove = rnd.nextInt(numMoves); |
473 | 474 |
int moveIndex = currState.getNthMove(randMove,indexExcluded); |
474 |
mSignature = currState.getMove(moveIndex);
|
|
475 |
ObjectSignature signature = currState.getMove(moveIndex);
|
|
475 | 476 |
currState.fillOutScramble(scramble[curr],moveIndex); |
476 | 477 |
|
477 |
ScrambleStateBandagedCuboid nextState = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], mSignature);
|
|
478 |
ScrambleStateBandagedCuboid nextState = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], signature);
|
|
478 | 479 |
mBandagedStates.add(nextState); |
479 | 480 |
|
480 | 481 |
return true; |
... | ... | |
483 | 484 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
484 | 485 |
// TYPE 2 |
485 | 486 |
|
486 |
private void initializeType2Scrambling(int[][] scramble, Random rnd, int total) |
|
487 |
private void initializeType2Scrambling(int[][] scramble, Random rnd, int total, ObjectSignature signature)
|
|
487 | 488 |
{ |
488 | 489 |
if( mBandagedStates==null ) mBandagedStates = new ArrayList<>(); |
489 | 490 |
else mBandagedStates.clear(); |
490 | 491 |
|
491 |
ScrambleStateBandagedCuboid state = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], mSignature);
|
|
492 |
ScrambleStateBandagedCuboid state = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], signature);
|
|
492 | 493 |
mBandagedStates.add(state); |
493 | 494 |
boolean success = true; |
494 | 495 |
|
... | ... | |
505 | 506 |
if( !success ) |
506 | 507 |
{ |
507 | 508 |
mBandagedStates.clear(); |
508 |
state = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], mSignature);
|
|
509 |
state = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], signature);
|
|
509 | 510 |
mBandagedStates.add(state); |
510 | 511 |
|
511 | 512 |
for(int curr=0; curr<total; curr++) |
... | ... | |
515 | 516 |
} |
516 | 517 |
} |
517 | 518 |
|
518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
519 |
// TYPE 2 |
|
520 |
|
|
521 |
public static void setSignature(ObjectSignature signature) |
|
522 |
{ |
|
523 |
mSignature = signature; |
|
524 |
} |
|
525 |
|
|
526 | 519 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
527 | 520 |
// TYPE 2 (locally-created bandaged cuboids) |
528 | 521 |
|
529 |
private void randomizeNewScramble2(int[][] scramble, Random rnd, int curr, int total) |
|
522 |
private void randomizeNewScramble2(int[][] scramble, Random rnd, int curr, int total, ObjectSignature signature)
|
|
530 | 523 |
{ |
531 |
if( curr==0 ) initializeType2Scrambling(scramble,rnd,total); |
|
524 |
if( curr==0 ) initializeType2Scrambling(scramble,rnd,total,signature);
|
|
532 | 525 |
} |
533 | 526 |
|
534 | 527 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
535 | 528 |
// PUBLIC API |
536 | 529 |
|
537 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
530 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total, ObjectSignature signature)
|
|
538 | 531 |
{ |
539 |
if( mType==0 ) randomizeNewScramble0(scramble, rnd, curr, total); |
|
540 |
if( mType==1 ) randomizeNewScramble1(scramble, rnd, curr, total); |
|
541 |
if( mType==2 ) randomizeNewScramble2(scramble, rnd, curr, total); |
|
532 |
switch(mType) |
|
533 |
{ |
|
534 |
case 0: randomizeNewScramble0(scramble, rnd, curr); break; |
|
535 |
case 1: randomizeNewScramble1(scramble, rnd, curr); break; |
|
536 |
case 2: randomizeNewScramble2(scramble, rnd, curr, total, signature); break; |
|
537 |
} |
|
542 | 538 |
} |
543 | 539 |
} |
Also available in: Unified diff
Improve scrambling locally-produced bandaged cuboid.