Revision 5043d5d0
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
335 | 335 |
|
336 | 336 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
337 | 337 |
|
338 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
339 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
338 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num) |
|
340 | 339 |
{ |
341 |
if( numScramble==1 )
|
|
340 |
if( num==0 )
|
|
342 | 341 |
{ |
343 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
342 |
scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
344 | 343 |
} |
345 | 344 |
else |
346 | 345 |
{ |
347 | 346 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-2); |
348 | 347 |
|
349 |
switch(oldRotAxis)
|
|
348 |
switch(scramble[num-1][0])
|
|
350 | 349 |
{ |
351 | 350 |
case 0: |
352 |
case 1: scramble[0] = newVector+2; |
|
351 |
case 1: scramble[num][0] = newVector+2;
|
|
353 | 352 |
break; |
354 | 353 |
case 2: |
355 |
case 3: scramble[0] = (newVector==0 || newVector==1) ? newVector:newVector+2; |
|
354 |
case 3: scramble[num][0] = (newVector==0 || newVector==1) ? newVector:newVector+2;
|
|
356 | 355 |
break; |
357 |
default: scramble[0] = newVector; |
|
356 |
default: scramble[num][0] = newVector;
|
|
358 | 357 |
break; |
359 | 358 |
} |
360 | 359 |
} |
... | ... | |
365 | 364 |
{ |
366 | 365 |
if( rowFloat<=mRowChances[row] ) |
367 | 366 |
{ |
368 |
scramble[1] = row; |
|
367 |
scramble[num][1] = row;
|
|
369 | 368 |
break; |
370 | 369 |
} |
371 | 370 |
} |
372 | 371 |
|
373 |
int random = rnd.nextInt(remScrambles);
|
|
374 |
int result = random<remDoubleScrambles ? 2:1;
|
|
375 |
int sign = rnd.nextInt(2);
|
|
376 |
|
|
377 |
scramble[2] = sign==0 ? result : -result;
|
|
372 |
switch( rnd.nextInt(2) )
|
|
373 |
{
|
|
374 |
case 0: scramble[num][2] = -1; break;
|
|
375 |
case 1: scramble[num][2] = 1; break; |
|
376 |
}
|
|
378 | 377 |
} |
379 | 378 |
|
380 | 379 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.