Project

General

Profile

« Previous | Next » 

Revision 3ca97293

Added by Leszek Koltunski over 3 years ago

Correct rotations of the Pyraminx - eliminate one cse when three consecutive rotations collapse into one.

View differences:

src/main/java/org/distorted/effects/scramble/ScrambleEffect.java
271 271
    mBasicAngle = mObject.getBasicAngle();
272 272

  
273 273
    int numScrambles = cont.getNumScrambles();
274
    int dura = (int)(duration*Math.pow(numScrambles,0.6f));
274
    int dura = (int)(duration*Math.pow(numScrambles,0.66f));
275 275
    createBaseEffects(dura,numScrambles);
276 276
    createEffects    (dura,numScrambles);
277 277

  
src/main/java/org/distorted/objects/TwistyPyraminx.java
402 402
      }
403 403
    else
404 404
      {
405
      int newVector = rnd.nextInt(NUM_AXIS -1);
405
      int newVector = rnd.nextInt(NUM_AXIS-1);
406 406
      scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
407

  
408
      // Correct the situation when we first rotate the largest layer, then a tip (which doesn't
409
      // intersect anything besides the largest layer!) and then we try to rotate again along
410
      // the same axis like 2 rotations before - which carries the risk we rotate the largest
411
      // layer back to its spot again and the three moves end up being only a single tip rotation.
412
      if( curr>=2 && scramble[curr-1][1]==(numLayers-1) && scramble[curr][0]==scramble[curr-2][0] )
413
        {
414
        for(int ax=0; ax<NUM_AXIS; ax++)
415
          {
416
          if( scramble[curr-1][0]!=ax && scramble[curr-2][0]!=ax )
417
            {
418
            scramble[curr][0]=ax;
419
            break;
420
            }
421
          }
422
        }
407 423
      }
408 424

  
409 425
    float rowFloat = rnd.nextFloat();

Also available in: Unified diff