Revision 0ad6b867
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyBandaged2Bar.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
import org.distorted.main.R; |
30 | 30 |
|
31 |
import java.util.Random; |
|
32 |
|
|
33 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
34 | 32 |
|
35 | 33 |
class TwistyBandaged2Bar extends TwistyBandagedAbstract |
src/main/java/org/distorted/objects/TwistyBandaged3Plate.java | ||
---|---|---|
28 | 28 |
import org.distorted.helpers.ScrambleStateGraph; |
29 | 29 |
import org.distorted.main.R; |
30 | 30 |
|
31 |
import java.util.Random; |
|
32 |
|
|
33 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
34 | 32 |
|
35 | 33 |
class TwistyBandaged3Plate extends TwistyBandagedAbstract |
src/main/java/org/distorted/objects/TwistyBandagedEvil.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
import org.distorted.main.R; |
30 | 30 |
|
31 |
import java.util.Random; |
|
32 |
|
|
33 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
34 | 32 |
|
35 | 33 |
class TwistyBandagedEvil extends TwistyBandagedAbstract |
src/main/java/org/distorted/objects/TwistyBandagedFused.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static4D; |
29 | 29 |
import org.distorted.main.R; |
30 | 30 |
|
31 |
import java.util.Random; |
|
32 |
|
|
33 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
34 | 32 |
|
35 | 33 |
class TwistyBandagedFused extends TwistyBandagedAbstract |
... | ... | |
74 | 72 |
{ |
75 | 73 |
super(size, quat, texture, mesh, effects, moves, ObjectList.BAN1, res, scrWidth); |
76 | 74 |
|
75 |
int[] tmp = {0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0}; |
|
76 |
|
|
77 | 77 |
mStates = new ScrambleStateGraph[] |
78 | 78 |
{ |
79 |
new ScrambleStateGraph( new int[][] { |
|
80 |
{0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0}, |
|
81 |
{0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0}, |
|
82 |
{0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0}, |
|
83 |
} |
|
84 |
) |
|
79 |
new ScrambleStateGraph( new int[][] {tmp,tmp,tmp} ) |
|
85 | 80 |
}; |
86 | 81 |
} |
87 | 82 |
|
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.ObjectShape; |
25 | 25 |
import org.distorted.helpers.ObjectSticker; |
26 |
import org.distorted.helpers.ScrambleStateGraph; |
|
26 | 27 |
import org.distorted.library.main.DistortedEffects; |
27 | 28 |
import org.distorted.library.main.DistortedTexture; |
28 | 29 |
import org.distorted.library.mesh.MeshSquare; |
... | ... | |
116 | 117 |
} |
117 | 118 |
} |
118 | 119 |
|
120 |
private int mCurrState; |
|
121 |
private int mIndexExcluded; |
|
122 |
private final ScrambleStateGraph[] mStates; |
|
123 |
|
|
119 | 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
120 | 125 |
|
121 | 126 |
TwistyIvy(int size, Static4D quat, DistortedTexture texture, |
122 | 127 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
123 | 128 |
{ |
124 | 129 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.IVY, res, scrWidth); |
130 |
|
|
131 |
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 }; |
|
132 |
|
|
133 |
mStates = new ScrambleStateGraph[] |
|
134 |
{ |
|
135 |
new ScrambleStateGraph( new int[][] {tmp,tmp,tmp,tmp} ) |
|
136 |
}; |
|
125 | 137 |
} |
126 | 138 |
|
127 | 139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
450 | 462 |
|
451 | 463 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
452 | 464 |
|
453 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
465 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
454 | 466 |
{ |
455 | 467 |
if( curr==0 ) |
456 | 468 |
{ |
457 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS); |
|
458 |
} |
|
459 |
else |
|
460 |
{ |
|
461 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
|
462 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
|
469 |
mCurrState = 0; |
|
470 |
mIndexExcluded =-1; |
|
463 | 471 |
} |
464 | 472 |
|
465 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 1; |
|
473 |
int total = mStates[mCurrState].getTotal(mIndexExcluded); |
|
474 |
int random= rnd.nextInt(total); |
|
475 |
int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded); |
|
466 | 476 |
|
467 |
switch( rnd.nextInt(2) ) |
|
468 |
{ |
|
469 |
case 0: scramble[curr][2] = -1; break; |
|
470 |
case 1: scramble[curr][2] = 1; break; |
|
471 |
} |
|
477 |
scramble[curr][0] = info[0]; |
|
478 |
scramble[curr][1] = info[1]; |
|
479 |
scramble[curr][2] = info[2]; |
|
480 |
|
|
481 |
mCurrState = info[3]; |
|
482 |
mIndexExcluded = info[0]; |
|
472 | 483 |
} |
473 | 484 |
|
474 | 485 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyJing.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.ObjectShape; |
25 | 25 |
import org.distorted.helpers.ObjectSticker; |
26 |
import org.distorted.helpers.ScrambleStateGraph; |
|
26 | 27 |
import org.distorted.library.main.DistortedEffects; |
27 | 28 |
import org.distorted.library.main.DistortedTexture; |
28 | 29 |
import org.distorted.library.mesh.MeshSquare; |
... | ... | |
215 | 216 |
} |
216 | 217 |
} |
217 | 218 |
|
219 |
private int mCurrState; |
|
220 |
private int mIndexExcluded; |
|
221 |
private final ScrambleStateGraph[] mStates; |
|
222 |
|
|
218 | 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
219 | 224 |
|
220 | 225 |
TwistyJing(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
221 | 226 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
222 | 227 |
{ |
223 | 228 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.JING, res, scrWidth); |
229 |
|
|
230 |
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 }; |
|
231 |
|
|
232 |
mStates = new ScrambleStateGraph[] |
|
233 |
{ |
|
234 |
new ScrambleStateGraph( new int[][] {tmp,tmp,tmp,tmp} ) |
|
235 |
}; |
|
224 | 236 |
} |
225 | 237 |
|
226 | 238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
400 | 412 |
|
401 | 413 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
402 | 414 |
|
403 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
415 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
404 | 416 |
{ |
405 | 417 |
if( curr==0 ) |
406 | 418 |
{ |
407 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS); |
|
408 |
} |
|
409 |
else |
|
410 |
{ |
|
411 |
int newVector = rnd.nextInt(NUM_AXIS-1); |
|
412 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
|
419 |
mCurrState = 0; |
|
420 |
mIndexExcluded =-1; |
|
413 | 421 |
} |
414 | 422 |
|
415 |
scramble[curr][1] = rnd.nextInt(2); |
|
423 |
int total = mStates[mCurrState].getTotal(mIndexExcluded); |
|
424 |
int random= rnd.nextInt(total); |
|
425 |
int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded); |
|
416 | 426 |
|
417 |
switch( rnd.nextInt(2) ) |
|
418 |
{ |
|
419 |
case 0: scramble[curr][2] = -1; break; |
|
420 |
case 1: scramble[curr][2] = 1; break; |
|
421 |
} |
|
427 |
scramble[curr][0] = info[0]; |
|
428 |
scramble[curr][1] = info[1]; |
|
429 |
scramble[curr][2] = info[2]; |
|
430 |
|
|
431 |
mCurrState = info[3]; |
|
432 |
mIndexExcluded = info[0]; |
|
422 | 433 |
} |
423 | 434 |
|
424 | 435 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyUltimate.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.ObjectShape; |
25 | 25 |
import org.distorted.helpers.ObjectSticker; |
26 |
import org.distorted.helpers.ScrambleStateGraph; |
|
26 | 27 |
import org.distorted.library.main.DistortedEffects; |
27 | 28 |
import org.distorted.library.main.DistortedTexture; |
28 | 29 |
import org.distorted.library.mesh.MeshSquare; |
... | ... | |
232 | 233 |
} |
233 | 234 |
} |
234 | 235 |
|
236 |
private int mCurrState; |
|
237 |
private int mIndexExcluded; |
|
238 |
private final ScrambleStateGraph[] mStates; |
|
239 |
|
|
235 | 240 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
236 | 241 |
|
237 | 242 |
TwistyUltimate(int size, Static4D quat, DistortedTexture texture, |
238 | 243 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
239 | 244 |
{ |
240 | 245 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.ULTI, res, scrWidth); |
246 |
|
|
247 |
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 }; |
|
248 |
|
|
249 |
mStates = new ScrambleStateGraph[] |
|
250 |
{ |
|
251 |
new ScrambleStateGraph( new int[][] {tmp,tmp,tmp,tmp} ) |
|
252 |
}; |
|
241 | 253 |
} |
242 | 254 |
|
243 | 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
416 | 428 |
|
417 | 429 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
418 | 430 |
|
419 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
431 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
420 | 432 |
{ |
421 | 433 |
if( curr==0 ) |
422 | 434 |
{ |
423 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS); |
|
424 |
} |
|
425 |
else |
|
426 |
{ |
|
427 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
|
428 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
|
435 |
mCurrState = 0; |
|
436 |
mIndexExcluded =-1; |
|
429 | 437 |
} |
430 | 438 |
|
431 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0 : 1; |
|
439 |
int total = mStates[mCurrState].getTotal(mIndexExcluded); |
|
440 |
int random= rnd.nextInt(total); |
|
441 |
int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded); |
|
432 | 442 |
|
433 |
switch( rnd.nextInt(2) ) |
|
434 |
{ |
|
435 |
case 0: scramble[curr][2] = 1; break; |
|
436 |
case 1: scramble[curr][2] = -1; break; |
|
437 |
} |
|
443 |
scramble[curr][0] = info[0]; |
|
444 |
scramble[curr][1] = info[1]; |
|
445 |
scramble[curr][2] = info[2]; |
|
446 |
|
|
447 |
mCurrState = info[3]; |
|
448 |
mIndexExcluded = info[0]; |
|
438 | 449 |
} |
439 | 450 |
|
440 | 451 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert Skewb Ultimate, Jing Pyraminx & Ivy Cube to the new, unified scrambling method.