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/TwistyJing.java
219 219
  private int mCurrState;
220 220
  private int mIndexExcluded;
221 221
  private final ScrambleState[] mStates;
222
  private int[][] mScrambleTable;
223
  private int[] mNumOccurences;
222 224

  
223 225
///////////////////////////////////////////////////////////////////////////////////////////////////
224 226

  
......
396 398
    }
397 399

  
398 400
///////////////////////////////////////////////////////////////////////////////////////////////////
399
// PUBLIC API
400 401

  
401
  public Static3D[] getRotationAxis()
402
  private void initializeScrambling()
402 403
    {
403
    return ROT_AXIS;
404
    }
404
    int numLayers = getNumLayers();
405 405

  
406
///////////////////////////////////////////////////////////////////////////////////////////////////
406
    if( mScrambleTable ==null )
407
      {
408
      mScrambleTable = new int[NUM_AXIS][numLayers];
409
      }
410
    if( mNumOccurences ==null )
411
      {
412
      int max=0;
407 413

  
408
  public int[] getBasicAngle()
409
    {
410
    return BASIC_ANGLE;
414
      for (ScrambleState mState : mStates)
415
        {
416
        int tmp = mState.getTotal(-1);
417
        if (max < tmp) max = tmp;
418
        }
419

  
420
      mNumOccurences = new int[max];
421
      }
422

  
423
    for(int i=0; i<NUM_AXIS; i++)
424
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
411 425
    }
412 426

  
413 427
///////////////////////////////////////////////////////////////////////////////////////////////////
428
// PUBLIC API
414 429

  
415 430
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
416 431
    {
......
418 433
      {
419 434
      mCurrState     = 0;
420 435
      mIndexExcluded =-1;
436
      initializeScrambling();
421 437
      }
422 438

  
423
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
424
    int random= rnd.nextInt(total);
425
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
439
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
426 440

  
427 441
    scramble[curr][0] = info[0];
428 442
    scramble[curr][1] = info[1];
......
432 446
    mIndexExcluded = info[0];
433 447
    }
434 448

  
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450

  
451
  public Static3D[] getRotationAxis()
452
    {
453
    return ROT_AXIS;
454
    }
455

  
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

  
458
  public int[] getBasicAngle()
459
    {
460
    return BASIC_ANGLE;
461
    }
462

  
435 463
///////////////////////////////////////////////////////////////////////////////////////////////////
436 464

  
437 465
  public int getObjectName(int numLayers)

Also available in: Unified diff