Revision 5cf34c5f
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/effects/scramble/ScrambleEffect.java | ||
---|---|---|
72 | 72 |
private RubikObject mObject; |
73 | 73 |
private int mNumAxis; |
74 | 74 |
private int mBasicAngle; |
75 |
private int mSize;
|
|
75 |
private float[] mRowChances;
|
|
76 | 76 |
|
77 | 77 |
Effect[] mNodeEffects; |
78 | 78 |
int[] mNodeEffectPosition; |
... | ... | |
142 | 142 |
mLastVector = (newVector>=mLastVector ? newVector+1 : newVector); |
143 | 143 |
} |
144 | 144 |
|
145 |
int rowBitmap = (1<<mRnd.nextInt(mSize)); |
|
145 |
int row=0; |
|
146 |
float rowFloat = mRnd.nextFloat(); |
|
147 |
|
|
148 |
for(int i=0; i<mRowChances.length; i++) |
|
149 |
{ |
|
150 |
if( rowFloat<=mRowChances[i] ) |
|
151 |
{ |
|
152 |
row=i; |
|
153 |
break; |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
int rowBitmap = (1<<row); |
|
146 | 158 |
int angle= randomizeAngle(); |
147 | 159 |
int absAngle = (angle<0 ? -angle : angle); |
148 |
long durationMillis = absAngle*mDurationSingleTurn;
|
|
160 |
long durationMillis = absAngle*mDurationSingleTurn; |
|
149 | 161 |
|
150 | 162 |
mNumScramblesLeft--; |
151 | 163 |
if( absAngle==2 ) mNumDoubleScramblesLeft--; |
... | ... | |
306 | 318 |
{ |
307 | 319 |
mObject = post.getObject(); |
308 | 320 |
mPostRender = post; |
321 |
mRowChances = mObject.getRowChances(); |
|
309 | 322 |
|
310 | 323 |
mObject.solve(); |
311 | 324 |
|
312 | 325 |
mNumAxis = mObject.getRotationAxis().length; |
313 | 326 |
mBasicAngle = mObject.getBasicAngle(); |
314 |
mSize = mObject.getSize(); |
|
315 | 327 |
|
316 | 328 |
int numScrambles = post.getNumScrambles(); |
317 | 329 |
int dura = (int)(duration*Math.pow(numScrambles,0.6f)); |
src/main/java/org/distorted/objects/RubikCube.java | ||
---|---|---|
219 | 219 |
return getSize(); |
220 | 220 |
} |
221 | 221 |
|
222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
223 |
|
|
224 |
public float[] getRowChances() |
|
225 |
{ |
|
226 |
int size = getSize(); |
|
227 |
float[] chances = new float[size]; |
|
228 |
|
|
229 |
for(int i=0; i<size; i++) |
|
230 |
{ |
|
231 |
chances[i] = (i+1.0f) / size; |
|
232 |
} |
|
233 |
|
|
234 |
return chances; |
|
235 |
} |
|
236 |
|
|
222 | 237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
223 | 238 |
|
224 | 239 |
public float returnRotationFactor(float offset) |
... | ... | |
337 | 352 |
objectString.append(FACE_NAMES[color]); |
338 | 353 |
} |
339 | 354 |
|
340 |
// android.util.Log.e("cube", "string: "+objectString.toString()); |
|
341 |
|
|
342 | 355 |
return objectString.toString(); |
343 | 356 |
} |
344 | 357 |
} |
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
588 | 588 |
public abstract float returnMultiplier(); |
589 | 589 |
public abstract float returnRotationFactor(float offset); |
590 | 590 |
public abstract String retObjectString(); |
591 |
public abstract float[] getRowChances(); |
|
591 | 592 |
} |
src/main/java/org/distorted/objects/RubikPyraminx.java | ||
---|---|---|
310 | 310 |
return getSize()/(SQ3/2); |
311 | 311 |
} |
312 | 312 |
|
313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
314 |
|
|
315 |
public float[] getRowChances() |
|
316 |
{ |
|
317 |
int size = getSize(); |
|
318 |
int total = size*(size+1)/2; |
|
319 |
float running=0.0f; |
|
320 |
float[] chances = new float[size]; |
|
321 |
|
|
322 |
for(int i=0; i<size; i++) |
|
323 |
{ |
|
324 |
running += (size-i); |
|
325 |
chances[i] = running / total; |
|
326 |
} |
|
327 |
|
|
328 |
return chances; |
|
329 |
} |
|
330 |
|
|
313 | 331 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
314 | 332 |
|
315 | 333 |
public float returnRotationFactor(float offset) |
Also available in: Unified diff
Make chances to randimoze a given row when scrambling dependant on the type of Object.
The point: in case of the Cube, all rows should have equal chances. In case of the Pyraminx, the smaller the row, the smaller the chance should be. In particular the trivial 4 corners of the tetraherdon should have a very small chance to be selected.