Revision 20898e6f
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.ObjectShape; |
25 | 25 |
import org.distorted.helpers.ObjectSticker; |
26 |
import org.distorted.helpers.ScrambleStateGraph; |
|
26 | 27 |
import org.distorted.library.main.DistortedEffects; |
27 | 28 |
import org.distorted.library.main.DistortedTexture; |
28 | 29 |
import org.distorted.library.mesh.MeshSquare; |
29 | 30 |
import org.distorted.library.type.Static3D; |
30 | 31 |
import org.distorted.library.type.Static4D; |
31 | 32 |
|
33 |
import java.util.Random; |
|
34 |
|
|
32 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 36 |
|
34 | 37 |
public abstract class TwistyDino extends TwistyObject |
... | ... | |
117 | 120 |
mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke); |
118 | 121 |
} |
119 | 122 |
|
123 |
private int mCurrState; |
|
124 |
private int mIndexExcluded; |
|
125 |
ScrambleStateGraph[] mStates; |
|
126 |
|
|
120 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | 128 |
|
122 | 129 |
TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
... | ... | |
233 | 240 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
234 | 241 |
// PUBLIC API |
235 | 242 |
|
243 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles) |
|
244 |
{ |
|
245 |
if( curr==0 ) |
|
246 |
{ |
|
247 |
mCurrState = 0; |
|
248 |
mIndexExcluded =-1; |
|
249 |
} |
|
250 |
|
|
251 |
int total = mStates[mCurrState].getTotal(mIndexExcluded); |
|
252 |
int random= rnd.nextInt(total); |
|
253 |
int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded); |
|
254 |
|
|
255 |
scramble[curr][0] = info[0]; |
|
256 |
scramble[curr][1] = info[1]; |
|
257 |
scramble[curr][2] = info[2]; |
|
258 |
|
|
259 |
mCurrState = info[3]; |
|
260 |
mIndexExcluded = info[0]; |
|
261 |
} |
|
262 |
|
|
263 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
264 |
|
|
236 | 265 |
public Static3D[] getRotationAxis() |
237 | 266 |
{ |
238 | 267 |
return ROT_AXIS; |
src/main/java/org/distorted/objects/TwistyDino4.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 |
import org.distorted.helpers.ScrambleStateGraph; |
|
24 | 25 |
import org.distorted.library.main.DistortedEffects; |
25 | 26 |
import org.distorted.library.main.DistortedTexture; |
26 | 27 |
import org.distorted.library.mesh.MeshSquare; |
... | ... | |
41 | 42 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
42 | 43 |
{ |
43 | 44 |
super(size, quat, texture, mesh, effects, moves, ObjectList.DIN4, res, scrWidth); |
45 |
|
|
46 |
mStates = new ScrambleStateGraph[] |
|
47 |
{ |
|
48 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{0,1,5,0,-1,5 },{ 2,1,8,2,-1,8} } ), |
|
49 |
new ScrambleStateGraph( new int[][] { { },{0,1,3,0,-1,3 },{0,1,5,0,-1,5, },{ 2,1,8,2,-1,8} } ), |
|
50 |
new ScrambleStateGraph( new int[][] { { },{ 2,1,4,2,-1,4},{ 2,1,6,2,-1,6},{0,1,7,0,-1,7 } } ), |
|
51 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1 },{ },{ 2,1,6,2,-1,6},{0,1,7,0,-1,7 } } ), |
|
52 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{ },{0,1,5,0,-1,5, },{ 2,1,8,2,-1,8} } ), |
|
53 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1 },{ 2,1,4,2,-1,4},{ },{0,1,7,0,-1,7 } } ), |
|
54 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{ },{ 2,1,8,2,-1,8} } ), |
|
55 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{0,1,5,0,-1,5, },{ } } ), |
|
56 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1 },{ 2,1,4,2,-1,4},{ 2,1,6,2,-1,6},{ } } ), |
|
57 |
}; |
|
44 | 58 |
} |
45 | 59 |
|
46 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
71 | 85 |
return true; |
72 | 86 |
} |
73 | 87 |
|
74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
75 |
|
|
76 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
77 |
{ |
|
78 |
if( curr==0 ) |
|
79 |
{ |
|
80 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS); |
|
81 |
scramble[curr][1] = (scramble[curr][0]==1 || scramble[curr][0]==2) ? 0:2; |
|
82 |
} |
|
83 |
else |
|
84 |
{ |
|
85 |
int newVector = rnd.nextInt(NUM_AXIS-1); |
|
86 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
|
87 |
scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1]; |
|
88 |
} |
|
89 |
|
|
90 |
switch( rnd.nextInt(2) ) |
|
91 |
{ |
|
92 |
case 0: scramble[curr][2] = -1; break; |
|
93 |
case 1: scramble[curr][2] = 1; break; |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
98 | 89 |
|
99 | 90 |
public int getObjectName(int numLayers) |
src/main/java/org/distorted/objects/TwistyDino6.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 |
import org.distorted.helpers.ScrambleStateGraph; |
|
24 | 25 |
import org.distorted.library.main.DistortedEffects; |
25 | 26 |
import org.distorted.library.main.DistortedTexture; |
26 | 27 |
import org.distorted.library.mesh.MeshSquare; |
27 | 28 |
import org.distorted.library.type.Static4D; |
28 | 29 |
import org.distorted.main.R; |
29 | 30 |
|
30 |
import java.util.Random; |
|
31 |
|
|
32 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 32 |
|
34 | 33 |
public class TwistyDino6 extends TwistyDino |
... | ... | |
43 | 42 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
44 | 43 |
{ |
45 | 44 |
super(size, quat, texture, mesh, effects, moves, ObjectList.DINO, res, scrWidth); |
45 |
|
|
46 |
mStates = new ScrambleStateGraph[] |
|
47 |
{ |
|
48 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1, 2,1,2,2,-1,2},{0,1,3,0,-1,3, 2,1,4,2,-1,4},{0,1,5,0,-1,5, 2,1,6,2,-1,6},{0,1,7,0,-1,7, 2,1,8,2,-1,8} } ), |
|
49 |
new ScrambleStateGraph( new int[][] { { },{0,1,3,0,-1,3 },{0,1,5,0,-1,5, },{ 2,1,8,2,-1,8} } ), |
|
50 |
new ScrambleStateGraph( new int[][] { { },{ 2,1,4,2,-1,4},{ 2,1,6,2,-1,6},{0,1,7,0,-1,7 } } ), |
|
51 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1 },{ },{ 2,1,6,2,-1,6},{0,1,7,0,-1,7 } } ), |
|
52 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{ },{0,1,5,0,-1,5, },{ 2,1,8,2,-1,8} } ), |
|
53 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1 },{ 2,1,4,2,-1,4},{ },{0,1,7,0,-1,7 } } ), |
|
54 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{ },{ 2,1,8,2,-1,8} } ), |
|
55 |
new ScrambleStateGraph( new int[][] { { 2,1,2,2,-1,2},{0,1,3,0,-1,3 },{0,1,5,0,-1,5, },{ } } ), |
|
56 |
new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1 },{ 2,1,4,2,-1,4},{ 2,1,6,2,-1,6},{ } } ), |
|
57 |
}; |
|
46 | 58 |
} |
47 | 59 |
|
48 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
101 | 113 |
return false; |
102 | 114 |
} |
103 | 115 |
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
|
106 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
107 |
{ |
|
108 |
if( curr==0 ) |
|
109 |
{ |
|
110 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS); |
|
111 |
scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0:2; |
|
112 |
} |
|
113 |
else |
|
114 |
{ |
|
115 |
int newVector = rnd.nextInt(NUM_AXIS-1); |
|
116 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
|
117 |
scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1]; |
|
118 |
} |
|
119 |
|
|
120 |
switch( rnd.nextInt(2) ) |
|
121 |
{ |
|
122 |
case 0: scramble[curr][2] = -1; break; |
|
123 |
case 1: scramble[curr][2] = 1; break; |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 | 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
128 | 117 |
|
129 | 118 |
public int getObjectName(int numLayers) |
Also available in: Unified diff
Convert both Dinos to the new, unified scrambling method.