Project

General

Profile

« Previous | Next » 

Revision e1dc3366

Added by Leszek Koltunski over 2 years ago

Introduce pseudorandom balancing into scrambling to all the other already converted objects, i.e. everytihng except for Pyraminxes, Squares, Minxes and the Redi.

View differences:

src/main/java/org/distorted/objects/TwistyCube.java
132 132
  private int mCurrState;
133 133
  private int mIndexExcluded;
134 134
  private final ScrambleState[] mStates;
135
  private int[][] mScrambleTable;
136
  private int[] mNumOccurences;
135 137

  
136 138
///////////////////////////////////////////////////////////////////////////////////////////////////
137 139

  
......
370 372
    return BASIC_ANGLE;
371 373
    }
372 374

  
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376

  
377
  private void initializeScrambling()
378
    {
379
    int numLayers = getNumLayers();
380

  
381
    if( mScrambleTable ==null )
382
      {
383
      mScrambleTable = new int[NUM_AXIS][numLayers];
384
      }
385
    if( mNumOccurences ==null )
386
      {
387
      int max=0;
388

  
389
      for (ScrambleState mState : mStates)
390
        {
391
        int tmp = mState.getTotal(-1);
392
        if (max < tmp) max = tmp;
393
        }
394

  
395
      mNumOccurences = new int[max];
396
      }
397

  
398
    for(int i=0; i<NUM_AXIS; i++)
399
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
400
    }
401

  
373 402
///////////////////////////////////////////////////////////////////////////////////////////////////
374 403

  
375 404
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
......
378 407
      {
379 408
      mCurrState     = 0;
380 409
      mIndexExcluded =-1;
410
      initializeScrambling();
381 411
      }
382 412

  
383
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
384
    int random= rnd.nextInt(total);
385
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
413
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
386 414

  
387 415
    scramble[curr][0] = info[0];
388 416
    scramble[curr][1] = info[1];

Also available in: Unified diff