Project

General

Profile

« Previous | Next » 

Revision e50d4668

Added by Leszek Koltunski about 3 years ago

1) in case of several obejct, we need return to the original max num of scrambles - otherwise the records in the DB do not show.
2) implement proper automatic scrambling of the 2Bar and the 3Plate bandaged cubes.

View differences:

src/main/java/org/distorted/objects/TwistyBandaged2Bar.java
99 99

  
100 100
///////////////////////////////////////////////////////////////////////////////////////////////////
101 101
// PUBLIC API
102
// TODO
103 102

  
104 103
  public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
105 104
    {
106 105
    if( num==0 )
107 106
      {
108
      scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
107
      int random = rnd.nextInt(4);
108

  
109
      scramble[num][0] = 1;
110
      scramble[num][1] = random>1      ?  2:0;
111
      scramble[num][2] = random%2 == 0 ? -1:1;
109 112
      }
110 113
    else
111 114
      {
112
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
113
      scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
114
      }
115
      boolean even = ((num%2) == 0);
116
      int angle = rnd.nextInt(4);
115 117

  
116
    float rowFloat = rnd.nextFloat();
118
      scramble[num][0] = even ? 1 : scramble[0][1];
119
      scramble[num][1] = rnd.nextInt(3);
117 120

  
118
    for(int row=0; row<mRowChances.length; row++)
119
      {
120
      if( rowFloat<=mRowChances[row] )
121
      if( even == (scramble[num][1]==1) )
121 122
        {
122
        scramble[num][1] = row;
123
        break;
123
        switch(angle)
124
          {
125
          case 0: scramble[num][2] = -2; break;
126
          case 1: scramble[num][2] = -1; break;
127
          case 2: scramble[num][2] =  1; break;
128
          case 3: scramble[num][2] =  2; break;
129
          }
130
        }
131
      else
132
        {
133
        scramble[num][2] = angle>1 ? 2:-2;
124 134
        }
125
      }
126

  
127
    switch( rnd.nextInt(4) )
128
      {
129
      case 0: scramble[num][2] = -2; break;
130
      case 1: scramble[num][2] = -1; break;
131
      case 2: scramble[num][2] =  1; break;
132
      case 3: scramble[num][2] =  2; break;
133 135
      }
134 136
    }
135 137

  

Also available in: Unified diff