Revision bbc6471c
Added by Leszek Koltunski over 4 years ago
| src/main/java/org/distorted/objects/TwistyBandaged2Bar.java | ||
|---|---|---|
| 29 | 29 |
|
| 30 | 30 |
import java.util.Random; |
| 31 | 31 |
|
| 32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
| 33 |
|
|
| 34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 35 | 33 |
|
| 36 | 34 |
class TwistyBandaged2Bar extends TwistyBandagedAbstract |
| ... | ... | |
| 102 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 103 | 101 |
// PUBLIC API |
| 104 | 102 |
// TODO |
| 105 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
| 106 |
{
|
|
| 107 |
int numAxis = ROTATION_AXIS.length; |
|
| 108 | 103 |
|
| 109 |
if( oldRotAxis == START_AXIS ) |
|
| 104 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
| 105 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
| 106 |
{
|
|
| 107 |
if( numScramble==1 ) |
|
| 110 | 108 |
{
|
| 111 |
return rnd.nextInt(numAxis);
|
|
| 109 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
| 112 | 110 |
} |
| 113 | 111 |
else |
| 114 | 112 |
{
|
| 115 |
int newVector = rnd.nextInt(numAxis-1);
|
|
| 116 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
| 113 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
| 114 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
| 117 | 115 |
} |
| 118 |
} |
|
| 119 | 116 |
|
| 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 121 |
// TODO |
|
| 122 |
|
|
| 123 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
| 124 |
{
|
|
| 125 | 117 |
float rowFloat = rnd.nextFloat(); |
| 126 | 118 |
|
| 127 | 119 |
for(int row=0; row<mRowChances.length; row++) |
| 128 | 120 |
{
|
| 129 |
if( rowFloat<=mRowChances[row] ) return row; |
|
| 121 |
if( rowFloat<=mRowChances[row] ) |
|
| 122 |
{
|
|
| 123 |
scramble[1] = row; |
|
| 124 |
break; |
|
| 125 |
} |
|
| 130 | 126 |
} |
| 131 | 127 |
|
| 132 |
return 0; |
|
| 128 |
int random = rnd.nextInt(remScrambles); |
|
| 129 |
int result = random<remDoubleScrambles ? 2:1; |
|
| 130 |
int sign = rnd.nextInt(2); |
|
| 131 |
|
|
| 132 |
scramble[2] = sign==0 ? result : -result; |
|
| 133 | 133 |
} |
| 134 | 134 |
|
| 135 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.