Project

General

Profile

« Previous | Next » 

Revision 91792184

Added by Leszek Koltunski over 2 years ago

Make object scrambling abstract (well, almost - with exception of Square-1 - this theoretically could also be done the generic way, but this would require almost 20000 'ScrambleStates')

View differences:

src/main/java/org/distorted/objects/TwistyDino.java
30 30
import org.distorted.library.type.Static3D;
31 31
import org.distorted.library.type.Static4D;
32 32

  
33
import java.util.Random;
34

  
35 33
///////////////////////////////////////////////////////////////////////////////////////////////////
36 34

  
37 35
public abstract class TwistyDino extends TwistyObject
......
52 50
           COLOR_RED   , COLOR_ORANGE
53 51
         };
54 52

  
55
  private int mCurrState;
56
  private int mIndexExcluded;
57
  private int[][] mScrambleTable;
58
  private int[] mNumOccurences;
59 53
  private int[] mBasicAngle;
60 54
  private Static4D[] mQuats;
61 55
  private ObjectSticker[] mStickers;
......
229 223
    return 2.0f;
230 224
    }
231 225

  
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

  
234
  private void initializeScrambling()
235
    {
236
    int numLayers = getNumLayers();
237

  
238
    if( mScrambleTable ==null )
239
      {
240
      mScrambleTable = new int[NUM_AXIS][numLayers];
241
      }
242
    if( mNumOccurences ==null )
243
      {
244
      int max=0;
245

  
246
      for (ScrambleState mState : mStates)
247
        {
248
        int tmp = mState.getTotal(-1);
249
        if (max < tmp) max = tmp;
250
        }
251

  
252
      mNumOccurences = new int[max];
253
      }
254

  
255
    for(int i=0; i<NUM_AXIS; i++)
256
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
257
    }
258

  
259 226
///////////////////////////////////////////////////////////////////////////////////////////////////
260 227
// PUBLIC API
261 228

  
262
  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
263
    {
264
    if( curr==0 )
265
      {
266
      mCurrState     = 0;
267
      mIndexExcluded =-1;
268
      initializeScrambling();
269
      }
270

  
271
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
272

  
273
    scramble[curr][0] = info[0];
274
    scramble[curr][1] = info[1];
275
    scramble[curr][2] = info[2];
276

  
277
    mCurrState     = info[3];
278
    mIndexExcluded = info[0];
279
    }
280

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

  
283 229
  public Static3D[] getRotationAxis()
284 230
    {
285 231
    return ROT_AXIS;

Also available in: Unified diff