Revision bbc6471c
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/effects/scramble/ScrambleEffect.java | ||
---|---|---|
49 | 49 |
} |
50 | 50 |
} |
51 | 51 |
|
52 |
private static int NUM_EFFECTS = Type.values().length; |
|
52 |
private static final int NUM_EFFECTS = Type.values().length;
|
|
53 | 53 |
private static final int FAKE_EFFECT_ID = -3; |
54 | 54 |
private static final Type[] types; |
55 | 55 |
|
... | ... | |
72 | 72 |
private int mNumDoubleScramblesLeft, mNumScramblesLeft; |
73 | 73 |
private int mLastRotAxis, mLastRow; |
74 | 74 |
private long mDurationSingleTurn; |
75 |
private Random mRnd; |
|
75 |
private final Random mRnd;
|
|
76 | 76 |
private int mBasicAngle; |
77 | 77 |
|
78 | 78 |
TwistyObject mObject; |
... | ... | |
81 | 81 |
Effect[] mCubeEffects; |
82 | 82 |
int[] mCubeEffectPosition; |
83 | 83 |
int mCubeEffectNumber, mNodeEffectNumber; |
84 |
int mNumScrambles; |
|
85 |
int[] mScramble; |
|
84 | 86 |
|
85 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
86 | 88 |
|
87 | 89 |
ScrambleEffect() |
88 | 90 |
{ |
89 | 91 |
mRnd = new Random( System.currentTimeMillis() ); |
92 |
mScramble = new int[3]; |
|
90 | 93 |
mLastRotAxis = START_AXIS; |
91 | 94 |
} |
92 | 95 |
|
... | ... | |
125 | 128 |
} |
126 | 129 |
|
127 | 130 |
mDurationSingleTurn = duration/(mNumScramblesLeft+mNumDoubleScramblesLeft); |
131 |
mNumScrambles = 0; |
|
128 | 132 |
|
129 | 133 |
addNewScramble(); |
130 | 134 |
} |
... | ... | |
136 | 140 |
{ |
137 | 141 |
if( mNumScramblesLeft>0 ) |
138 | 142 |
{ |
139 |
int lastRotAxis = mLastRotAxis; |
|
140 |
mLastRotAxis = mObject.randomizeNewRotAxis(mRnd,mLastRotAxis); |
|
141 |
mLastRow = mObject.randomizeNewRow(mRnd,lastRotAxis,mLastRow,mLastRotAxis); |
|
143 |
mNumScrambles++; |
|
144 |
|
|
145 |
mObject.randomizeNewScramble(mScramble, mRnd,mLastRotAxis, mLastRow, mNumScrambles, |
|
146 |
mNumScramblesLeft, mNumDoubleScramblesLeft); |
|
147 |
mLastRotAxis = mScramble[0]; |
|
148 |
mLastRow = mScramble[1]; |
|
149 |
int angle = mScramble[2]; |
|
142 | 150 |
|
143 | 151 |
int rowBitmap = (1<<mLastRow); |
144 |
int angle= randomizeAngle(); |
|
145 | 152 |
int absAngle = (angle<0 ? -angle : angle); |
146 | 153 |
long durationMillis = absAngle*mDurationSingleTurn; |
147 | 154 |
|
... | ... | |
166 | 173 |
} |
167 | 174 |
} |
168 | 175 |
|
169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
170 |
// only works for basicAngle<=5. |
|
171 |
|
|
172 |
private int randomizeAngle() |
|
173 |
{ |
|
174 |
int random = mRnd.nextInt(mNumScramblesLeft); |
|
175 |
int result = random<mNumDoubleScramblesLeft ? 2:1; |
|
176 |
int sign = mRnd.nextInt(2); |
|
177 |
|
|
178 |
return sign==0 ? result : -result; |
|
179 |
} |
|
180 |
|
|
181 | 176 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
182 | 177 |
|
183 | 178 |
private void assignEffects() |
src/main/java/org/distorted/objects/ObjectList.java | ||
---|---|---|
61 | 61 |
|
62 | 62 |
DIAM ( |
63 | 63 |
new int[][] { |
64 |
{2 , 10, R.raw.diamond, R.drawable.ui_small_diam, R.drawable.ui_medium_diam, R.drawable.ui_big_diam, R.drawable.ui_huge_diam} ,
|
|
64 |
{2 , 12, R.raw.diamond, R.drawable.ui_small_diam, R.drawable.ui_medium_diam, R.drawable.ui_big_diam, R.drawable.ui_huge_diam} ,
|
|
65 | 65 |
}, |
66 | 66 |
TwistyDiamond.class, |
67 | 67 |
new MovementDiamond(), |
... | ... | |
71 | 71 |
|
72 | 72 |
DINO ( |
73 | 73 |
new int[][] { |
74 |
{3 , 10, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
|
|
74 |
{3 , 12, R.raw.dino, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
|
|
75 | 75 |
}, |
76 | 76 |
TwistyDino6.class, |
77 | 77 |
new MovementDino(), |
... | ... | |
91 | 91 |
|
92 | 92 |
REDI ( |
93 | 93 |
new int[][] { |
94 |
{3 , 14, R.raw.redi, R.drawable.ui_small_redi, R.drawable.ui_medium_redi, R.drawable.ui_big_redi, R.drawable.ui_huge_redi} ,
|
|
94 |
{3 , 18, R.raw.redi, R.drawable.ui_small_redi, R.drawable.ui_medium_redi, R.drawable.ui_big_redi, R.drawable.ui_huge_redi} ,
|
|
95 | 95 |
}, |
96 | 96 |
TwistyRedi.class, |
97 | 97 |
new MovementRedi(), |
... | ... | |
101 | 101 |
|
102 | 102 |
HELI ( |
103 | 103 |
new int[][] { |
104 |
{3 , 18, R.raw.heli, R.drawable.ui_small_heli, R.drawable.ui_medium_heli, R.drawable.ui_big_heli, R.drawable.ui_huge_heli} ,
|
|
104 |
{3 , 20, R.raw.heli, R.drawable.ui_small_heli, R.drawable.ui_medium_heli, R.drawable.ui_big_heli, R.drawable.ui_huge_heli} ,
|
|
105 | 105 |
}, |
106 | 106 |
TwistyHelicopter.class, |
107 | 107 |
new MovementHelicopter(), |
... | ... | |
111 | 111 |
|
112 | 112 |
SKEW ( |
113 | 113 |
new int[][] { |
114 |
{2 , 11, R.raw.skewb, R.drawable.ui_small_skewb, R.drawable.ui_medium_skewb, R.drawable.ui_big_skewb, R.drawable.ui_huge_skewb} ,
|
|
115 |
{3 , 17, R.raw.skewm, R.drawable.ui_small_skewm, R.drawable.ui_medium_skewm, R.drawable.ui_big_skewm, R.drawable.ui_huge_skewm} ,
|
|
114 |
{2 , 12, R.raw.skewb, R.drawable.ui_small_skewb, R.drawable.ui_medium_skewb, R.drawable.ui_big_skewb, R.drawable.ui_huge_skewb} ,
|
|
115 |
{3 , 21, R.raw.skewm, R.drawable.ui_small_skewm, R.drawable.ui_medium_skewm, R.drawable.ui_big_skewm, R.drawable.ui_huge_skewm} ,
|
|
116 | 116 |
}, |
117 | 117 |
TwistySkewb.class, |
118 | 118 |
new MovementSkewb(), |
... | ... | |
132 | 132 |
|
133 | 133 |
REX ( |
134 | 134 |
new int[][] { |
135 |
{3 , 16, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
|
|
135 |
{3 , 18, R.raw.rex, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
|
|
136 | 136 |
}, |
137 | 137 |
TwistyRex.class, |
138 | 138 |
new MovementRex(), |
... | ... | |
152 | 152 |
|
153 | 153 |
MEGA ( |
154 | 154 |
new int[][] { |
155 |
{3 , 21, R.raw.mega3, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} ,
|
|
155 |
{3 , 24, R.raw.mega3, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} ,
|
|
156 | 156 |
{5 , 35, R.raw.mega5, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} , |
157 | 157 |
}, |
158 | 158 |
TwistyMegaminx.class, |
src/main/java/org/distorted/objects/TwistyBandaged2Bar.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Random; |
31 | 31 |
|
32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
class TwistyBandaged2Bar extends TwistyBandagedAbstract |
... | ... | |
102 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
103 | 101 |
// PUBLIC API |
104 | 102 |
// TODO |
105 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
106 |
{ |
|
107 |
int numAxis = ROTATION_AXIS.length; |
|
108 | 103 |
|
109 |
if( oldRotAxis == START_AXIS ) |
|
104 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
105 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
106 |
{ |
|
107 |
if( numScramble==1 ) |
|
110 | 108 |
{ |
111 |
return rnd.nextInt(numAxis);
|
|
109 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
112 | 110 |
} |
113 | 111 |
else |
114 | 112 |
{ |
115 |
int newVector = rnd.nextInt(numAxis-1);
|
|
116 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
113 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
114 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
117 | 115 |
} |
118 |
} |
|
119 | 116 |
|
120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
121 |
// TODO |
|
122 |
|
|
123 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
124 |
{ |
|
125 | 117 |
float rowFloat = rnd.nextFloat(); |
126 | 118 |
|
127 | 119 |
for(int row=0; row<mRowChances.length; row++) |
128 | 120 |
{ |
129 |
if( rowFloat<=mRowChances[row] ) return row; |
|
121 |
if( rowFloat<=mRowChances[row] ) |
|
122 |
{ |
|
123 |
scramble[1] = row; |
|
124 |
break; |
|
125 |
} |
|
130 | 126 |
} |
131 | 127 |
|
132 |
return 0; |
|
128 |
int random = rnd.nextInt(remScrambles); |
|
129 |
int result = random<remDoubleScrambles ? 2:1; |
|
130 |
int sign = rnd.nextInt(2); |
|
131 |
|
|
132 |
scramble[2] = sign==0 ? result : -result; |
|
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyBandaged3Plate.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Random; |
31 | 31 |
|
32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
class TwistyBandaged3Plate extends TwistyBandagedAbstract |
... | ... | |
108 | 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
109 | 107 |
// PUBLIC API |
110 | 108 |
// TODO |
111 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
112 |
{ |
|
113 |
int numAxis = ROTATION_AXIS.length; |
|
114 | 109 |
|
115 |
if( oldRotAxis == START_AXIS ) |
|
110 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
111 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
112 |
{ |
|
113 |
if( numScramble==1 ) |
|
116 | 114 |
{ |
117 |
return rnd.nextInt(numAxis);
|
|
115 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
118 | 116 |
} |
119 | 117 |
else |
120 | 118 |
{ |
121 |
int newVector = rnd.nextInt(numAxis-1);
|
|
122 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
119 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
120 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
123 | 121 |
} |
124 |
} |
|
125 |
|
|
126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
127 |
// TODO |
|
128 | 122 |
|
129 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
130 |
{ |
|
131 | 123 |
float rowFloat = rnd.nextFloat(); |
132 | 124 |
|
133 | 125 |
for(int row=0; row<mRowChances.length; row++) |
134 | 126 |
{ |
135 |
if( rowFloat<=mRowChances[row] ) return row; |
|
127 |
if( rowFloat<=mRowChances[row] ) |
|
128 |
{ |
|
129 |
scramble[1] = row; |
|
130 |
break; |
|
131 |
} |
|
136 | 132 |
} |
137 | 133 |
|
138 |
return 0; |
|
134 |
int random = rnd.nextInt(remScrambles); |
|
135 |
int result = random<remDoubleScrambles ? 2:1; |
|
136 |
int sign = rnd.nextInt(2); |
|
137 |
|
|
138 |
scramble[2] = sign==0 ? result : -result; |
|
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyBandagedEvil.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Random; |
31 | 31 |
|
32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
class TwistyBandagedEvil extends TwistyBandagedAbstract |
... | ... | |
120 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | 119 |
// PUBLIC API |
122 | 120 |
// TODO |
123 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
124 |
{ |
|
125 |
int numAxis = ROTATION_AXIS.length; |
|
126 | 121 |
|
127 |
if( oldRotAxis == START_AXIS ) |
|
122 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
123 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
124 |
{ |
|
125 |
if( numScramble==1 ) |
|
128 | 126 |
{ |
129 |
return rnd.nextInt(numAxis);
|
|
127 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
130 | 128 |
} |
131 | 129 |
else |
132 | 130 |
{ |
133 |
int newVector = rnd.nextInt(numAxis-1);
|
|
134 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
131 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
132 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
135 | 133 |
} |
136 |
} |
|
137 | 134 |
|
138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
139 |
// TODO |
|
140 |
|
|
141 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
142 |
{ |
|
143 | 135 |
float rowFloat = rnd.nextFloat(); |
144 | 136 |
|
145 | 137 |
for(int row=0; row<mRowChances.length; row++) |
146 | 138 |
{ |
147 |
if( rowFloat<=mRowChances[row] ) return row; |
|
139 |
if( rowFloat<=mRowChances[row] ) |
|
140 |
{ |
|
141 |
scramble[1] = row; |
|
142 |
break; |
|
143 |
} |
|
148 | 144 |
} |
149 | 145 |
|
150 |
return 0; |
|
146 |
int random = rnd.nextInt(remScrambles); |
|
147 |
int result = random<remDoubleScrambles ? 2:1; |
|
148 |
int sign = rnd.nextInt(2); |
|
149 |
|
|
150 |
scramble[2] = sign==0 ? result : -result; |
|
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyCube.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 |
class TwistyCube extends TwistyObject |
... | ... | |
256 | 254 |
|
257 | 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
258 | 256 |
|
259 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
257 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
258 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
260 | 259 |
{ |
261 |
int numAxis = ROTATION_AXIS.length; |
|
262 |
|
|
263 |
if( oldRotAxis == START_AXIS ) |
|
260 |
if( numScramble==1 ) |
|
264 | 261 |
{ |
265 |
return rnd.nextInt(numAxis);
|
|
262 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
266 | 263 |
} |
267 | 264 |
else |
268 | 265 |
{ |
269 |
int newVector = rnd.nextInt(numAxis-1);
|
|
270 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
266 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
267 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
271 | 268 |
} |
272 |
} |
|
273 |
|
|
274 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
275 | 269 |
|
276 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
277 |
{ |
|
278 | 270 |
float rowFloat = rnd.nextFloat(); |
279 | 271 |
|
280 | 272 |
for(int row=0; row<mRowChances.length; row++) |
281 | 273 |
{ |
282 |
if( rowFloat<=mRowChances[row] ) return row; |
|
274 |
if( rowFloat<=mRowChances[row] ) |
|
275 |
{ |
|
276 |
scramble[1] = row; |
|
277 |
break; |
|
278 |
} |
|
283 | 279 |
} |
284 | 280 |
|
285 |
return 0; |
|
281 |
int random = rnd.nextInt(remScrambles); |
|
282 |
int result = random<remDoubleScrambles ? 2:1; |
|
283 |
int sign = rnd.nextInt(2); |
|
284 |
|
|
285 |
scramble[2] = sign==0 ? result : -result; |
|
286 | 286 |
} |
287 | 287 |
|
288 | 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.Random; |
37 | 37 |
|
38 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
39 |
|
|
40 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 39 |
|
42 | 40 |
public class TwistyDiamond extends TwistyObject |
... | ... | |
293 | 291 |
|
294 | 292 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
295 | 293 |
|
296 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
294 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
295 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
297 | 296 |
{ |
298 |
int numAxis = ROTATION_AXIS.length; |
|
299 |
|
|
300 |
if( oldRotAxis == START_AXIS ) |
|
297 |
if( numScramble==1 ) |
|
301 | 298 |
{ |
302 |
return rnd.nextInt(numAxis);
|
|
299 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
303 | 300 |
} |
304 | 301 |
else |
305 | 302 |
{ |
306 |
int newVector = rnd.nextInt(numAxis-1);
|
|
307 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
303 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
304 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
308 | 305 |
} |
309 |
} |
|
310 | 306 |
|
311 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
312 |
|
|
313 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
314 |
{ |
|
315 | 307 |
float rowFloat = rnd.nextFloat(); |
316 | 308 |
|
317 | 309 |
for(int row=0; row<mRowChances.length; row++) |
318 | 310 |
{ |
319 |
if( rowFloat<=mRowChances[row] ) return row; |
|
311 |
if( rowFloat<=mRowChances[row] ) |
|
312 |
{ |
|
313 |
scramble[1] = row; |
|
314 |
break; |
|
315 |
} |
|
320 | 316 |
} |
321 | 317 |
|
322 |
return 0; |
|
318 |
int random = rnd.nextInt(remScrambles); |
|
319 |
int result = random<remDoubleScrambles ? 2:1; |
|
320 |
int sign = rnd.nextInt(2); |
|
321 |
|
|
322 |
scramble[2] = sign==0 ? result : -result; |
|
323 | 323 |
} |
324 | 324 |
|
325 | 325 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.type.Static4D; |
33 | 33 |
import org.distorted.main.RubikSurfaceView; |
34 | 34 |
|
35 |
import java.util.Random; |
|
36 |
|
|
37 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
38 |
|
|
39 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 36 |
|
41 | 37 |
public abstract class TwistyDino extends TwistyObject |
... | ... | |
250 | 246 |
return 3; |
251 | 247 |
} |
252 | 248 |
|
253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
254 |
|
|
255 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
256 |
{ |
|
257 |
int numAxis = ROTATION_AXIS.length; |
|
258 |
|
|
259 |
if( oldRotAxis == START_AXIS ) |
|
260 |
{ |
|
261 |
return rnd.nextInt(numAxis); |
|
262 |
} |
|
263 |
else |
|
264 |
{ |
|
265 |
int newVector = rnd.nextInt(numAxis-1); |
|
266 |
return (newVector>=oldRotAxis ? newVector+1 : newVector); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
271 | 250 |
// only needed for solvers - there are no Dino solvers ATM) |
272 | 251 |
|
src/main/java/org/distorted/objects/TwistyDino4.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Random; |
31 | 31 |
|
32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
public class TwistyDino4 extends TwistyDino |
... | ... | |
68 | 66 |
|
69 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
70 | 68 |
|
71 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
69 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
70 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
72 | 71 |
{ |
73 |
return (oldRotAxis==START_AXIS) ? ((newRotAxis==1 || newRotAxis==2) ? 0:2) : (oldRotAxis+newRotAxis==3 ? 2-oldRow : oldRow); |
|
72 |
if( numScramble==1 ) |
|
73 |
{ |
|
74 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
75 |
} |
|
76 |
else |
|
77 |
{ |
|
78 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1); |
|
79 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector); |
|
80 |
} |
|
81 |
|
|
82 |
scramble[1] = (numScramble==1) ? ((scramble[0]==1 || scramble[0]==2) ? 0:2) : (oldRotAxis+scramble[0]==3 ? 2-oldRow : oldRow); |
|
83 |
|
|
84 |
int random = rnd.nextInt(remScrambles); |
|
85 |
int result = random<remDoubleScrambles ? 2:1; |
|
86 |
int sign = rnd.nextInt(2); |
|
87 |
|
|
88 |
scramble[2] = sign==0 ? result : -result; |
|
74 | 89 |
} |
75 | 90 |
|
76 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDino6.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Random; |
31 | 31 |
|
32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
public class TwistyDino6 extends TwistyDino |
... | ... | |
68 | 66 |
|
69 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
70 | 68 |
|
71 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
69 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
70 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
72 | 71 |
{ |
73 |
return (oldRotAxis==START_AXIS) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+newRotAxis==3 ? 2-oldRow : oldRow); |
|
72 |
if( numScramble==1 ) |
|
73 |
{ |
|
74 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length); |
|
75 |
} |
|
76 |
else |
|
77 |
{ |
|
78 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1); |
|
79 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector); |
|
80 |
} |
|
81 |
|
|
82 |
scramble[1] = (numScramble==1) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+scramble[0]==3 ? 2-oldRow : oldRow); |
|
83 |
|
|
84 |
int random = rnd.nextInt(remScrambles); |
|
85 |
int result = random<remDoubleScrambles ? 2:1; |
|
86 |
int sign = rnd.nextInt(2); |
|
87 |
|
|
88 |
scramble[2] = sign==0 ? result : -result; |
|
74 | 89 |
} |
75 | 90 |
|
76 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.Random; |
37 | 37 |
|
38 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
39 |
|
|
40 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 39 |
|
42 | 40 |
public class TwistyHelicopter extends TwistyObject |
... | ... | |
337 | 335 |
|
338 | 336 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
339 | 337 |
|
340 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
338 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
339 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
341 | 340 |
{ |
342 |
int numAxis = ROTATION_AXIS.length; |
|
343 |
|
|
344 |
if( oldRotAxis == START_AXIS ) |
|
341 |
if( numScramble==1 ) |
|
345 | 342 |
{ |
346 |
return rnd.nextInt(numAxis);
|
|
343 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
347 | 344 |
} |
348 | 345 |
else |
349 | 346 |
{ |
350 |
int newVector = rnd.nextInt(numAxis-2);
|
|
347 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-2);
|
|
351 | 348 |
|
352 | 349 |
switch(oldRotAxis) |
353 | 350 |
{ |
354 | 351 |
case 0: |
355 |
case 1: return newVector+2; |
|
352 |
case 1: scramble[0] = newVector+2; |
|
353 |
break; |
|
356 | 354 |
case 2: |
357 |
case 3: return (newVector==0 || newVector==1) ? newVector:newVector+2; |
|
358 |
default: return newVector; |
|
355 |
case 3: scramble[0] = (newVector==0 || newVector==1) ? newVector:newVector+2; |
|
356 |
break; |
|
357 |
default: scramble[0] = newVector; |
|
358 |
break; |
|
359 | 359 |
} |
360 | 360 |
} |
361 |
} |
|
362 |
|
|
363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
364 | 361 |
|
365 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
366 |
{ |
|
367 | 362 |
float rowFloat = rnd.nextFloat(); |
368 | 363 |
|
369 | 364 |
for(int row=0; row<mRowChances.length; row++) |
370 | 365 |
{ |
371 |
if( rowFloat<=mRowChances[row] ) return row; |
|
366 |
if( rowFloat<=mRowChances[row] ) |
|
367 |
{ |
|
368 |
scramble[1] = row; |
|
369 |
break; |
|
370 |
} |
|
372 | 371 |
} |
373 | 372 |
|
374 |
return 0; |
|
373 |
int random = rnd.nextInt(remScrambles); |
|
374 |
int result = random<remDoubleScrambles ? 2:1; |
|
375 |
int sign = rnd.nextInt(2); |
|
376 |
|
|
377 |
scramble[2] = sign==0 ? result : -result; |
|
375 | 378 |
} |
376 | 379 |
|
377 | 380 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.Random; |
37 | 37 |
|
38 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
39 |
|
|
40 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 39 |
|
42 | 40 |
public class TwistyIvy extends TwistyObject |
... | ... | |
283 | 281 |
|
284 | 282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
285 | 283 |
|
286 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
284 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
285 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
287 | 286 |
{ |
288 |
int numAxis = ROTATION_AXIS.length; |
|
289 |
|
|
290 |
if( oldRotAxis == START_AXIS ) |
|
287 |
if( numScramble==1 ) |
|
291 | 288 |
{ |
292 |
return rnd.nextInt(numAxis);
|
|
289 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
293 | 290 |
} |
294 | 291 |
else |
295 | 292 |
{ |
296 |
int newVector = rnd.nextInt(numAxis-1);
|
|
297 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
293 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
294 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
298 | 295 |
} |
299 |
} |
|
300 |
|
|
301 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
302 | 296 |
|
303 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
304 |
{ |
|
305 | 297 |
float rowFloat = rnd.nextFloat(); |
306 | 298 |
|
307 | 299 |
for(int row=0; row<mRowChances.length; row++) |
308 | 300 |
{ |
309 |
if( rowFloat<=mRowChances[row] ) return row; |
|
301 |
if( rowFloat<=mRowChances[row] ) |
|
302 |
{ |
|
303 |
scramble[1] = row; |
|
304 |
break; |
|
305 |
} |
|
310 | 306 |
} |
311 | 307 |
|
312 |
return 0; |
|
308 |
int random = rnd.nextInt(remScrambles); |
|
309 |
int result = random<remDoubleScrambles ? 2:1; |
|
310 |
int sign = rnd.nextInt(2); |
|
311 |
|
|
312 |
scramble[2] = sign==0 ? result : -result; |
|
313 | 313 |
} |
314 | 314 |
|
315 | 315 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyMinx.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Random; |
31 | 31 |
|
32 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
33 |
|
|
34 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 33 |
|
36 | 34 |
abstract class TwistyMinx extends TwistyObject |
... | ... | |
282 | 280 |
|
283 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
284 | 282 |
|
285 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
283 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
284 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
286 | 285 |
{ |
287 |
int numAxis = ROTATION_AXIS.length; |
|
288 |
|
|
289 |
if( oldRotAxis == START_AXIS ) |
|
286 |
if( numScramble==1 ) |
|
290 | 287 |
{ |
291 |
return rnd.nextInt(numAxis);
|
|
288 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
292 | 289 |
} |
293 | 290 |
else |
294 | 291 |
{ |
295 |
int newVector = rnd.nextInt(numAxis-1);
|
|
296 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
292 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
293 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
297 | 294 |
} |
298 |
} |
|
299 |
|
|
300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
301 | 295 |
|
302 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
303 |
{ |
|
304 |
if( oldRotAxis<0 ) |
|
296 |
if( numScramble==1 ) |
|
305 | 297 |
{ |
306 | 298 |
float rowFloat = rnd.nextFloat(); |
307 | 299 |
|
308 | 300 |
for(int row=0; row<mRowChances.length; row++) |
309 | 301 |
{ |
310 |
if( rowFloat<=mRowChances[row] ) return row; |
|
302 |
if( rowFloat<=mRowChances[row] ) |
|
303 |
{ |
|
304 |
scramble[1] = row; |
|
305 |
break; |
|
306 |
} |
|
311 | 307 |
} |
312 |
|
|
313 |
return 0; |
|
314 | 308 |
} |
315 | 309 |
else |
316 | 310 |
{ |
317 | 311 |
int size = mRowChances.length; |
318 | 312 |
int num = (size-1)/2; |
319 | 313 |
int row = rnd.nextInt(num); |
320 |
boolean opposite = OPPOSITE_ROWS[oldRotAxis][newRotAxis];
|
|
314 |
boolean opposite = OPPOSITE_ROWS[oldRotAxis][scramble[0]];
|
|
321 | 315 |
boolean low = opposite^(oldRow<num); |
322 |
return low ? row : size-1-row;
|
|
316 |
scramble[1] = low ? row : size-1-row;
|
|
323 | 317 |
} |
318 |
|
|
319 |
int random = rnd.nextInt(remScrambles); |
|
320 |
int result = random<remDoubleScrambles ? 2:1; |
|
321 |
int sign = rnd.nextInt(2); |
|
322 |
|
|
323 |
scramble[2] = sign==0 ? result : -result; |
|
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
913 | 913 |
public abstract Static3D[] getRotationAxis(); |
914 | 914 |
public abstract int getBasicAngle(); |
915 | 915 |
public abstract String retObjectString(); |
916 |
public abstract int randomizeNewRotAxis(Random rnd, int oldRotAxis); |
|
917 |
public abstract int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis); |
|
916 |
public abstract void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, int numScramble, int remScrambles, int remDoubleScrambles); |
|
918 | 917 |
public abstract int getObjectName(int numLayers); |
919 | 918 |
public abstract int getInventor(int numLayers); |
920 | 919 |
public abstract int getComplexity(int numLayers); |
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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
import java.util.Random; |
36 | 36 |
|
37 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
38 |
|
|
39 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 38 |
|
41 | 39 |
public class TwistyRedi extends TwistyObject |
... | ... | |
330 | 328 |
|
331 | 329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
332 | 330 |
|
333 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
331 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
332 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
334 | 333 |
{ |
335 |
int numAxis = ROTATION_AXIS.length; |
|
336 |
|
|
337 |
if( oldRotAxis == START_AXIS ) |
|
334 |
if( numScramble==1 ) |
|
338 | 335 |
{ |
339 |
return rnd.nextInt(numAxis);
|
|
336 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
340 | 337 |
} |
341 | 338 |
else |
342 | 339 |
{ |
343 |
int newVector = rnd.nextInt(numAxis-1);
|
|
344 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
340 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
341 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
345 | 342 |
} |
346 |
} |
|
347 | 343 |
|
348 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
344 |
scramble[1] = (numScramble==1) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+scramble[0]==3 ? 2-oldRow : oldRow);
|
|
349 | 345 |
|
350 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
351 |
{ |
|
352 |
return (oldRotAxis==START_AXIS) ? (rnd.nextFloat()<=0.5f ? 0:2) : (oldRotAxis+newRotAxis==3 ? 2-oldRow : oldRow); |
|
346 |
int random = rnd.nextInt(remScrambles); |
|
347 |
int result = random<remDoubleScrambles ? 2:1; |
|
348 |
int sign = rnd.nextInt(2); |
|
349 |
|
|
350 |
scramble[2] = sign==0 ? result : -result; |
|
353 | 351 |
} |
354 | 352 |
|
355 | 353 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.Random; |
37 | 37 |
|
38 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
39 | 38 |
import static org.distorted.objects.FactoryCubit.REX_D; |
40 | 39 |
|
41 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
393 | 392 |
|
394 | 393 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
395 | 394 |
|
396 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
395 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
396 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
397 | 397 |
{ |
398 |
int numAxis = ROTATION_AXIS.length; |
|
399 |
|
|
400 |
if( oldRotAxis == START_AXIS ) |
|
398 |
if( numScramble==1 ) |
|
401 | 399 |
{ |
402 |
return rnd.nextInt(numAxis);
|
|
400 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
403 | 401 |
} |
404 | 402 |
else |
405 | 403 |
{ |
406 |
int newVector = rnd.nextInt(numAxis-1);
|
|
407 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
404 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
405 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
408 | 406 |
} |
409 |
} |
|
410 |
|
|
411 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
412 | 407 |
|
413 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
414 |
{ |
|
415 | 408 |
float rowFloat = rnd.nextFloat(); |
416 | 409 |
|
417 | 410 |
for(int row=0; row<mRowChances.length; row++) |
418 | 411 |
{ |
419 |
if( rowFloat<=mRowChances[row] ) return row; |
|
412 |
if( rowFloat<=mRowChances[row] ) |
|
413 |
{ |
|
414 |
scramble[1] = row; |
|
415 |
break; |
|
416 |
} |
|
420 | 417 |
} |
421 | 418 |
|
422 |
return 0; |
|
419 |
int random = rnd.nextInt(remScrambles); |
|
420 |
int result = random<remDoubleScrambles ? 2:1; |
|
421 |
int sign = rnd.nextInt(2); |
|
422 |
|
|
423 |
scramble[2] = sign==0 ? result : -result; |
|
423 | 424 |
} |
424 | 425 |
|
425 | 426 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
import java.util.Random; |
39 | 39 |
|
40 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
41 |
|
|
42 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 41 |
|
44 | 42 |
public class TwistySkewb extends TwistyObject |
... | ... | |
541 | 539 |
|
542 | 540 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
543 | 541 |
|
544 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
542 |
public void randomizeNewScramble(int[] scramble, Random rnd, int oldRotAxis, int oldRow, |
|
543 |
int numScramble, int remScrambles, int remDoubleScrambles) |
|
545 | 544 |
{ |
546 |
int numAxis = ROTATION_AXIS.length; |
|
547 |
|
|
548 |
if( oldRotAxis == START_AXIS ) |
|
545 |
if( numScramble==1 ) |
|
549 | 546 |
{ |
550 |
return rnd.nextInt(numAxis);
|
|
547 |
scramble[0] = rnd.nextInt(ROTATION_AXIS.length);
|
|
551 | 548 |
} |
552 | 549 |
else |
553 | 550 |
{ |
554 |
int newVector = rnd.nextInt(numAxis-1);
|
|
555 |
return (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
551 |
int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
|
|
552 |
scramble[0] = (newVector>=oldRotAxis ? newVector+1 : newVector);
|
|
556 | 553 |
} |
557 |
} |
|
558 |
|
|
559 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
560 | 554 |
|
561 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
562 |
{ |
|
563 | 555 |
float rowFloat = rnd.nextFloat(); |
564 | 556 |
|
565 | 557 |
for(int row=0; row<mRowChances.length; row++) |
566 | 558 |
{ |
567 |
if( rowFloat<=mRowChances[row] ) return row; |
|
559 |
if( rowFloat<=mRowChances[row] ) |
|
560 |
{ |
|
561 |
scramble[1] = row; |
|
562 |
break; |
|
563 |
} |
|
568 | 564 |
} |
569 | 565 |
|
570 |
return 0; |
|
566 |
int random = rnd.nextInt(remScrambles); |
|
567 |
int result = random<remDoubleScrambles ? 2:1; |
|
568 |
int sign = rnd.nextInt(2); |
|
569 |
|
|
570 |
scramble[2] = sign==0 ? result : -result; |
|
571 | 571 |
} |
572 | 572 |
|
573 | 573 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change the automatic scramble API in the TwistyObject - in preparation for automatic scrambles in the Bandaged Objects.