Revision bbc6471c
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyMinx.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 |
abstract class TwistyMinx extends TwistyObject |
... | ... | |
282 | 280 |
|
283 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
284 | 282 |
|
285 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
283 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
284 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
286 | 285 |
{ |
287 |
int numAxis = ROTATION_AXIS.length; |
|
288 |
|
|
289 |
if( oldRotAxis == START_AXIS ) |
|
286 |
if( numScramble==1 ) |
|
290 | 287 |
{ |
291 |
return rnd.nextInt(numAxis);
|
|
288 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
292 | 289 |
} |
293 | 290 |
else |
294 | 291 |
{ |
295 |
int newVector = rnd.nextInt(numAxis-1);
|
|
296 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
292 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
293 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
297 | 294 |
} |
298 |
} |
|
299 |
|
|
300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
301 | 295 |
|
302 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
303 |
{ |
|
304 |
if( oldRotAxis<0 ) |
|
296 |
if( numScramble==1 ) |
|
305 | 297 |
{ |
306 | 298 |
float rowFloat = rnd.nextFloat(); |
307 | 299 |
|
308 | 300 |
for(int row=0; row<mRowChances.length; row++) |
309 | 301 |
{ |
310 |
if( rowFloat<=mRowChances[row] ) return row; |
|
302 |
if( rowFloat<=mRowChances[row] ) |
|
303 |
{ |
|
304 |
scramble[1] = row; |
|
305 |
break; |
|
306 |
} |
|
311 | 307 |
} |
312 |
|
|
313 |
return 0; |
|
314 | 308 |
} |
315 | 309 |
else |
316 | 310 |
{ |
317 | 311 |
int size = mRowChances.length; |
318 | 312 |
int num = (size-1)/2; |
319 | 313 |
int row = rnd.nextInt(num); |
320 |
boolean opposite = OPPOSITE_ROWS[oldRotAxis][newRotAxis];
|
|
314 |
boolean opposite = OPPOSITE_ROWS[oldRotAxis][scramble[0]];
|
|
321 | 315 |
boolean low = opposite^(oldRow<num); |
322 |
return low ? row : size-1-row;
|
|
316 |
scramble[1] = low ? row : size-1-row;
|
|
323 | 317 |
} |
318 |
|
|
319 |
int random = rnd.nextInt(remScrambles); |
|
320 |
int result = random<remDoubleScrambles ? 2:1; |
|
321 |
int sign = rnd.nextInt(2); |
|
322 |
|
|
323 |
scramble[2] = sign==0 ? result : -result; |
|
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.