Revision 5043d5d0
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
539 | 539 |
|
540 | 540 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
541 | 541 |
|
542 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
543 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
542 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num) |
|
544 | 543 |
{ |
545 |
if( numScramble==1 )
|
|
544 |
if( num==0 )
|
|
546 | 545 |
{ |
547 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
546 |
scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
548 | 547 |
} |
549 | 548 |
else |
550 | 549 |
{ |
551 | 550 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1); |
552 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
551 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
553 | 552 |
} |
554 | 553 |
|
555 | 554 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
558 | 557 |
{ |
559 | 558 |
if( rowFloat<=mRowChances[row] ) |
560 | 559 |
{ |
561 |
scramble[1] = row; |
|
560 |
scramble[num][1] = row;
|
|
562 | 561 |
break; |
563 | 562 |
} |
564 | 563 |
} |
565 | 564 |
|
566 |
int random = rnd.nextInt(remScrambles);
|
|
567 |
int result = random<remDoubleScrambles ? 2:1;
|
|
568 |
int sign = rnd.nextInt(2);
|
|
569 |
|
|
570 |
scramble[2] = sign==0 ? result : -result;
|
|
565 |
switch( rnd.nextInt(2) )
|
|
566 |
{
|
|
567 |
case 0: scramble[num][2] = -1; break;
|
|
568 |
case 1: scramble[num][2] = 1; break; |
|
569 |
}
|
|
571 | 570 |
} |
572 | 571 |
|
573 | 572 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Refactor the automatic scrambling. From now on, it is not needed to care about single and double turns when randomizing a new turn.