Project

General

Profile

« Previous | Next » 

Revision 9ba7f3f6

Added by Leszek Koltunski over 1 year ago

Move scrambling to a new model where there are spearete scrambling 'algorithms' and 'edges' of the scrambling graph.
Now each edge can contain a whole algorithm, i.e. a sequence of moves leading from state to state, which permits construction of scrambling for more complicated bandaged objects such as the AI cube.

Unchecked as of yet, probably still a lot of bugs.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyMasterball.java
22 22
import org.distorted.objectlib.main.InitData;
23 23
import org.distorted.objectlib.main.ObjectType;
24 24
import org.distorted.objectlib.shape.ShapeDiamond;
25
import org.distorted.objectlib.scrambling.ScrambleState;
26 25
import org.distorted.objectlib.touchcontrol.TouchControlBall;
27 26

  
28 27
import java.io.InputStream;
......
42 41

  
43 42
  private static final float D = 0.1f; // shape; keep between (-0.5,0.5)
44 43

  
45
  private ScrambleState[] mStates;
44
  private int[][] mEdges;
46 45
  private int[][] mBasicAngle;
47 46
  private int[] mQuatIndex;
48 47
  private float[][] mCuts;
......
63 62
    {
64 63
    final float X1 = -0.38861537f;
65 64
    final float Y1 = -0.4252297f;
66
    final float X2 = 0.5f;
65
    final float X2 =  0.5f;
67 66
    final float Y2 = -0.2860808f;
68
    final float X3 = 0.18867691f;
69
    final float Y3 = 0.39392126f;
67
    final float X3 =  0.18867691f;
68
    final float Y3 =  0.39392126f;
70 69
    final float X4 = -0.30006152f;
71
    final float Y4 = 0.3173893f;
70
    final float Y4 =  0.3173893f;
72 71

  
73 72
    final float Y = 0.02f;
74 73

  
......
112 111

  
113 112
///////////////////////////////////////////////////////////////////////////////////////////////////
114 113

  
115
  public ScrambleState[] getScrambleStates()
114
  public int[][] getScrambleEdges()
116 115
    {
117
    if( mStates==null )
116
    if( mEdges==null )
118 117
      {
119
      int[] H = {
120
                  0,-3,1, 0,-2,1, 0,-1,1, 0,1,1, 0,2,1, 0,3,1, 0,4,1,
121
                  1,-3,1, 1,-2,1, 1,-1,1, 1,1,1, 1,2,1, 1,3,1, 1,4,1,
122
                  2,-3,1, 2,-2,1, 2,-1,1, 2,1,1, 2,2,1, 2,3,1, 2,4,1,
123
                  3,-3,1, 3,-2,1, 3,-1,1, 3,1,1, 3,2,1, 3,3,1, 3,4,1
124
                };
125
      int[] V2= { 0,1,2, 1,1,2 };
126
      int[] V0= { 0,1,0, 1,1,0 };
127

  
128
      mStates = new ScrambleState[]
118
      mEdges = new int[][]
129 119
          {
130
          new ScrambleState( new int[][] {    H,null,null,null,null } ),  //  0: beginning; two last were vertical
131
          new ScrambleState( new int[][] { null,  V2,  V2,  V2,  V2 } ),  //  1: last was horizontal (i.e. along (0,1,0))
132
          new ScrambleState( new int[][] {    H,  V0,  V0,  V0,  V0 } ),  //  2: last was vertical and forelast horizontal
120
              {0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1,9,1,10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1},
121
              {28,2,29,2,30,2,31,2,32,2,33,2,34,2,35,2 },
122
              {0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1,9,1,10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,1,19,1,20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,
123
               28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0 }
133 124
          };
134 125
      }
135 126

  
136
    return mStates;
127
    return mEdges;
137 128
    }
138 129

  
139 130
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff