Project

General

Profile

« Previous | Next » 

Revision 338e42aa

Added by Leszek Koltunski about 2 years ago

Fixes for scrambling locally-produced bandaged cuboid.
Still does not work completely.

View differences:

src/main/java/org/distorted/objectlib/scrambling/ObjectScrambler.java
56 56
  // type=2 , i.e. locally created bandaged cuboids
57 57
  private static ObjectSignature mSignature;
58 58
  private ArrayList<ScrambleStateBandagedCuboid> mBandagedStates;
59
  private int[] mSize, mTurns;
60 59

  
61 60
///////////////////////////////////////////////////////////////////////////////////////////////////
62 61

  
......
73 72
      mCornerQuat = new int[8];
74 73
      mLastRot = LAST_SL;
75 74
      }
76
    if( mType==2 )
77
      {
78
      mSize = new int[3];
79
      mTurns= new int[3];
80

  
81
      mSize[0] = (mNumLayers[0]>1 ? mNumLayers[0] : 0);
82
      mSize[1] = (mNumLayers[1]>1 ? mNumLayers[1] : 0);
83
      mSize[2] = (mNumLayers[2]>1 ? mNumLayers[2] : 0);
84

  
85
      mTurns[0] = mNumLayers[1]==mNumLayers[2] ? 3:1;
86
      mTurns[1] = mNumLayers[0]==mNumLayers[2] ? 3:1;
87
      mTurns[2] = mNumLayers[0]==mNumLayers[1] ? 3:1;
88
      }
89 75
    }
90 76

  
91 77
///////////////////////////////////////////////////////////////////////////////////////////////////
......
421 407
      }
422 408
    }
423 409

  
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425
// TYPE 2
426

  
427
  private void fillOutScramble(int[] scramble, int moveIndex)
428
    {
429
    for(int axis=0; axis<3; axis++)
430
      {
431
      int size = mTurns[axis]*mSize[axis];
432

  
433
      if( moveIndex<size )
434
        {
435
        scramble[0] = axis;
436
        scramble[1] = moveIndex/mTurns[axis];
437

  
438
        if( mTurns[axis]==3 )
439
          {
440
          switch(moveIndex%3)
441
            {
442
            case 0: scramble[2] = -1; break;
443
            case 1: scramble[2] =  2; break;
444
            case 2: scramble[2] =  1; break;
445
            }
446
          }
447
        else scramble[2] =  1;
448
        return;
449
        }
450

  
451
      moveIndex -= size;
452
      }
453

  
454
    android.util.Log.e("D", "ERROR in fillOutScramble moveIndex="+moveIndex);
455
    }
456

  
457 410
///////////////////////////////////////////////////////////////////////////////////////////////////
458 411
// TYPE 2
459 412

  
......
480 433
      int randMove = rnd.nextInt(numMoves);
481 434
      int moveIndex = currState.getNthMove(randMove,indexExcluded);
482 435
      mSignature = currState.getMove(moveIndex);
483
      fillOutScramble(scramble[curr],moveIndex);
436
      currState.fillOutScramble(scramble[curr],moveIndex);
484 437
      }
485 438

  
486 439
    ScrambleStateBandagedCuboid nextState = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], mSignature);
......
519 472
    int randMove = rnd.nextInt(numMoves);
520 473
    int moveIndex = currState.getNthMove(randMove,indexExcluded);
521 474
    mSignature = currState.getMove(moveIndex);
522
    fillOutScramble(scramble[curr],moveIndex);
475
    currState.fillOutScramble(scramble[curr],moveIndex);
523 476

  
524 477
    ScrambleStateBandagedCuboid nextState = new ScrambleStateBandagedCuboid(mNumLayers[0], mNumLayers[1], mNumLayers[2], mSignature);
525 478
    mBandagedStates.add(nextState);

Also available in: Unified diff