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/TwistyHelicopter.java
239 239
  private int mCurrState;
240 240
  private int mIndexExcluded;
241 241
  private final ScrambleState[] mStates;
242
  private int[][] mScrambleTable;
243
  private int[] mNumOccurences;
242 244

  
243 245
///////////////////////////////////////////////////////////////////////////////////////////////////
244 246

  
......
415 417
    }
416 418

  
417 419
///////////////////////////////////////////////////////////////////////////////////////////////////
418
// PUBLIC API
419 420

  
420
  public Static3D[] getRotationAxis()
421
  private void initializeScrambling()
421 422
    {
422
    return ROT_AXIS;
423
    }
423
    int numLayers = getNumLayers();
424 424

  
425
///////////////////////////////////////////////////////////////////////////////////////////////////
425
    if( mScrambleTable ==null )
426
      {
427
      mScrambleTable = new int[NUM_AXIS][numLayers];
428
      }
429
    if( mNumOccurences ==null )
430
      {
431
      int max=0;
426 432

  
427
  public int[] getBasicAngle()
428
    {
429
    return BASIC_ANGLE;
433
      for (ScrambleState mState : mStates)
434
        {
435
        int tmp = mState.getTotal(-1);
436
        if (max < tmp) max = tmp;
437
        }
438

  
439
      mNumOccurences = new int[max];
440
      }
441

  
442
    for(int i=0; i<NUM_AXIS; i++)
443
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
430 444
    }
431 445

  
432 446
///////////////////////////////////////////////////////////////////////////////////////////////////
447
// PUBLIC API
433 448

  
434 449
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
435 450
    {
......
437 452
      {
438 453
      mCurrState     = 0;
439 454
      mIndexExcluded =-1;
455
      initializeScrambling();
440 456
      }
441 457

  
442
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
443
    int random= rnd.nextInt(total);
444
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
458
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
445 459

  
446 460
    scramble[curr][0] = info[0];
447 461
    scramble[curr][1] = info[1];
......
451 465
    mIndexExcluded = info[0];
452 466
    }
453 467

  
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

  
470
  public Static3D[] getRotationAxis()
471
    {
472
    return ROT_AXIS;
473
    }
474

  
475
///////////////////////////////////////////////////////////////////////////////////////////////////
476

  
477
  public int[] getBasicAngle()
478
    {
479
    return BASIC_ANGLE;
480
    }
481

  
454 482
///////////////////////////////////////////////////////////////////////////////////////////////////
455 483

  
456 484
  public int getObjectName(int numLayers)

Also available in: Unified diff