Project

General

Profile

« Previous | Next » 

Revision e342c3f7

Added by Leszek Koltunski almost 2 years ago

Introduce BlacklistedSignatures singleton: during type2 scrambling (locally-produced bandaged cuboids) remember the signatures that we've previously proven to be leading to a dead-end.

View differences:

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

  
20 20
package org.distorted.objectlib.scrambling;
21 21

  
22
import org.distorted.objectlib.helpers.ObjectSignature;
23

  
22 24
///////////////////////////////////////////////////////////////////////////////////////////////////
23 25
// Info about a scramble state of any bandaged cuboid.
24 26

  
25
import org.distorted.objectlib.helpers.ObjectSignature;
26

  
27 27
public class ScrambleStateBandagedCuboid
28 28
{
29 29
  public static int MAX_SUPPORTED_SIZE = 5;
......
42 42

  
43 43
///////////////////////////////////////////////////////////////////////////////////////////////////
44 44

  
45
  public ScrambleStateBandagedCuboid(int x, int y, int z, ObjectSignature signature)
45
  public ScrambleStateBandagedCuboid(int x, int y, int z, ObjectSignature signature, BlacklistedSignatures blacklisted)
46 46
    {
47 47
    mLayer = new int[3];
48 48
    mTurns = new int[3];
......
73 73
    mStartZ = xMoves + yMoves;
74 74

  
75 75
    mSignature = signature;
76
    mMoves = createMoves();
76
    mMoves = createMoves(blacklisted);
77 77
    }
78 78

  
79 79
///////////////////////////////////////////////////////////////////////////////////////////////////
......
280 280

  
281 281
///////////////////////////////////////////////////////////////////////////////////////////////////
282 282

  
283
  private ObjectSignature[] createMoves()
283
  private ObjectSignature[] createMoves(BlacklistedSignatures blacklisted)
284 284
    {
285 285
    ObjectSignature[] ret = new ObjectSignature[mNumMoves];
286 286
    int index = 0;
......
296 296
        for(int turn=1; turn<=mTurns[axis]; turn++)
297 297
          {
298 298
          boolean allLayersLocked = true;
299
          int begIndex = index;
299 300

  
300 301
          for(int layer=0; layer<mLayer[axis]; layer++)
301 302
            {
......
313 314
            index++;
314 315
            }
315 316

  
317
          for(int i=begIndex; i<index; i++)
318
            {
319
            if( ret[i]!=null && blacklisted.contains(ret[i]) ) ret[i]=null;
320
            }
321

  
316 322
          if( allLayersLocked ) ret[index-1] = null;
317 323
          }
318 324

  

Also available in: Unified diff