Project

General

Profile

« Previous | Next » 

Revision 38589947

Added by Leszek Koltunski over 2 years ago

Unify scrambling across all 4 bandaged objects.

View differences:

src/main/java/org/distorted/objects/TwistyBandaged3Plate.java
34 34

  
35 35
class TwistyBandaged3Plate extends TwistyBandagedAbstract
36 36
{
37
  private int mCurrState;
38
  private int mIndexExcluded;
39

  
40
  // The 16 'significant' states of the 3Plate bandaged cube.
41
  // One State means one arrangement of the three 2x2 'plates'. Such State precisely defines which
42
  // rotations of the Cube are possible.
43
  // There are 27 such states in total, but 2 of them are unreachable from the initial State, and
44
  // 9 more are 'insignificant' - i.e. States which only permit rotation along a single axis.
45
  // When doing an automatic scramble, we never want to enter such 'insignificant' states because
46
  // that would mean we'd have to do two rotations in a row along the same axis.
47
  //
48
  // 4th State's first 'x' array being '2,-1,10, 2, 2,13' means the following:
49
  // if we are in the 4th state, and make move (2,-1) [i.e. rotation along the X axis, 2nd row, -1 angle]
50
  // then we will land in state 10. If we make move (2,2), we will land in state 13. There are no other
51
  // 'x' moves that lead to a 'significant' state.
52

  
53
  private final ScrambleStateGraph[] mStates = new ScrambleStateGraph[]
54
    {
55
    new ScrambleStateGraph( new int[][] {{ 2,-1, 1, 2, 1, 6                  }, { 0,-1, 5, 0, 1, 3                  }, { 2,-1, 2, 2, 1, 4                  }} ),
56
    new ScrambleStateGraph( new int[][] {{ 2, 1, 0                           }, {                                   }, { 2, 1,10, 2, 2, 7                  }} ),
57
    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,11, 0, 2, 8                  }, { 2, 1, 0                           }} ),
58
    new ScrambleStateGraph( new int[][] {{ 2, 1,12, 2, 2, 9                  }, { 0,-1, 0                           }, {                                   }} ),
59
    new ScrambleStateGraph( new int[][] {{ 2,-1,10, 2, 2,13                  }, {                                   }, { 2,-1, 0                           }} ),
60
    new ScrambleStateGraph( new int[][] {{                                   }, { 0, 1, 0                           }, { 2,-1,11, 2, 2,14                  }} ),
61
    new ScrambleStateGraph( new int[][] {{ 2,-1, 0                           }, { 0, 1,12, 0, 2,15                  }, {                                   }} ),
62
    new ScrambleStateGraph( new int[][] {{                                   }, { 2,-2, 7, 2,-1, 7, 2, 1, 7, 2, 2, 7}, { 2,-1,10, 2, 2, 1                  }} ),
63
    new ScrambleStateGraph( new int[][] {{ 0,-2, 8, 0,-1, 8, 0, 1, 8, 0, 2, 8}, { 0, 1,11, 0, 2, 2                  }, {                                   }} ),
64
    new ScrambleStateGraph( new int[][] {{ 2,-1,12, 2, 2, 3                  }, {                                   }, { 0,-2, 9, 0,-1, 9, 0, 1, 9, 0, 2, 9}} ),
65
    new ScrambleStateGraph( new int[][] {{ 2,-1,13, 2, 1, 4                  }, { 2,-2,10, 2,-1,10, 2, 1,10, 2, 2,10}, { 2,-1, 1, 2, 1, 7                  }} ),
66
    new ScrambleStateGraph( new int[][] {{ 0,-2,11, 0,-1,11, 0, 1,11, 0, 2,11}, { 0,-1, 8, 0, 1, 2                  }, { 2,-1,14, 2, 1, 5                  }} ),
67
    new ScrambleStateGraph( new int[][] {{ 2,-1, 3, 2, 1, 9                  }, { 0,-1, 6, 0, 1,15                  }, { 0,-2,12, 0,-1,12, 0, 1,12, 0, 2,12}} ),
68
    new ScrambleStateGraph( new int[][] {{ 2, 1,10, 2, 2, 4                  }, { 2,-2,13, 2,-1,13, 2, 1,13, 2, 2,13}, {                                   }} ),
69
    new ScrambleStateGraph( new int[][] {{ 0,-2,14, 0,-1,14, 0, 1,14, 0, 2,14}, {                                   }, { 2, 1,11, 2, 2, 5                  }} ),
70
    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,12, 0, 2, 6                  }, { 0,-2,15, 0,-1,15, 0, 1,15, 0, 2,15}} )
