Revision 0ad6b867
Added by Leszek Koltunski over 2 years ago
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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert Skewb Ultimate, Jing Pyraminx & Ivy Cube to the new, unified scrambling method.