Project

General

Profile

« Previous | Next » 

Revision 6cf89a3e

Added by Leszek Koltunski over 2 years ago

Introduce pseudorandom balancing into scrambling in case of the two Dinos (from now on, the more times a particular (ax,layer) combination has been chosen already in the scrambling sequence, the less likely it is to be chosen next).
Fix Dino6 - isSolved(). Sadly, it cannot be the geeneric function - it needs to be another special case.

View differences:

src/main/java/org/distorted/objects/TwistyDino.java
23 23

  
24 24
import org.distorted.helpers.ObjectShape;
25 25
import org.distorted.helpers.ObjectSticker;
26
import org.distorted.helpers.ScrambleStateGraph;
26
import org.distorted.helpers.ScrambleState;
27 27
import org.distorted.library.main.DistortedEffects;
28 28
import org.distorted.library.main.DistortedTexture;
29 29
import org.distorted.library.mesh.MeshSquare;
......
122 122

  
123 123
  private int mCurrState;
124 124
  private int mIndexExcluded;
125
  ScrambleStateGraph[] mStates;
125
  ScrambleState[] mStates;
126
  private int[][] mScrambleTable;
127
  private int[] mNumOccurences;
126 128

  
127 129
///////////////////////////////////////////////////////////////////////////////////////////////////
128 130

  
......
237 239
    return 2.0f;
238 240
    }
239 241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
  private void initializeScrambling()
245
    {
246
    int numLayers = getNumLayers();
247

  
248
    if( mScrambleTable ==null )
249
      {
250
      mScrambleTable = new int[NUM_AXIS][numLayers];
251
      }
252
    if( mNumOccurences ==null )
253
      {
254
      int max=0;
255

  
256
      for (ScrambleState mState : mStates)
257
        {
258
        int tmp = mState.getTotal(-1);
259
        if (max < tmp) max = tmp;
260
        }
261

  
262
      mNumOccurences = new int[max];
263
      }
264

  
265
    for(int i=0; i<NUM_AXIS; i++)
266
      for(int j=0; j<numLayers; j++) mScrambleTable[i][j] = 0;
267
    }
268

  
240 269
///////////////////////////////////////////////////////////////////////////////////////////////////
241 270
// PUBLIC API
242 271

  
......
246 275
      {
247 276
      mCurrState     = 0;
248 277
      mIndexExcluded =-1;
278
      initializeScrambling();
249 279
      }
250 280

  
251
    int total = mStates[mCurrState].getTotal(mIndexExcluded);
252
    int random= rnd.nextInt(total);
253
    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
281
    int[] info= mStates[mCurrState].getRandom(rnd, mIndexExcluded, mScrambleTable, mNumOccurences);
254 282

  
255 283
    scramble[curr][0] = info[0];
256 284
    scramble[curr][1] = info[1];

Also available in: Unified diff