Project

General

Profile

« Previous | Next » 

Revision 3a5aa558

Added by Leszek Koltunski about 2 years ago

Fix scrambling the Danavi Block IV (and Burr Cube). Still looks a bit buggy, shouldn't have two consecutive moves along the same axis and layer and it seems to have those occasionally.

View differences:

src/main/java/org/distorted/objectlib/scrambling/ScrambleStateBandagedCuboid.java
198 198
    return -1;
199 199
    }
200 200

  
201
///////////////////////////////////////////////////////////////////////////////////////////////////
202

  
203
  private int numXMoves(int excludedLayer)
204
    {
205
    int num=0;
206
    for(int x=mStartX; x<mStartY; x++) if( mMoves[x]!=null && (x-mStartX)%mLayer[0]!=excludedLayer ) num++;
207
    return num;
208
    }
209

  
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211

  
212
  private int numYMoves(int excludedLayer)
213
    {
214
    int num=0;
215
    for(int y=mStartY; y<mStartZ; y++) if( mMoves[y]!=null && (y-mStartY)%mLayer[1]!=excludedLayer ) num++;
216
    return num;
217
    }
218

  
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

  
221
  private int numZMoves(int excludedLayer)
222
    {
223
    int num=0;
224
    for(int z=mStartZ; z<mNumMoves; z++) if( mMoves[z]!=null && (z-mStartZ)%mLayer[2]!=excludedLayer ) num++;
225
    return num;
226
    }
227

  
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

  
230
  public int numMoves(int excludedAxis, int excludedLayer)
231
    {
232
    switch(excludedAxis)
233
      {
234
      case AXIS_X: return numYMoves(excludedLayer)+numZMoves(excludedLayer);
235
      case AXIS_Y: return numXMoves(excludedLayer)+numZMoves(excludedLayer);
236
      case AXIS_Z: return numXMoves(excludedLayer)+numYMoves(excludedLayer);
237
      }
238

  
239
    return numXMoves(excludedLayer)+numYMoves(excludedLayer)+numZMoves(excludedLayer);
240
    }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
  public int getNthMove(int n, int excludedAxis, int excludedLayer)
245
    {
246
    int num = 0;
247

  
248
    if( excludedAxis!=0 )
249
      {
250
      for(int m=mStartX; m<mStartY; m++)
251
        if( mMoves[m]!=null && (m-mStartX)%mLayer[0]!=excludedLayer )
252
          {
253
          if( num==n ) return m;
254
          num++;
255
          }
256
      }
257

  
258
    if( excludedAxis!=1 )
259
      {
260
      for(int m=mStartY; m<mStartZ; m++)
261
        if( mMoves[m]!=null && (m-mStartY)%mLayer[1]!=excludedLayer )
262
          {
263
          if( num==n ) return m;
264
          num++;
265
          }
266
      }
267

  
268
    if( excludedAxis!=2 )
269
      {
270
      for(int m=mStartZ; m<mNumMoves; m++)
271
        if( mMoves[m]!=null && (m-mStartZ)%mLayer[2]!=excludedLayer )
272
          {
273
          if( num==n ) return m;
274
          num++;
275
          }
276
      }
277

  
278
    return -1;
279
    }
280

  
201 281
///////////////////////////////////////////////////////////////////////////////////////////////////
202 282

  
203 283
  private ObjectSignature[] createMoves()

Also available in: Unified diff