Project

General

Profile

« Previous | Next » 

Revision bbc6471c

Added by Leszek Koltunski about 3 years ago

Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.

View differences:

src/main/java/org/distorted/objects/TwistyPyraminx.java
33 33

  
34 34
import java.util.Random;
35 35

  
36
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
37

  
38 36
///////////////////////////////////////////////////////////////////////////////////////////////////
39 37

  
40 38
public class TwistyPyraminx extends TwistyObject
......
288 286

  
289 287
///////////////////////////////////////////////////////////////////////////////////////////////////
290 288

  
291
  public int randomizeNewRotAxis(Random rnd, int oldRotAxis)
289
  public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow,
290
                                   int numScramble, int remScrambles, int remDoubleScrambles)
292 291
    {
293
    int numAxis = ROTATION_AXIS.length;
294

  
295
    if( oldRotAxis == START_AXIS )
292
    if( numScramble==1 )
296 293
      {
297
      return rnd.nextInt(numAxis);
294
      scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
298 295
      }
299 296
    else
300 297
      {
301
      int newVector = rnd.nextInt(numAxis-1);
302
      return (newVector>=oldRotAxis ? newVector+1 : newVector);
298
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
299
      scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
303 300
      }
304
    }
305

  
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307 301

  
308
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
309
    {
310 302
    float rowFloat = rnd.nextFloat();
311 303

  
312 304
    for(int row=0; row<mRowChances.length; row++)
313 305
      {
314
      if( rowFloat<=mRowChances[row] ) return row;
306
      if( rowFloat<=mRowChances[row] )
307
        {
308
        scramble[1] = row;
309
        break;
310
        }
315 311
      }
316 312

  
317
    return 0;
313
    int random = rnd.nextInt(remScrambles);
314
    int result = random<remDoubleScrambles ? 2:1;
315
    int sign   = rnd.nextInt(2);
316

  
317
    scramble[2] = sign==0 ? result : -result;
318 318
    }
319 319

  
320 320
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff