Revision bbc6471c
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
import java.util.Random; |
36 | 36 |
|
37 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
38 |
|
|
39 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 38 |
|
41 | 39 |
public class TwistyRedi extends TwistyObject |
... | ... | |
330 | 328 |
|
331 | 329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
332 | 330 |
|
333 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
331 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
332 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
334 | 333 |
{ |
335 |
int numAxis = ROTATION_AXIS.length; |
|
336 |
|
|
337 |
if( oldRotAxis == START_AXIS ) |
|
334 |
if( numScramble==1 ) |
|
338 | 335 |
{ |
339 |
return rnd.nextInt(numAxis);
|
|
336 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
340 | 337 |
} |
341 | 338 |
else |
342 | 339 |
{ |
343 |
int newVector = rnd.nextInt(numAxis-1);
|
|
344 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
340 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
341 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
345 | 342 |
} |
346 |
} |
|
347 | 343 |
|
348 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
344 |
scramble[1] = (numScramble==1) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+scramble[0]==3 ? 2-oldRow : oldRow);
|
|
349 | 345 |
|
350 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
351 |
{ |
|
352 |
return (oldRotAxis==START_AXIS) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+newRotAxis==3 ? 2-oldRow : oldRow); |
|
346 |
int random = rnd.nextInt(remScrambles); |
|
347 |
int result = random<remDoubleScrambles ? 2:1; |
|
348 |
int sign = rnd.nextInt(2); |
|
349 |
|
|
350 |
scramble[2] = sign==0 ? result : -result; |
|
353 | 351 |
} |
354 | 352 |
|
355 | 353 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.