Project

General

Profile

« Previous | Next » 

Revision 0ad6b867

Added by Leszek Koltunski over 2 years ago

Convert Skewb Ultimate, Jing Pyraminx & Ivy Cube to the new, unified scrambling method.

View differences:

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