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/TwistyBandagedAbstract.java
154 154
  private int mCurrState;
155 155
  private int mIndexExcluded;
156 156
  ScrambleState[] mStates;
157
  private int[][] mScrambleTable;
158
  private int[] mNumOccurences;
157 159

  
158 160
///////////////////////////////////////////////////////////////////////////////////////////////////
159 161

  
......
447 449
    return getNumLayers();
448 450
    }
449 451

  
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

  
454
  private void initializeScrambling()
455
    {
456
    int numLayers = getNumLayers();
457

  
458
    if( mScrambleTable ==null )
459
      {
460
      mScrambleTable = new int[NUM_AXIS][numLayers];
461
      }
462
    if( mNumOccurences ==null )
463
      {
464
      int max=0;
465

  
466
      for (ScrambleState mState : mStates)
467
        {
468
        int tmp = mState.getTotal(-1);
469
        if (max < tmp) max = tmp;
470
        }
471

  
472
      mNumOccurences = new int[max];
473
      }
474

  
475
    for(int i=0; i<NUM_AXIS; i++)
476
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
477
    }
478

  
450 479
///////////////////////////////////////////////////////////////////////////////////////////////////
451 480
// PUBLIC API
452 481

  
......
456 485
      {
457 486
      mCurrState     = 0;
458 487
      mIndexExcluded =-1;
488
      initializeScrambling();
459 489
      }
460 490

  
461
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
462
    int random= rnd.nextInt(total);
463
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
491
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
464 492

  
465 493
    scramble[curr][0] = info[0];
466 494
    scramble[curr][1] = info[1];

Also available in: Unified diff