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/ScrambleStateBandagedCuboid.java
35 35

  
36 36
  private final ObjectSignature[] mMoves;
37 37
  private final ObjectSignature mSignature;
38
  private final int[] mLayer, mTurns;
38
  private final int[] mLayer, mTurns, mSize;
39 39
  private final int mNumMoves;
40 40
  private final int mStartX, mStartY, mStartZ;
41 41
  private final boolean[][] mIsUnblocked;
......
46 46
    {
47 47
    mLayer = new int[3];
48 48
    mTurns = new int[3];
49
    mSize  = new int[3];
49 50

  
50 51
    mIsUnblocked = new boolean[3][MAX_SUPPORTED_SIZE];
51 52

  
......
57 58
    mTurns[1] = mLayer[0]==mLayer[2] ? 3:1;
58 59
    mTurns[2] = mLayer[0]==mLayer[1] ? 3:1;
59 60

  
60
    int xMoves = mLayer[0]>1 ? mTurns[0]*mLayer[0] : 0;
61
    int yMoves = mLayer[1]>1 ? mTurns[1]*mLayer[1] : 0;
62
    int zMoves = mLayer[2]>1 ? mTurns[2]*mLayer[2] : 0;
61
    mSize[0] = (mLayer[0]>1 ? mLayer[0] : 0);
62
    mSize[1] = (mLayer[1]>1 ? mLayer[1] : 0);
63
    mSize[2] = (mLayer[2]>1 ? mLayer[2] : 0);
64

  
65
    int xMoves = mTurns[0]*mSize[0];
66
    int yMoves = mTurns[1]*mSize[1];
67
    int zMoves = mTurns[2]*mSize[2];
63 68

  
64 69
    mNumMoves = xMoves + yMoves + zMoves;
65 70

  
......
210 215
      for(int layer=0; layer<mLayer[axis]; layer++)
211 216
        {
212 217
        mIsUnblocked[axis][layer] = mSignature.isUnblockedFromLeft(axis,layer);
213
        android.util.Log.e("D", "unblocked from left: axis="+axis+" layer="+layer+" val="+mIsUnblocked[axis][layer]);
218
        //android.util.Log.e("D", "unblocked from left: axis="+axis+" layer="+layer+" val="+mIsUnblocked[axis][layer]);
214 219
        }
215 220

  
216 221
    for(int axis=0; axis<3; axis++)
217 222
      if( mLayer[axis]>1 )
218
        for(int turn=0; turn<mTurns[axis]; turn++)
223
        for(int turn=1; turn<=mTurns[axis]; turn++)
219 224
          {
220 225
          boolean allLayersLocked = true;
221 226

  
......
241 246
    return ret;
242 247
    }
243 248

  
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

  
251
  public void fillOutScramble(int[] scramble, int moveIndex)
252
    {
253
    for(int axis=0; axis<3; axis++)
254
      {
255
      int size = mTurns[axis]*mSize[axis];
256

  
257
      if( moveIndex<size )
258
        {
259
        scramble[0] = axis;
260
        scramble[1] = moveIndex % mSize[axis];
261

  
262
        if( mTurns[axis]==3 )
263
          {
264
          switch(moveIndex/mSize[axis])
265
            {
266
            case 0: scramble[2] =-1; break;
267
            case 1: scramble[2] = 2; break;
268
            case 2: scramble[2] = 1; break;
269
            }
270
          }
271
        else scramble[2] = 1;
272
        return;
273
        }
274

  
275
      moveIndex -= size;
276
      }
277

  
278
    android.util.Log.e("D", "ERROR in fillOutScramble moveIndex="+moveIndex);
279
    }
280

  
244 281
///////////////////////////////////////////////////////////////////////////////////////////////////
245 282

  
246 283
  private void printMoves()

Also available in: Unified diff