Revision 5043d5d0
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
281 | 281 |
|
282 | 282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
283 | 283 |
|
284 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
285 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
284 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num) |
|
286 | 285 |
{ |
287 |
if( numScramble==1 )
|
|
286 |
if( num==0 )
|
|
288 | 287 |
{ |
289 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
288 |
scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
290 | 289 |
} |
291 | 290 |
else |
292 | 291 |
{ |
293 | 292 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1); |
294 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
293 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
295 | 294 |
} |
296 | 295 |
|
297 | 296 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
300 | 299 |
{ |
301 | 300 |
if( rowFloat<=mRowChances[row] ) |
302 | 301 |
{ |
303 |
scramble[1] = row; |
|
302 |
scramble[num][1] = row;
|
|
304 | 303 |
break; |
305 | 304 |
} |
306 | 305 |
} |
307 | 306 |
|
308 |
int random = rnd.nextInt(remScrambles);
|
|
309 |
int result = random<remDoubleScrambles ? 2:1;
|
|
310 |
int sign = rnd.nextInt(2);
|
|
311 |
|
|
312 |
scramble[2] = sign==0 ? result : -result;
|
|
307 |
switch( rnd.nextInt(2) )
|
|
308 |
{
|
|
309 |
case 0: scramble[num][2] = -1; break;
|
|
310 |
case 1: scramble[num][2] = 1; break; |
|
311 |
}
|
|
313 | 312 |
} |
314 | 313 |
|
315 | 314 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.