Revision f2d04089
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/objects/TwistyMinx.java | ||
---|---|---|
198 | 198 |
36, 34, 56, 32, 43, 21, 48, 28, 42, 23 |
199 | 199 |
}; |
200 | 200 |
|
201 |
static final boolean[][] OPPOSITE_ROWS = |
|
202 |
{ |
|
203 |
{false, true, false, true, false, false}, |
|
204 |
{ true, false, false, true, true, true}, |
|
205 |
{false, false, false, true, false, true}, |
|
206 |
{ true, true, true, false, false, true}, |
|
207 |
{false, true, false, false, false, true}, |
|
208 |
{false, true, true, true, true, false} |
|
209 |
}; |
|
210 |
|
|
201 | 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
202 | 212 |
|
203 | 213 |
TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
... | ... | |
298 | 308 |
|
299 | 309 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
300 | 310 |
{ |
301 |
float rowFloat = rnd.nextFloat(); |
|
311 |
if( oldRotAxis<0 ) |
|
312 |
{ |
|
313 |
float rowFloat = rnd.nextFloat(); |
|
302 | 314 |
|
303 |
for(int row=0; row<mRowChances.length; row++) |
|
315 |
for(int row=0; row<mRowChances.length; row++) |
|
316 |
{ |
|
317 |
if( rowFloat<=mRowChances[row] ) return row; |
|
318 |
} |
|
319 |
|
|
320 |
return 0; |
|
321 |
} |
|
322 |
else |
|
304 | 323 |
{ |
305 |
if( rowFloat<=mRowChances[row] ) return row; |
|
324 |
int size = mRowChances.length; |
|
325 |
int num = (size-1)/2; |
|
326 |
int row = rnd.nextInt(num); |
|
327 |
boolean opposite = OPPOSITE_ROWS[oldRotAxis][newRotAxis]; |
|
328 |
boolean low = opposite^(oldRow<num); |
|
329 |
return low ? row : size-1-row; |
|
306 | 330 |
} |
307 |
|
|
308 |
return 0; |
|
309 | 331 |
} |
310 | 332 |
|
311 | 333 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Improve the way we scramble the Kilo and Megaminx.