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/TwistyBandagedFused.java
101 101
    }
102 102

  
103 103
///////////////////////////////////////////////////////////////////////////////////////////////////
104
// PUBLIC API
105 104

  
106
  public int randomizeNewRotAxis(Random rnd, int oldRotAxis)
105
  public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow,
106
                                   int numScramble, int remScrambles, int remDoubleScrambles)
107 107
    {
108
    int numAxis = ROTATION_AXIS.length;
109

  
110
    if( oldRotAxis == START_AXIS )
108
    if( numScramble==1 )
111 109
      {
112
      return rnd.nextInt(numAxis);
110
      scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
113 111
      }
114 112
    else
115 113
      {
116
      int newVector = rnd.nextInt(numAxis-1);
117
      return (newVector>=oldRotAxis ? newVector+1 : newVector);
114
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
115
      scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
118 116
      }
119
    }
120

  
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122 117

  
123
  public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
124
    {
125 118
    float rowFloat = rnd.nextFloat();
126 119

  
127 120
    for(int row=0; row<mRowChances.length; row++)
128 121
      {
129
      if( rowFloat<=mRowChances[row] ) return row;
122
      if( rowFloat<=mRowChances[row] )
123
        {
124
        scramble[1] = row;
125
        break;
126
        }
130 127
      }
131 128

  
132
    return 0;
129
    int random = rnd.nextInt(remScrambles);
130
    int result = random<remDoubleScrambles ? 2:1;
131
    int sign   = rnd.nextInt(2);
132

  
133
    scramble[2] = sign==0 ? result : -result;
133 134
    }
134 135

  
135 136
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff