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/TwistyDiamond.java
139 139
  private int mCurrState;
140 140
  private int mIndexExcluded;
141 141
  private final ScrambleState[] mStates;
142
  private int[][] mScrambleTable;
143
  private int[] mNumOccurences;
142 144

  
143 145
///////////////////////////////////////////////////////////////////////////////////////////////////
144 146

  
......
518 520
    }
519 521

  
520 522
///////////////////////////////////////////////////////////////////////////////////////////////////
521
// PUBLIC API
522 523

  
523
  public Static3D[] getRotationAxis()
524
  private void initializeScrambling()
524 525
    {
525
    return ROT_AXIS;
526
    }
526
    int numLayers = getNumLayers();
527 527

  
528
///////////////////////////////////////////////////////////////////////////////////////////////////
528
    if( mScrambleTable ==null )
529
      {
530
      mScrambleTable = new int[NUM_AXIS][numLayers];
531
      }
532
    if( mNumOccurences ==null )
533
      {
534
      int max=0;
529 535

  
530
  public int[] getBasicAngle()
531
    {
532
    return BASIC_ANGLE;
536
      for (ScrambleState mState : mStates)
537
        {
538
        int tmp = mState.getTotal(-1);
539
        if (max < tmp) max = tmp;
540
        }
541

  
542
      mNumOccurences = new int[max];
543
      }
544

  
545
    for(int i=0; i<NUM_AXIS; i++)
546
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
533 547
    }
534 548

  
535 549
///////////////////////////////////////////////////////////////////////////////////////////////////
550
// PUBLIC API
536 551

  
537 552
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
538 553
    {
......
540 555
      {
541 556
      mCurrState     = 0;
542 557
      mIndexExcluded =-1;
558
      initializeScrambling();
543 559
      }
544 560

  
545
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
546
    int random= rnd.nextInt(total);
547
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
561
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
548 562

  
549 563
    scramble[curr][0] = info[0];
550 564
    scramble[curr][1] = info[1];
......
554 568
    mIndexExcluded = info[0];
555 569
    }
556 570

  
571
///////////////////////////////////////////////////////////////////////////////////////////////////
572

  
573
  public Static3D[] getRotationAxis()
574
    {
575
    return ROT_AXIS;
576
    }
577

  
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579

  
580
  public int[] getBasicAngle()
581
    {
582
    return BASIC_ANGLE;
583
    }
584

  
557 585
///////////////////////////////////////////////////////////////////////////////////////////////////
558 586

  
559 587
  public int getObjectName(int numLayers)

Also available in: Unified diff