Project

General

Profile

« Previous | Next » 

Revision efeca8ef

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
70 70
    }
71 71

  
72 72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
// objects created from JSON (version2)
73
// locally created bandaged cuboids created from JSON (version2)
74

  
75
  public ObjectSignature(String shortName, long signature1, long signature2, long signature3)
76
    {
77
    mSignature1 = signature1;
78
    mSignature2 = signature2;
79
    mSignature3 = signature3;
80

  
81
    int x = shortName.charAt(0) - '0';
82
    int y = shortName.charAt(1) - '0';
83
    int z = shortName.charAt(2) - '0';
84

  
85
    mLayer = new int[] {x,y,z};
86

  
87
    prepareCubitTouch();
88
    prepareAllCycles();
89
    }
90

  
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92
// other objects created from JSON (version2)
74 93

  
75 94
  public ObjectSignature(long signature1, long signature2, long signature3)
76 95
    {
......
96 115
      int numCenters = pos.length/3;
97 116

  
98 117
      for(int i=0; i<numCenters; i++)
118
        {
119
        float xi = pos[3*i  ];
120
        float yi = pos[3*i+1];
121
        float zi = pos[3*i+2];
122

  
99 123
        for(int j=i+1; j<numCenters; j++)
100 124
          {
101
          float x1 = pos[3*i  ];
102
          float y1 = pos[3*i+1];
103
          float z1 = pos[3*i+2];
104
          float x2 = pos[3*i  ];
105
          float y2 = pos[3*i+1];
106
          float z2 = pos[3*i+2];
107

  
108
          if(areNeighbours(x1-x2,y1-y2,z1-z2))
125
          float xj = pos[3*j  ];
126
          float yj = pos[3*j+1];
127
          float zj = pos[3*j+2];
128

  
129
          if(areNeighbours(xi-xj,yi-yj,zi-zj))
109 130
            {
110
            float xc = (x1+y1)/2;
111
            float yc = (y1+y2)/2;
112
            float zc = (z1+z2)/2;
131
            float xc = (xi+xj)/2;
132
            float yc = (yi+yj)/2;
133
            float zc = (zi+zj)/2;
113 134

  
114 135
            int bitIndex = getIndexOfCubitTouch(xc,yc,zc);
115 136
            setBit(bitIndex,1);
116 137
            }
117 138
          }
139
        }
118 140
      }
119 141
    }
120 142

  
......
168 190

  
169 191
  public String getString()
170 192
    {
171
    return mSignature1+"_"+mSignature2+"_"+mSignature3;
193
    String sig1 = String.format("0x%016X", mSignature1);
194
    String sig2 = String.format("0x%016X", mSignature2);
195
    String sig3 = String.format("0x%016X", mSignature3);
196

  
197
    return sig1+"_"+sig2+"_"+sig3;
172 198
    }
173 199

  
174 200
///////////////////////////////////////////////////////////////////////////////////////////////////
......
305 331

  
306 332
        if( areNeighbours(x1-x2,y1-y2,z1-z2) )
307 333
          {
308
          float xc = (x1+y1)/2;
334
          float xc = (x1+x2)/2;
309 335
          float yc = (y1+y2)/2;
310 336
          float zc = (z1+z2)/2;
311 337

  
......
317 343
    mNumCubitTouches = mTouch.size();
318 344
    mCubitTouch = new float[mNumCubitTouches][];
319 345
    for(int i=0; i<mNumCubitTouches; i++) mCubitTouch[i] = mTouch.remove(0);
346

  
347
    // now sort the touches so that the order agrees with 'Andreas signature' as defined here:
348
    // https://twistypuzzles.com/forum/viewtopic.php?p=415466#p415466
349
    // i.e. we need to sort by Y first (increasing) then by Z (decreasing) then by X (decreasing)
350
    // i.e. we need to sort by 100Y-10Z-X (increasing)
351

  
352
    for(int i=0; i<mNumCubitTouches; i++)
353
      {
354
      float[] ci = mCubitTouch[i];
355
      float val_i = 100*ci[1]-10*ci[2]-ci[0];
356

  
357
      for(int j=i+1; j<mNumCubitTouches; j++)
358
        {
359
        float[] cj = mCubitTouch[j];
360
        float val_j = 100*cj[1]-10*cj[2]-cj[0];
361

  
362
        if( val_j<val_i )
363
          {
364
          mCubitTouch[i] = cj;
365
          mCubitTouch[j] = ci;
366
          val_i = val_j;
367
          ci = cj;
368
          }
369
        }
370
      }
371
/*
372
    android.util.Log.e("D", "num touches="+mNumCubitTouches);
373

  
374
    for(int i=0; i<mNumCubitTouches; i++)
375
      {
376
      android.util.Log.e("D", mCubitTouch[i][0]+" "+mCubitTouch[i][1]+" "+mCubitTouch[i][2]);
377
      }
378
 */
320 379
    }
321 380

  
322 381
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/json/JsonReader.java
32 32

  
33 33
import org.distorted.objectlib.helpers.ObjectFaceShape;
34 34
import org.distorted.objectlib.helpers.ObjectSignature;
35
import org.distorted.objectlib.objects.TwistyBandagedGeneric;
35 36
import org.json.JSONArray;
36 37
import org.json.JSONException;
37 38
import org.json.JSONObject;
......
144 145
      long signature1 = object.getLong("signature1");
145 146
      long signature2 = object.getLong("signature2");
146 147
      long signature3 = object.getLong("signature3");
147
      mSignature = new ObjectSignature(signature1,signature2,signature3);
148

  
149
      if( mLongName.equals(TwistyBandagedGeneric.OBJECT_NAME) )
150
        {
151
        mSignature = new ObjectSignature(mShortName,signature1,signature2,signature3);
152
        }
153
      else
154
        {
155
        mSignature = new ObjectSignature(signature1,signature2,signature3);
156
        }
148 157
      }
149 158
    catch(JSONException ex)
150 159
      {
src/main/java/org/distorted/objectlib/objects/TwistyBandagedGeneric.java
30 30

  
31 31
public class TwistyBandagedGeneric extends TwistyBandagedAbstract
32 32
{
33
  public static final String OBJECT_NAME = "LOCAL_BANDAGED";
33 34
  private static float[][] POS;
34 35
  private static ObjectSignature mSignature;
35 36

  
......
134 135

  
135 136
  public String getObjectName()
136 137
    {
137
    return "";
138
    return OBJECT_NAME;
138 139
    }
139 140

  
140 141
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/scrambling/ScrambleStateBandagedCuboid.java
208 208

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

  
213 216
    for(int axis=0; axis<3; axis++)
214 217
      if( mLayer[axis]>1 )
......
242 245

  
243 246
  private void printMoves()
244 247
    {
245
    String moves = "";
246

  
247 248
    for(int i=0; i<mNumMoves; i++)
248 249
      {
249
      moves += (mMoves[i]!=null ? " "+mMoves[i].getString() : " NULL");
250
      android.util.Log.e("D", "move "+i+" : "+(mMoves[i]!=null ? " "+mMoves[i].getString() : " NULL") );
250 251
      }
251

  
252
    android.util.Log.e("D", moves);
253 252
    }
254 253

  
255 254
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff