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/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
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff