Revision 9f171eba
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/effects/scramble/ScrambleEffect.java | ||
---|---|---|
104 | 104 |
|
105 | 105 |
for(int scramble=0; scramble<mNumScramblesLeft; scramble++) |
106 | 106 |
{ |
107 |
mObject.randomizeNewScramble(mScrambles, mRnd, scramble); |
|
107 |
mObject.randomizeNewScramble(mScrambles, mRnd, scramble, numScrambles);
|
|
108 | 108 |
axis = mScrambles[scramble][0]; |
109 | 109 |
angle = mScrambles[scramble][2]; |
110 | 110 |
absAngle = (angle<0 ? -angle : angle); |
src/main/java/org/distorted/objects/TwistyBandaged2Bar.java | ||
---|---|---|
86 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 87 |
// PUBLIC API |
88 | 88 |
|
89 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
89 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
90 | 90 |
{ |
91 |
if( num==0 )
|
|
91 |
if( curr==0 )
|
|
92 | 92 |
{ |
93 | 93 |
int random = rnd.nextInt(4); |
94 | 94 |
|
95 |
scramble[num][0] = 1;
|
|
96 |
scramble[num][1] = random>1 ? 2:0;
|
|
97 |
scramble[num][2] = random%2 == 0 ? -1:1;
|
|
95 |
scramble[curr][0] = 1;
|
|
96 |
scramble[curr][1] = random>1 ? 2:0;
|
|
97 |
scramble[curr][2] = random%2 == 0 ? -1:1;
|
|
98 | 98 |
} |
99 | 99 |
else |
100 | 100 |
{ |
101 |
boolean even = ((num%2) == 0);
|
|
101 |
boolean even = ((curr%2) == 0);
|
|
102 | 102 |
int angle = rnd.nextInt(4); |
103 | 103 |
|
104 |
scramble[num][0] = even ? 1 : scramble[0][1];
|
|
105 |
scramble[num][1] = rnd.nextInt(3);
|
|
104 |
scramble[curr][0] = even ? 1 : scramble[0][1];
|
|
105 |
scramble[curr][1] = rnd.nextInt(3);
|
|
106 | 106 |
|
107 |
if( even == (scramble[num][1]==1) )
|
|
107 |
if( even == (scramble[curr][1]==1) )
|
|
108 | 108 |
{ |
109 | 109 |
switch(angle) |
110 | 110 |
{ |
111 |
case 0: scramble[num][2] = -2; break;
|
|
112 |
case 1: scramble[num][2] = -1; break;
|
|
113 |
case 2: scramble[num][2] = 1; break;
|
|
114 |
case 3: scramble[num][2] = 2; break;
|
|
111 |
case 0: scramble[curr][2] = -2; break;
|
|
112 |
case 1: scramble[curr][2] = -1; break;
|
|
113 |
case 2: scramble[curr][2] = 1; break;
|
|
114 |
case 3: scramble[curr][2] = 2; break;
|
|
115 | 115 |
} |
116 | 116 |
} |
117 | 117 |
else |
118 | 118 |
{ |
119 |
scramble[num][2] = angle>1 ? 2:-2;
|
|
119 |
scramble[curr][2] = angle>1 ? 2:-2;
|
|
120 | 120 |
} |
121 | 121 |
} |
122 | 122 |
} |
src/main/java/org/distorted/objects/TwistyBandaged3Plate.java | ||
---|---|---|
122 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
123 | 123 |
// PUBLIC API |
124 | 124 |
|
125 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
125 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
126 | 126 |
{ |
127 |
if( num==0 )
|
|
127 |
if( curr==0 )
|
|
128 | 128 |
{ |
129 | 129 |
mCurrState = 0; |
130 | 130 |
mUseX = true; |
... | ... | |
136 | 136 |
int random= rnd.nextInt(total); |
137 | 137 |
int[] info= mStates[mCurrState].getInfo(random,mUseX,mUseY,mUseZ); |
138 | 138 |
|
139 |
scramble[num][0] = info[0];
|
|
140 |
scramble[num][1] = info[1];
|
|
141 |
scramble[num][2] = info[2];
|
|
139 |
scramble[curr][0] = info[0];
|
|
140 |
scramble[curr][1] = info[1];
|
|
141 |
scramble[curr][2] = info[2];
|
|
142 | 142 |
|
143 | 143 |
mCurrState = info[3]; |
144 | 144 |
|
src/main/java/org/distorted/objects/TwistyBandagedEvil.java | ||
---|---|---|
237 | 237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
238 | 238 |
// PUBLIC API |
239 | 239 |
|
240 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
240 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
241 | 241 |
{ |
242 |
if( num==0 )
|
|
242 |
if( curr==0 )
|
|
243 | 243 |
{ |
244 | 244 |
mCurrState = 0; |
245 | 245 |
mUseX = true; |
... | ... | |
251 | 251 |
int random= rnd.nextInt(total); |
252 | 252 |
int[] info= mStates[mCurrState].getInfo(random,mUseX,mUseY,mUseZ); |
253 | 253 |
|
254 |
scramble[num][0] = info[0];
|
|
255 |
scramble[num][1] = info[1];
|
|
256 |
scramble[num][2] = info[2];
|
|
254 |
scramble[curr][0] = info[0];
|
|
255 |
scramble[curr][1] = info[1];
|
|
256 |
scramble[curr][2] = info[2];
|
|
257 | 257 |
|
258 | 258 |
mCurrState = info[3]; |
259 | 259 |
|
src/main/java/org/distorted/objects/TwistyBandagedFused.java | ||
---|---|---|
90 | 90 |
|
91 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
92 | 92 |
|
93 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
93 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
94 | 94 |
{ |
95 |
if( num==0 )
|
|
95 |
if( curr==0 )
|
|
96 | 96 |
{ |
97 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
97 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
98 | 98 |
} |
99 | 99 |
else |
100 | 100 |
{ |
101 | 101 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
102 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
102 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
109 | 109 |
{ |
110 | 110 |
if( rowFloat*numLayers <= row+1 ) |
111 | 111 |
{ |
112 |
scramble[num][1] = row;
|
|
112 |
scramble[curr][1] = row;
|
|
113 | 113 |
break; |
114 | 114 |
} |
115 | 115 |
} |
116 | 116 |
|
117 | 117 |
switch( rnd.nextInt(4) ) |
118 | 118 |
{ |
119 |
case 0: scramble[num][2] = -2; break;
|
|
120 |
case 1: scramble[num][2] = -1; break;
|
|
121 |
case 2: scramble[num][2] = 1; break;
|
|
122 |
case 3: scramble[num][2] = 2; break;
|
|
119 |
case 0: scramble[curr][2] = -2; break;
|
|
120 |
case 1: scramble[curr][2] = -1; break;
|
|
121 |
case 2: scramble[curr][2] = 1; break;
|
|
122 |
case 3: scramble[curr][2] = 2; break;
|
|
123 | 123 |
} |
124 | 124 |
} |
125 | 125 |
|
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
299 | 299 |
|
300 | 300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
301 | 301 |
|
302 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
302 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
303 | 303 |
{ |
304 |
if( num==0 )
|
|
304 |
if( curr==0 )
|
|
305 | 305 |
{ |
306 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
306 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
307 | 307 |
} |
308 | 308 |
else |
309 | 309 |
{ |
310 | 310 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
311 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
311 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
312 | 312 |
} |
313 | 313 |
|
314 | 314 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
318 | 318 |
{ |
319 | 319 |
if( rowFloat*numLayers <= row+1 ) |
320 | 320 |
{ |
321 |
scramble[num][1] = row;
|
|
321 |
scramble[curr][1] = row;
|
|
322 | 322 |
break; |
323 | 323 |
} |
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
switch( rnd.nextInt(4) ) |
327 | 327 |
{ |
328 |
case 0: scramble[num][2] = -2; break;
|
|
329 |
case 1: scramble[num][2] = -1; break;
|
|
330 |
case 2: scramble[num][2] = 1; break;
|
|
331 |
case 3: scramble[num][2] = 2; break;
|
|
328 |
case 0: scramble[curr][2] = -2; break;
|
|
329 |
case 1: scramble[curr][2] = -1; break;
|
|
330 |
case 2: scramble[curr][2] = 1; break;
|
|
331 |
case 3: scramble[curr][2] = 2; break;
|
|
332 | 332 |
} |
333 | 333 |
} |
334 | 334 |
|
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
522 | 522 |
|
523 | 523 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
524 | 524 |
|
525 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
525 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
526 | 526 |
{ |
527 |
if( num==0 )
|
|
527 |
if( curr==0 )
|
|
528 | 528 |
{ |
529 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
529 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
530 | 530 |
} |
531 | 531 |
else |
532 | 532 |
{ |
533 | 533 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
534 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
534 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
535 | 535 |
} |
536 | 536 |
|
537 | 537 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
541 | 541 |
{ |
542 | 542 |
if( rowFloat*numLayers <= row+1 ) |
543 | 543 |
{ |
544 |
scramble[num][1] = row;
|
|
544 |
scramble[curr][1] = row;
|
|
545 | 545 |
break; |
546 | 546 |
} |
547 | 547 |
} |
548 | 548 |
|
549 | 549 |
switch( rnd.nextInt(2) ) |
550 | 550 |
{ |
551 |
case 0: scramble[num][2] = -1; break;
|
|
552 |
case 1: scramble[num][2] = 1; break;
|
|
551 |
case 0: scramble[curr][2] = -1; break;
|
|
552 |
case 1: scramble[curr][2] = 1; break;
|
|
553 | 553 |
} |
554 | 554 |
} |
555 | 555 |
|
src/main/java/org/distorted/objects/TwistyDino4.java | ||
---|---|---|
104 | 104 |
|
105 | 105 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
106 | 106 |
|
107 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
107 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
108 | 108 |
{ |
109 |
if( num==0 )
|
|
109 |
if( curr==0 )
|
|
110 | 110 |
{ |
111 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
112 |
scramble[num][1] = (scramble[num][0]==1 || scramble[num][0]==2) ? 0:2;
|
|
111 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
112 |
scramble[curr][1] = (scramble[curr][0]==1 || scramble[curr][0]==2) ? 0:2;
|
|
113 | 113 |
} |
114 | 114 |
else |
115 | 115 |
{ |
116 | 116 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
117 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
118 |
scramble[num][1] = scramble[num-1][0]+scramble[num][0]==3 ? 2-scramble[num-1][1] : scramble[num-1][1];
|
|
117 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
118 |
scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1];
|
|
119 | 119 |
} |
120 | 120 |
|
121 | 121 |
switch( rnd.nextInt(2) ) |
122 | 122 |
{ |
123 |
case 0: scramble[num][2] = -1; break;
|
|
124 |
case 1: scramble[num][2] = 1; break;
|
|
123 |
case 0: scramble[curr][2] = -1; break;
|
|
124 |
case 1: scramble[curr][2] = 1; break;
|
|
125 | 125 |
} |
126 | 126 |
} |
127 | 127 |
|
src/main/java/org/distorted/objects/TwistyDino6.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
68 | 68 |
|
69 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
69 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
70 | 70 |
{ |
71 |
if( num==0 )
|
|
71 |
if( curr==0 )
|
|
72 | 72 |
{ |
73 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
74 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0:2;
|
|
73 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
74 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0:2;
|
|
75 | 75 |
} |
76 | 76 |
else |
77 | 77 |
{ |
78 | 78 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
79 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
80 |
scramble[num][1] = scramble[num-1][0]+scramble[num][0]==3 ? 2-scramble[num-1][1] : scramble[num-1][1];
|
|
79 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
80 |
scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1];
|
|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
switch( rnd.nextInt(2) ) |
84 | 84 |
{ |
85 |
case 0: scramble[num][2] = -1; break;
|
|
86 |
case 1: scramble[num][2] = 1; break;
|
|
85 |
case 0: scramble[curr][2] = -1; break;
|
|
86 |
case 1: scramble[curr][2] = 1; break;
|
|
87 | 87 |
} |
88 | 88 |
} |
89 | 89 |
|
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
408 | 408 |
|
409 | 409 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
410 | 410 |
|
411 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
411 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
412 | 412 |
{ |
413 |
if( num==0 )
|
|
413 |
if( curr==0 )
|
|
414 | 414 |
{ |
415 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
415 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
416 | 416 |
} |
417 | 417 |
else |
418 | 418 |
{ |
419 | 419 |
int newVector = rnd.nextInt(NUM_AXIS -2); |
420 | 420 |
|
421 |
switch(scramble[num-1][0])
|
|
421 |
switch(scramble[curr-1][0])
|
|
422 | 422 |
{ |
423 | 423 |
case 0: |
424 |
case 1: scramble[num][0] = newVector+2;
|
|
424 |
case 1: scramble[curr][0] = newVector+2;
|
|
425 | 425 |
break; |
426 | 426 |
case 2: |
427 |
case 3: scramble[num][0] = (newVector==0 || newVector==1) ? newVector:newVector+2;
|
|
427 |
case 3: scramble[curr][0] = (newVector==0 || newVector==1) ? newVector:newVector+2;
|
|
428 | 428 |
break; |
429 |
default: scramble[num][0] = newVector;
|
|
429 |
default: scramble[curr][0] = newVector;
|
|
430 | 430 |
break; |
431 | 431 |
} |
432 | 432 |
} |
433 | 433 |
|
434 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0 : 2;
|
|
434 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 2;
|
|
435 | 435 |
|
436 | 436 |
switch( rnd.nextInt(2) ) |
437 | 437 |
{ |
438 |
case 0: scramble[num][2] = -1; break;
|
|
439 |
case 1: scramble[num][2] = 1; break;
|
|
438 |
case 0: scramble[curr][2] = -1; break;
|
|
439 |
case 1: scramble[curr][2] = 1; break;
|
|
440 | 440 |
} |
441 | 441 |
} |
442 | 442 |
|
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
433 | 433 |
|
434 | 434 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
435 | 435 |
|
436 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
436 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
437 | 437 |
{ |
438 |
if( num==0 )
|
|
438 |
if( curr==0 )
|
|
439 | 439 |
{ |
440 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
440 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
441 | 441 |
} |
442 | 442 |
else |
443 | 443 |
{ |
444 | 444 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
445 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
445 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
446 | 446 |
} |
447 | 447 |
|
448 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0 : 1;
|
|
448 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 1;
|
|
449 | 449 |
|
450 | 450 |
switch( rnd.nextInt(2) ) |
451 | 451 |
{ |
452 |
case 0: scramble[num][2] = -1; break;
|
|
453 |
case 1: scramble[num][2] = 1; break;
|
|
452 |
case 0: scramble[curr][2] = -1; break;
|
|
453 |
case 1: scramble[curr][2] = 1; break;
|
|
454 | 454 |
} |
455 | 455 |
} |
456 | 456 |
|
src/main/java/org/distorted/objects/TwistyMinx.java | ||
---|---|---|
443 | 443 |
|
444 | 444 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
445 | 445 |
|
446 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
446 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
447 | 447 |
{ |
448 | 448 |
int numLayers = getNumLayers(); |
449 | 449 |
int nom = (numLayers-1)/2; |
450 | 450 |
int row = rnd.nextInt(nom); |
451 | 451 |
|
452 |
if( num==0 )
|
|
452 |
if( curr==0 )
|
|
453 | 453 |
{ |
454 | 454 |
int lf = rnd.nextInt(2); |
455 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
456 |
scramble[num][1] = (lf==0 ? row : numLayers-1-row);
|
|
455 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
456 |
scramble[curr][1] = (lf==0 ? row : numLayers-1-row);
|
|
457 | 457 |
} |
458 | 458 |
else |
459 | 459 |
{ |
460 |
boolean opposite = OPPOSITE_ROWS[scramble[num-1][0]][scramble[num][0]];
|
|
461 |
boolean low = opposite^(scramble[num-1][1]<nom);
|
|
460 |
boolean opposite = OPPOSITE_ROWS[scramble[curr-1][0]][scramble[curr][0]];
|
|
461 |
boolean low = opposite^(scramble[curr-1][1]<nom);
|
|
462 | 462 |
int newVector = rnd.nextInt(NUM_AXIS-1); |
463 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
464 |
scramble[num][1] = (low ? row : numLayers-1-row);
|
|
463 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
464 |
scramble[curr][1] = (low ? row : numLayers-1-row);
|
|
465 | 465 |
} |
466 | 466 |
|
467 | 467 |
switch( rnd.nextInt(4) ) |
468 | 468 |
{ |
469 |
case 0: scramble[num][2] = -2; break;
|
|
470 |
case 1: scramble[num][2] = -1; break;
|
|
471 |
case 2: scramble[num][2] = 1; break;
|
|
472 |
case 3: scramble[num][2] = 2; break;
|
|
469 |
case 0: scramble[curr][2] = -2; break;
|
|
470 |
case 1: scramble[curr][2] = -1; break;
|
|
471 |
case 2: scramble[curr][2] = 1; break;
|
|
472 |
case 3: scramble[curr][2] = 2; break;
|
|
473 | 473 |
} |
474 | 474 |
} |
475 | 475 |
|
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
977 | 977 |
public abstract boolean isSolved(); |
978 | 978 |
public abstract int[] getBasicAngle(); |
979 | 979 |
public abstract String retObjectString(); |
980 |
public abstract void randomizeNewScramble(int[][] scramble, Random rnd, int numScramble);
|
|
980 |
public abstract void randomizeNewScramble(int[][] scramble, Random rnd, int curScramble, int totScrambles);
|
|
981 | 981 |
public abstract int getObjectName(int numLayers); |
982 | 982 |
public abstract int getInventor(int numLayers); |
983 | 983 |
public abstract int getComplexity(int numLayers); |
src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
---|---|---|
390 | 390 |
|
391 | 391 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
392 | 392 |
|
393 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
393 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
394 | 394 |
{ |
395 | 395 |
int numLayers = getNumLayers(); |
396 | 396 |
|
397 | 397 |
if( mRowChances==null ) mRowChances = getRowChances(numLayers); |
398 | 398 |
|
399 |
if( num==0 )
|
|
399 |
if( curr==0 )
|
|
400 | 400 |
{ |
401 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
401 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
402 | 402 |
} |
403 | 403 |
else |
404 | 404 |
{ |
405 | 405 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
406 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
406 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
407 | 407 |
} |
408 | 408 |
|
409 | 409 |
float rowFloat = rnd.nextFloat(); |
... | ... | |
412 | 412 |
{ |
413 | 413 |
if( rowFloat<=mRowChances[row] ) |
414 | 414 |
{ |
415 |
scramble[num][1] = row;
|
|
415 |
scramble[curr][1] = row;
|
|
416 | 416 |
break; |
417 | 417 |
} |
418 | 418 |
} |
419 | 419 |
|
420 | 420 |
switch( rnd.nextInt(2) ) |
421 | 421 |
{ |
422 |
case 0: scramble[num][2] = -1; break;
|
|
423 |
case 1: scramble[num][2] = 1; break;
|
|
422 |
case 0: scramble[curr][2] = -1; break;
|
|
423 |
case 1: scramble[curr][2] = 1; break;
|
|
424 | 424 |
} |
425 | 425 |
} |
426 | 426 |
|
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
421 | 421 |
|
422 | 422 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
423 | 423 |
|
424 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
424 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
425 | 425 |
{ |
426 |
if( num==0 )
|
|
426 |
if( curr==0 )
|
|
427 | 427 |
{ |
428 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
429 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0:2;
|
|
428 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
429 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0:2;
|
|
430 | 430 |
} |
431 | 431 |
else |
432 | 432 |
{ |
433 | 433 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
434 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
435 |
scramble[num][1] = (scramble[num-1][0]+scramble[num][0]==3 ? 2-scramble[num-1][1] : scramble[num-1][1]);
|
|
434 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
435 |
scramble[curr][1] = (scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1]);
|
|
436 | 436 |
} |
437 | 437 |
|
438 | 438 |
switch( rnd.nextInt(2) ) |
439 | 439 |
{ |
440 |
case 0: scramble[num][2] = -1; break;
|
|
441 |
case 1: scramble[num][2] = 1; break;
|
|
440 |
case 0: scramble[curr][2] = -1; break;
|
|
441 |
case 1: scramble[curr][2] = 1; break;
|
|
442 | 442 |
} |
443 | 443 |
} |
444 | 444 |
|
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
599 | 599 |
|
600 | 600 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
601 | 601 |
|
602 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
602 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
603 | 603 |
{ |
604 |
if( num==0 )
|
|
604 |
if( curr==0 )
|
|
605 | 605 |
{ |
606 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
606 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
607 | 607 |
} |
608 | 608 |
else |
609 | 609 |
{ |
610 | 610 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
611 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
611 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
612 | 612 |
} |
613 | 613 |
|
614 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0 : 2;
|
|
614 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 2;
|
|
615 | 615 |
|
616 | 616 |
switch( rnd.nextInt(2) ) |
617 | 617 |
{ |
618 |
case 0: scramble[num][2] = -1; break;
|
|
619 |
case 1: scramble[num][2] = 1; break;
|
|
618 |
case 0: scramble[curr][2] = -1; break;
|
|
619 |
case 1: scramble[curr][2] = 1; break;
|
|
620 | 620 |
} |
621 | 621 |
} |
622 | 622 |
|
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
613 | 613 |
|
614 | 614 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
615 | 615 |
|
616 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
616 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
617 | 617 |
{ |
618 |
if( num==0 )
|
|
618 |
if( curr==0 )
|
|
619 | 619 |
{ |
620 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
620 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
621 | 621 |
} |
622 | 622 |
else |
623 | 623 |
{ |
624 | 624 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
625 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
625 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
626 | 626 |
} |
627 | 627 |
|
628 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0 : getNumLayers()-1;
|
|
628 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : getNumLayers()-1;
|
|
629 | 629 |
|
630 | 630 |
switch( rnd.nextInt(2) ) |
631 | 631 |
{ |
632 |
case 0: scramble[num][2] = -1; break;
|
|
633 |
case 1: scramble[num][2] = 1; break;
|
|
632 |
case 0: scramble[curr][2] = -1; break;
|
|
633 |
case 1: scramble[curr][2] = 1; break;
|
|
634 | 634 |
} |
635 | 635 |
} |
636 | 636 |
|
src/main/java/org/distorted/objects/TwistySquare1.java | ||
---|---|---|
454 | 454 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
455 | 455 |
// PUBLIC API |
456 | 456 |
|
457 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
457 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
458 | 458 |
{ |
459 | 459 |
int layer, nextAngle; |
460 | 460 |
|
461 |
if( num==0 )
|
|
461 |
if( curr==0 )
|
|
462 | 462 |
{ |
463 | 463 |
for(int corner=0; corner<8; corner++) mCornerQuat[corner] = 0; |
464 | 464 |
mLastRot = rnd.nextInt(4); |
... | ... | |
476 | 476 |
nextAngle = getNextAngleNotZero(rnd,layer); |
477 | 477 |
} |
478 | 478 |
|
479 |
scramble[num][0] = 0;
|
|
480 |
scramble[num][1] = 2*layer;
|
|
481 |
scramble[num][2] = nextAngle;
|
|
479 |
scramble[curr][0] = 0;
|
|
480 |
scramble[curr][1] = 2*layer;
|
|
481 |
scramble[curr][2] = nextAngle;
|
|
482 | 482 |
mLastRot = layer==0 ? LAST_LO : LAST_UP; |
483 |
updateCornerQuats(scramble[num]);
|
|
483 |
updateCornerQuats(scramble[curr]);
|
|
484 | 484 |
break; |
485 | 485 |
case LAST_LO: |
486 | 486 |
case LAST_UP: layer = mLastRot==LAST_LO ? 1:0; |
... | ... | |
488 | 488 |
|
489 | 489 |
if( nextAngle!=0 ) |
490 | 490 |
{ |
491 |
scramble[num][0] = 0;
|
|
492 |
scramble[num][1] = 2*layer;
|
|
493 |
scramble[num][2] = nextAngle;
|
|
494 |
updateCornerQuats(scramble[num]);
|
|
491 |
scramble[curr][0] = 0;
|
|
492 |
scramble[curr][1] = 2*layer;
|
|
493 |
scramble[curr][2] = nextAngle;
|
|
494 |
updateCornerQuats(scramble[curr]);
|
|
495 | 495 |
mLastRot = LAST_UL; |
496 | 496 |
} |
497 | 497 |
else |
498 | 498 |
{ |
499 |
scramble[num][0] = 1;
|
|
500 |
scramble[num][1] = rnd.nextInt(2);
|
|
501 |
scramble[num][2] = 1;
|
|
499 |
scramble[curr][0] = 1;
|
|
500 |
scramble[curr][1] = rnd.nextInt(2);
|
|
501 |
scramble[curr][2] = 1;
|
|
502 | 502 |
mLastRot = LAST_SL; |
503 |
updateCornerQuats(scramble[num]);
|
|
503 |
updateCornerQuats(scramble[curr]);
|
|
504 | 504 |
computePermittedAngles(); |
505 | 505 |
} |
506 | 506 |
|
507 | 507 |
break; |
508 |
case LAST_UL: scramble[num][0] = 1;
|
|
509 |
scramble[num][1] = rnd.nextInt(2);
|
|
510 |
scramble[num][2] = 1;
|
|
508 |
case LAST_UL: scramble[curr][0] = 1;
|
|
509 |
scramble[curr][1] = rnd.nextInt(2);
|
|
510 |
scramble[curr][2] = 1;
|
|
511 | 511 |
mLastRot = LAST_SL; |
512 |
updateCornerQuats(scramble[num]);
|
|
512 |
updateCornerQuats(scramble[curr]);
|
|
513 | 513 |
computePermittedAngles(); |
514 | 514 |
break; |
515 | 515 |
} |
src/main/java/org/distorted/objects/TwistySquare2.java | ||
---|---|---|
278 | 278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
279 | 279 |
// PUBLIC API |
280 | 280 |
|
281 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
281 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
282 | 282 |
{ |
283 | 283 |
int layer, nextAngle; |
284 | 284 |
|
285 |
if( num==0 ) mLastRot = rnd.nextInt(4);
|
|
285 |
if( curr==0 ) mLastRot = rnd.nextInt(4);
|
|
286 | 286 |
|
287 | 287 |
switch(mLastRot) |
288 | 288 |
{ |
... | ... | |
295 | 295 |
nextAngle = (2*rnd.nextInt(2)-1)*(rnd.nextInt(5)+1); |
296 | 296 |
} |
297 | 297 |
|
298 |
scramble[num][0] = 0;
|
|
299 |
scramble[num][1] = 2*layer;
|
|
300 |
scramble[num][2] = nextAngle;
|
|
298 |
scramble[curr][0] = 0;
|
|
299 |
scramble[curr][1] = 2*layer;
|
|
300 |
scramble[curr][2] = nextAngle;
|
|
301 | 301 |
mLastRot = layer==0 ? LAST_LO : LAST_UP; |
302 | 302 |
break; |
303 | 303 |
case LAST_LO: |
... | ... | |
306 | 306 |
|
307 | 307 |
if( nextAngle!=0 ) |
308 | 308 |
{ |
309 |
scramble[num][0] = 0;
|
|
310 |
scramble[num][1] = 2*layer;
|
|
311 |
scramble[num][2] = nextAngle;
|
|
309 |
scramble[curr][0] = 0;
|
|
310 |
scramble[curr][1] = 2*layer;
|
|
311 |
scramble[curr][2] = nextAngle;
|
|
312 | 312 |
mLastRot = LAST_UL; |
313 | 313 |
} |
314 | 314 |
else |
315 | 315 |
{ |
316 |
scramble[num][0] = 1;
|
|
317 |
scramble[num][1] = rnd.nextInt(2);
|
|
318 |
scramble[num][2] = 1;
|
|
316 |
scramble[curr][0] = 1;
|
|
317 |
scramble[curr][1] = rnd.nextInt(2);
|
|
318 |
scramble[curr][2] = 1;
|
|
319 | 319 |
mLastRot = LAST_SL; |
320 | 320 |
} |
321 | 321 |
break; |
322 |
case LAST_UL: scramble[num][0] = 1;
|
|
323 |
scramble[num][1] = rnd.nextInt(2);
|
|
324 |
scramble[num][2] = 1;
|
|
322 |
case LAST_UL: scramble[curr][0] = 1;
|
|
323 |
scramble[curr][1] = rnd.nextInt(2);
|
|
324 |
scramble[curr][2] = 1;
|
|
325 | 325 |
mLastRot = LAST_SL; |
326 | 326 |
break; |
327 | 327 |
} |
src/main/java/org/distorted/objects/TwistyUltimate.java | ||
---|---|---|
441 | 441 |
|
442 | 442 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
443 | 443 |
|
444 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
|
444 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
|
445 | 445 |
{ |
446 |
if( num==0 )
|
|
446 |
if( curr==0 )
|
|
447 | 447 |
{ |
448 |
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
|
448 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS);
|
|
449 | 449 |
} |
450 | 450 |
else |
451 | 451 |
{ |
452 | 452 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
453 |
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
|
453 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
|
|
454 | 454 |
} |
455 | 455 |
|
456 |
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0 : 1;
|
|
456 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 1;
|
|
457 | 457 |
|
458 | 458 |
switch( rnd.nextInt(2) ) |
459 | 459 |
{ |
460 |
case 0: scramble[num][2] = 1; break;
|
|
461 |
case 1: scramble[num][2] = -1; break;
|
|
460 |
case 0: scramble[curr][2] = 1; break;
|
|
461 |
case 1: scramble[curr][2] = -1; break;
|
|
462 | 462 |
} |
463 | 463 |
} |
464 | 464 |
|
Also available in: Unified diff
Preparation for 'smart scrambling' : introduce the total number of scrambles to the 'randomizeNewScramble' function.