Revision 5043d5d0
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
254 | 254 |
|
255 | 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
256 | 256 |
|
257 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
258 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
257 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num) |
|
259 | 258 |
{ |
260 |
if( numScramble==1 )
|
|
259 |
if( num==0 )
|
|
261 | 260 |
{ |
262 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
261 |
scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
263 | 262 |
} |
264 | 263 |
else |
265 | 264 |
{ |
266 | 265 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1); |
267 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
266 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
268 | 267 |
} |
269 | 268 |
|
270 | 269 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
273 | 272 |
{ |
274 | 273 |
if( rowFloat<=mRowChances[row] ) |
275 | 274 |
{ |
276 |
scramble[1] = row; |
|
275 |
scramble[num][1] = row;
|
|
277 | 276 |
break; |
278 | 277 |
} |
279 | 278 |
} |
280 | 279 |
|
281 |
int random = rnd.nextInt(remScrambles); |
|
282 |
int result = random<remDoubleScrambles ? 2:1; |
|
283 |
int sign = rnd.nextInt(2); |
|
284 |
|
|
285 |
scramble[2] = sign==0 ? result : -result; |
|
280 |
switch( rnd.nextInt(4) ) |
|
281 |
{ |
|
282 |
case 0: scramble[num][2] = -2; break; |
|
283 |
case 1: scramble[num][2] = -1; break; |
|
284 |
case 2: scramble[num][2] = 1; break; |
|
285 |
case 3: scramble[num][2] = 2; break; |
|
286 |
} |
|
286 | 287 |
} |
287 | 288 |
|
288 | 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.