Revision 8e6dc249
Added by Leszek Koltunski over 4 years ago
| src/main/java/org/distorted/objects/TwistyCube.java | ||
|---|---|---|
| 307 | 307 |
} |
| 308 | 308 |
else |
| 309 | 309 |
{
|
| 310 |
int newVector = rnd.nextInt(NUM_AXIS -1);
|
|
| 310 |
int newVector = rnd.nextInt(NUM_AXIS-1); |
|
| 311 | 311 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
| 312 |
|
|
| 313 |
// All three axis must be present among every four consecutive rotations. |
|
| 314 |
// Otherwise in case of odd-sized cubes we can get four consecutive rotations |
|
| 315 |
// that collapse to a NOP |
|
| 316 |
// (X,midLayer,180)->(Y,midLayer,180)->(X,midLayer,180)->(Y,midLayer,180) = NOP |
|
| 317 |
if( curr>=3 && scramble[curr-1][0]==scramble[curr-3][0] ) |
|
| 318 |
{
|
|
| 319 |
for( int ax=0; ax<NUM_AXIS; ax++) |
|
| 320 |
{
|
|
| 321 |
if( scramble[curr-1][0]!=ax && scramble[curr-2][0]!=ax ) |
|
| 322 |
{
|
|
| 323 |
scramble[curr][0] = ax; |
|
| 324 |
break; |
|
| 325 |
} |
|
| 326 |
} |
|
| 327 |
} |
|
| 312 | 328 |
} |
| 313 | 329 |
|
| 314 | 330 |
float rowFloat = rnd.nextFloat(); |
Also available in: Unified diff
Correct rotations of the Cube - eliminate one cse when four consecutive rotations collapse into one or a NOP.