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/TwistyIvy.java
120 120
  private int mCurrState;
121 121
  private int mIndexExcluded;
122 122
  private final ScrambleState[] mStates;
123
  private int[][] mScrambleTable;
124
  private int[] mNumOccurences;
123 125

  
124 126
///////////////////////////////////////////////////////////////////////////////////////////////////
125 127

  
......
446 448
    }
447 449

  
448 450
///////////////////////////////////////////////////////////////////////////////////////////////////
449
// PUBLIC API
450 451

  
451
  public Static3D[] getRotationAxis()
452
  private void initializeScrambling()
452 453
    {
453
    return ROT_AXIS;
454
    }
454
    int numLayers = getNumLayers();
455 455

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

  
458
  public int[] getBasicAngle()
459
    {
460
    return BASIC_ANGLE;
464
      for (ScrambleState mState : mStates)
465
        {
466
        int tmp = mState.getTotal(-1);
467
        if (max < tmp) max = tmp;
468
        }
469

  
470
      mNumOccurences = new int[max];
471
      }
472

  
473
    for(int i=0; i<NUM_AXIS; i++)
474
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
461 475
    }
462 476

  
463 477
///////////////////////////////////////////////////////////////////////////////////////////////////
478
// PUBLIC API
464 479

  
465 480
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
466 481
    {
......
468 483
      {
469 484
      mCurrState     = 0;
470 485
      mIndexExcluded =-1;
486
      initializeScrambling();
471 487
      }
472 488

  
473
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
474
    int random= rnd.nextInt(total);
475
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
489
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
476 490

  
477 491
    scramble[curr][0] = info[0];
478 492
    scramble[curr][1] = info[1];
......
482 496
    mIndexExcluded = info[0];
483 497
    }
484 498

  
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500

  
501
  public Static3D[] getRotationAxis()
502
    {
503
    return ROT_AXIS;
504
    }
505

  
506
///////////////////////////////////////////////////////////////////////////////////////////////////
507

  
508
  public int[] getBasicAngle()
509
    {
510
    return BASIC_ANGLE;
511
    }
512

  
485 513
///////////////////////////////////////////////////////////////////////////////////////////////////
486 514

  
487 515
  public int getObjectName(int numLayers)

Also available in: Unified diff