71
    };
72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75 37
  private static final float[][] POSITIONS = new float[][]
76 38
      {
77 39
       {-1.0f,  1.0f,  1.0f, -1.0f,  0.0f,  1.0f,  0.0f,  1.0f,  1.0f,  0.0f,  0.0f,  1.0f},
......
101 63
                       DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
102 64
    {
103 65
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN3, res, scrWidth);
66

  
67
    mStates = new ScrambleStateGraph[]
68
    {
69
    new ScrambleStateGraph( new int[][] {{ 2,-1, 1, 2, 1, 6                  }, { 0,-1, 5, 0, 1, 3                  }, { 2,-1, 2, 2, 1, 4                  }} ),
70
    new ScrambleStateGraph( new int[][] {{ 2, 1, 0                           }, {                                   }, { 2, 1,10, 2, 2, 7                  }} ),
71
    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,11, 0, 2, 8                  }, { 2, 1, 0                           }} ),
72
    new ScrambleStateGraph( new int[][] {{ 2, 1,12, 2, 2, 9                  }, { 0,-1, 0                           }, {                                   }} ),
73
    new ScrambleStateGraph( new int[][] {{ 2,-1,10, 2, 2,13                  }, {                                   }, { 2,-1, 0                           }} ),
74
    new ScrambleStateGraph( new int[][] {{                                   }, { 0, 1, 0                           }, { 2,-1,11, 2, 2,14                  }} ),
75
    new ScrambleStateGraph( new int[][] {{ 2,-1, 0                           }, { 0, 1,12, 0, 2,15                  }, {                                   }} ),
76
    new ScrambleStateGraph( new int[][] {{                                   }, { 2,-2, 7, 2,-1, 7, 2, 1, 7, 2, 2, 7}, { 2,-1,10, 2, 2, 1                  }} ),
77
    new ScrambleStateGraph( new int[][] {{ 0,-2, 8, 0,-1, 8, 0, 1, 8, 0, 2, 8}, { 0, 1,11, 0, 2, 2                  }, {                                   }} ),
78
    new ScrambleStateGraph( new int[][] {{ 2,-1,12, 2, 2, 3                  }, {                                   }, { 0,-2, 9, 0,-1, 9, 0, 1, 9, 0, 2, 9}} ),
79
    new ScrambleStateGraph( new int[][] {{ 2,-1,13, 2, 1, 4                  }, { 2,-2,10, 2,-1,10, 2, 1,10, 2, 2,10}, { 2,-1, 1, 2, 1, 7                  }} ),
80
    new ScrambleStateGraph( new int[][] {{ 0,-2,11, 0,-1,11, 0, 1,11, 0, 2,11}, { 0,-1, 8, 0, 1, 2                  }, { 2,-1,14, 2, 1, 5                  }} ),
81
    new ScrambleStateGraph( new int[][] {{ 2,-1, 3, 2, 1, 9                  }, { 0,-1, 6, 0, 1,15                  }, { 0,-2,12, 0,-1,12, 0, 1,12, 0, 2,12}} ),
82
    new ScrambleStateGraph( new int[][] {{ 2, 1,10, 2, 2, 4                  }, { 2,-2,13, 2,-1,13, 2, 1,13, 2, 2,13}, {                                   }} ),
83
    new ScrambleStateGraph( new int[][] {{ 0,-2,14, 0,-1,14, 0, 1,14, 0, 2,14}, {                                   }, { 2, 1,11, 2, 2, 5                  }} ),
84
    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,12, 0, 2, 6                  }, { 0,-2,15, 0,-1,15, 0, 1,15, 0, 2,15}} )
85
    };
104 86
    }
105 87

  
106 88
///////////////////////////////////////////////////////////////////////////////////////////////////
......
120 102
///////////////////////////////////////////////////////////////////////////////////////////////////
121 103
// PUBLIC API
122 104

  
123
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
124
    {
125
    if( curr==0 )
126
      {
127
      mCurrState     = 0;
128
      mIndexExcluded =-1;
129
      }
130

  
131
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
132
    int random= rnd.nextInt(total);
133
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
134

  
135
    scramble[curr][0] = info[0];
136
    scramble[curr][1] = info[1];
137
    scramble[curr][2] = info[2];
138

  
139
    mCurrState     = info[3];
140
    mIndexExcluded = info[0];
141
    }
142

  
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

  
145 105
  public int getObjectName(int numLayers)
146 106
    {
147 107
    return R.string.bandaged_3plate;

Also available in: Unified diff