Revision bbc6471c
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
import java.util.Random; |
35 | 35 |
|
36 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
37 |
|
|
38 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 37 |
|
40 | 38 |
class TwistyCube extends TwistyObject |
... | ... | |
256 | 254 |
|
257 | 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
258 | 256 |
|
259 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
257 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
258 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
260 | 259 |
{ |
261 |
int numAxis = ROTATION_AXIS.length; |
|
262 |
|
|
263 |
if( oldRotAxis == START_AXIS ) |
|
260 |
if( numScramble==1 ) |
|
264 | 261 |
{ |
265 |
return rnd.nextInt(numAxis);
|
|
262 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
266 | 263 |
} |
267 | 264 |
else |
268 | 265 |
{ |
269 |
int newVector = rnd.nextInt(numAxis-1);
|
|
270 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
266 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
267 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
271 | 268 |
} |
272 |
} |
|
273 |
|
|
274 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
275 | 269 |
|
276 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
277 |
{ |
|
278 | 270 |
float rowFloat = rnd.nextFloat(); |
279 | 271 |
|
280 | 272 |
for(int row=0; row<mRowChances.length; row++) |
281 | 273 |
{ |
282 |
if( rowFloat<=mRowChances[row] ) return row; |
|
274 |
if( rowFloat<=mRowChances[row] ) |
|
275 |
{ |
|
276 |
scramble[1] = row; |
|
277 |
break; |
|
278 |
} |
|
283 | 279 |
} |
284 | 280 |
|
285 |
return 0; |
|
281 |
int random = rnd.nextInt(remScrambles); |
|
282 |
int result = random<remDoubleScrambles ? 2:1; |
|
283 |
int sign = rnd.nextInt(2); |
|
284 |
|
|
285 |
scramble[2] = sign==0 ? result : -result; |
|
286 | 286 |
} |
287 | 287 |
|
288 | 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.