Revision 91792184
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
---|---|---|
30 | 30 |
import org.distorted.library.type.Static3D; |
31 | 31 |
import org.distorted.library.type.Static4D; |
32 | 32 |
|
33 |
import java.util.Random; |
|
34 |
|
|
35 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 34 |
|
37 | 35 |
abstract class TwistyBandagedAbstract extends TwistyObject |
... | ... | |
63 | 61 |
private static final int NUM_STICKERS = 4; |
64 | 62 |
|
65 | 63 |
private int[] mBasicAngle; |
66 |
private int mCurrState; |
|
67 |
private int mIndexExcluded; |
|
68 |
private int[][] mScrambleTable; |
|
69 |
private int[] mNumOccurences; |
|
70 | 64 |
private Static4D[] mQuats; |
71 | 65 |
private ObjectSticker[] mStickers; |
72 | 66 |
private Static4D[] mInitQuats; |
... | ... | |
466 | 460 |
return getNumLayers(); |
467 | 461 |
} |
468 | 462 |
|
469 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
470 |
|
|
471 |
private void initializeScrambling() |
|
472 |
{ |
|
473 |
int numLayers = getNumLayers(); |
|
474 |
|
|
475 |
if( mScrambleTable ==null ) |
|
476 |
{ |
|
477 |
mScrambleTable = new int[NUM_AXIS][numLayers]; |
|
478 |
} |
|
479 |
if( mNumOccurences ==null ) |
|
480 |
{ |
|
481 |
int max=0; |
|
482 |
|
|
483 |
for (ScrambleState mState : mStates) |
|
484 |
{ |
|
485 |
int tmp = mState.getTotal(-1); |
|
486 |
if (max < tmp) max = tmp; |
|
487 |
} |
|
488 |
|
|
489 |
mNumOccurences = new int[max]; |
|
490 |
} |
|
491 |
|
|
492 |
for(int i=0; i<NUM_AXIS; i++) |
|
493 |
for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0; |
|
494 |
} |
|
495 |
|
|
496 | 463 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
497 | 464 |
// PUBLIC API |
498 | 465 |
|
499 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles) |
|
500 |
{ |
|
501 |
if( curr==0 ) |
|
502 |
{ |
|
503 |
mCurrState = 0; |
|
504 |
mIndexExcluded =-1; |
|
505 |
initializeScrambling(); |
|
506 |
} |
|
507 |
|
|
508 |
int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences); |
|
509 |
|
|
510 |
scramble[curr][0] = info[0]; |
|
511 |
scramble[curr][1] = info[1]; |
|
512 |
scramble[curr][2] = info[2]; |
|
513 |
|
|
514 |
mCurrState = info[3]; |
|
515 |
mIndexExcluded = info[0]; |
|
516 |
} |
|
517 |
|
|
518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
519 |
|
|
520 | 466 |
public Static3D[] getRotationAxis() |
521 | 467 |
{ |
522 | 468 |
return ROT_AXIS; |
Also available in: Unified diff
Make object scrambling abstract (well, almost - with exception of Square-1 - this theoretically could also be done the generic way, but this would require almost 20000 'ScrambleStates')