Project

General

Profile

« Previous | Next » 

Revision 671a53a2

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/helpers/ObjectSignature.java
223 223
      float[][] cyc = mAllCycles[i];
224 224
      float[] p0 = cyc[0];
225 225
      float[] p1 = cyc[1];
226
      float[] p2 = cyc[2];
227 226

  
228
      if( (belongsLeft(p0,axis,layer) && belongsLeft(p1,axis,layer) && belongsLeft(p2,axis,layer)) ||
229
          (belongsCent(p0,axis,layer) && belongsCent(p1,axis,layer) && belongsCent(p2,axis,layer))  )
227
      if( cyc.length==4 )
230 228
        {
231
        ret.cycle(turn,cyc);
229
        float[] p2 = cyc[2];
230

  
231
        if( (belongsLeft(p0,axis,layer) && belongsLeft(p1,axis,layer) && belongsLeft(p2,axis,layer)) ||
232
            (belongsCent(p0,axis,layer) && belongsCent(p1,axis,layer) && belongsCent(p2,axis,layer))  )
233
          {
234
          ret.cycle4(turn,cyc);
235
          }
236
        }
237
      else
238
        {
239
        if( (belongsLeft(p0,axis,layer) && belongsLeft(p1,axis,layer)) ||
240
            (belongsCent(p0,axis,layer) && belongsCent(p1,axis,layer))  )
241
          {
242
          ret.cycle2(cyc);
243
          }
232 244
        }
233 245
      }
234 246

  
......
251 263

  
252 264
///////////////////////////////////////////////////////////////////////////////////////////////////
253 265

  
254
  private void cycle(int turn, float[][] cyc)
266
  private void cycle2(float[][] cyc)
255 267
    {
256
    int numPoints = cyc.length;
268
    float[] p0 = cyc[0];
269
    float[] p1 = cyc[1];
257 270

  
258
    if( numPoints==2 )
259
      {
260
      float[] p0 = cyc[0];
261
      float[] p1 = cyc[1];
271
    int index0 = getIndexOfCubitTouch(p0[0],p0[1],p0[2]);
272
    int index1 = getIndexOfCubitTouch(p1[0],p1[1],p1[2]);
262 273

  
263
      int index0 = getIndexOfCubitTouch(p0[0],p0[1],p0[2]);
264
      int index1 = getIndexOfCubitTouch(p1[0],p1[1],p1[2]);
274
    long b0 = getBit(index0);
275
    long b1 = getBit(index1);
265 276

  
266
      long b0 = getBit(index0);
267
      long b1 = getBit(index1);
268

  
269
      setBit(index1,b0);
270
      setBit(index0,b1);
271
      }
272
    else if( numPoints==4 )
273
      {
274
      float[] p0 = cyc[0];
275
      float[] p1 = cyc[1];
276
      float[] p2 = cyc[2];
277
      float[] p3 = cyc[3];
278

  
279
      int index0 = getIndexOfCubitTouch(p0[0],p0[1],p0[2]);
280
      int index1 = getIndexOfCubitTouch(p1[0],p1[1],p1[2]);
281
      int index2 = getIndexOfCubitTouch(p2[0],p2[1],p2[2]);
282
      int index3 = getIndexOfCubitTouch(p3[0],p3[1],p3[2]);
277
    setBit(index1,b0);
278
    setBit(index0,b1);
279
    }
283 280

  
284
      long b0 = getBit(index0);
285
      long b1 = getBit(index1);
286
      long b2 = getBit(index2);
287
      long b3 = getBit(index3);
281
///////////////////////////////////////////////////////////////////////////////////////////////////
288 282

  
289
      switch(turn)
290
        {
291
        case 1: setBit(index0,b3);
292
                setBit(index1,b0);
293
                setBit(index2,b1);
294
                setBit(index3,b2);
295
                break;
296
        case 2: setBit(index0,b2);
297
                setBit(index1,b3);
298
                setBit(index2,b0);
299
                setBit(index3,b1);
300
                break;
301
        case 3: setBit(index0,b1);
302
                setBit(index1,b2);
303
                setBit(index2,b3);
304
                setBit(index3,b0);
305
                break;
306
        }
307
      }
308
    else
283
  private void cycle4(int turn, float[][] cyc)
284
    {
285
    float[] p0 = cyc[0];
286
    float[] p1 = cyc[1];
287
    float[] p2 = cyc[2];
288
    float[] p3 = cyc[3];
289

  
290
    int index0 = getIndexOfCubitTouch(p0[0],p0[1],p0[2]);
291
    int index1 = getIndexOfCubitTouch(p1[0],p1[1],p1[2]);
292
    int index2 = getIndexOfCubitTouch(p2[0],p2[1],p2[2]);
293
    int index3 = getIndexOfCubitTouch(p3[0],p3[1],p3[2]);
294

  
295
    long b0 = getBit(index0);
296
    long b1 = getBit(index1);
297
    long b2 = getBit(index2);
298
    long b3 = getBit(index3);
299

  
300
    switch(turn)
309 301
      {
310
      android.util.Log.e("D", "error in cycle, numPoints="+numPoints);
302
      case 1: setBit(index0,b3);
303
              setBit(index1,b0);
304
              setBit(index2,b1);
305
              setBit(index3,b2);
306
              break;
307
      case 2: setBit(index0,b2);
308
              setBit(index1,b3);
309
              setBit(index2,b0);
310
              setBit(index3,b1);
311
              break;
312
      case 3: setBit(index0,b1);
313
              setBit(index1,b2);
314
              setBit(index2,b3);
315
              setBit(index3,b0);
316
              break;
311 317
      }
312 318
    }
313 319

  
src/main/java/org/distorted/objectlib/scrambling/ScrambleStateBandagedCuboid.java
76 76

  
77 77
    mMoves = createMoves();
78 78

  
79

  
80 79
android.util.Log.d("D", "sig: "+mSignature.getString() );
81 80
printMoves();
82

  
83 81
    }
84 82

  
85 83
///////////////////////////////////////////////////////////////////////////////////////////////////
......
101 99
  public void removeMoves(ObjectSignature signature)
102 100
    {
103 101
    for(int m=0; m<mNumMoves; m++)
104
      if( signature.isEqual(mMoves[m]) ) mMoves[m]=null;
102
      if( mMoves[m]!=null && signature.isEqual(mMoves[m]) ) mMoves[m]=null;
105 103
    }
106 104

  
107 105
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff