Revision 5043d5d0
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyMinx.java | ||
---|---|---|
280 | 280 |
|
281 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
282 | 282 |
|
283 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
284 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
283 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num) |
|
285 | 284 |
{ |
286 |
if( numScramble==1 )
|
|
285 |
if( num==0 )
|
|
287 | 286 |
{ |
288 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
287 |
scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
289 | 288 |
} |
290 | 289 |
else |
291 | 290 |
{ |
292 | 291 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1); |
293 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
292 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
294 | 293 |
} |
295 | 294 |
|
296 |
if( numScramble==1 )
|
|
295 |
if( num==0 )
|
|
297 | 296 |
{ |
298 | 297 |
float rowFloat = rnd.nextFloat(); |
299 | 298 |
|
... | ... | |
301 | 300 |
{ |
302 | 301 |
if( rowFloat<=mRowChances[row] ) |
303 | 302 |
{ |
304 |
scramble[1] = row; |
|
303 |
scramble[num][1] = row;
|
|
305 | 304 |
break; |
306 | 305 |
} |
307 | 306 |
} |
... | ... | |
309 | 308 |
else |
310 | 309 |
{ |
311 | 310 |
int size = mRowChances.length; |
312 |
int num = (size-1)/2;
|
|
313 |
int row = rnd.nextInt(num);
|
|
314 |
boolean opposite = OPPOSITE_ROWS[oldRotAxis][scramble[0]];
|
|
315 |
boolean low = opposite^(oldRow<num);
|
|
316 |
scramble[1] = low ? row : size-1-row; |
|
311 |
int nom = (size-1)/2;
|
|
312 |
int row = rnd.nextInt(nom);
|
|
313 |
boolean opposite = OPPOSITE_ROWS[scramble[num-1][0]][scramble[num][0]];
|
|
314 |
boolean low = opposite^(scramble[num-1][1]<nom);
|
|
315 |
scramble[num][1] = low ? row : size-1-row;
|
|
317 | 316 |
} |
318 | 317 |
|
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; |
|
318 |
switch( rnd.nextInt(4) ) |
|
319 |
{ |
|
320 |
case 0: scramble[num][2] = -2; break; |
|
321 |
case 1: scramble[num][2] = -1; break; |
|
322 |
case 2: scramble[num][2] = 1; break; |
|
323 |
case 3: scramble[num][2] = 2; break; |
|
324 |
} |
|
324 | 325 |
} |
325 | 326 |
|
326 | 327 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.