26 |
26 |
private String[] mPhaseNames;
|
27 |
27 |
private int mNumPhases;
|
28 |
28 |
private int[][][] mMoves;
|
|
29 |
private int[][] mCubitsInvolved;
|
29 |
30 |
private int mNumMoves,mCurrMove,mCurrPhase;
|
30 |
31 |
private boolean mCanMove;
|
31 |
32 |
private ObjectControl mControl;
|
... | ... | |
40 |
41 |
mPhaseNames = names;
|
41 |
42 |
mNumPhases = names.length;
|
42 |
43 |
mMoves = new int[mNumPhases][][];
|
|
44 |
mCubitsInvolved = new int[mNumPhases][];
|
43 |
45 |
mCanMove = true;
|
44 |
|
setMoves(act,null,0);
|
|
46 |
setSolution(act,null,0,null);
|
45 |
47 |
}
|
46 |
48 |
|
47 |
49 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
51 |
53 |
mPhaseNames = names;
|
52 |
54 |
mNumPhases = names.length;
|
53 |
55 |
mMoves = new int[mNumPhases][][];
|
|
56 |
mCubitsInvolved = new int[mNumPhases][];
|
54 |
57 |
mCanMove = true;
|
55 |
|
setMoves(act,null,0);
|
|
58 |
setSolution(act,null,0,null);
|
56 |
59 |
}
|
57 |
60 |
|
58 |
61 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
80 |
83 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length;
|
81 |
84 |
mCurrMove = mNumMoves;
|
82 |
85 |
mControl = act.getControl();
|
83 |
|
|
84 |
86 |
int[][] moves = transformMoves(mMoves, true);
|
85 |
87 |
mControl.applyScrambles(moves);
|
86 |
88 |
}
|
... | ... | |
92 |
94 |
|
93 |
95 |
void nextPhase(SolverActivity act)
|
94 |
96 |
{
|
95 |
|
if( mCurrMove<mNumMoves )
|
|
97 |
if( mCurrPhase<mNumPhases-1 )
|
96 |
98 |
{
|
97 |
|
int[][] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
98 |
|
mCurrMove = mNumMoves;
|
99 |
99 |
mControl = act.getControl();
|
|
100 |
glowCubits(mControl,mCubitsInvolved[mCurrPhase]);
|
|
101 |
int[][] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
100 |
102 |
mControl.applyScrambles(moves);
|
101 |
|
}
|
102 |
|
else if( mCurrPhase<mNumPhases-1 )
|
103 |
|
{
|
104 |
103 |
mCurrPhase++;
|
105 |
104 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length;
|
106 |
|
mCurrMove = mNumMoves;
|
107 |
|
int[][] moves = transformMoves(mMoves[mCurrPhase],0,mNumMoves, true);
|
|
105 |
mCurrMove = 0;
|
|
106 |
}
|
|
107 |
else if( mCurrMove<mNumMoves )
|
|
108 |
{
|
108 |
109 |
mControl = act.getControl();
|
|
110 |
glowCubits(mControl,mCubitsInvolved[mCurrPhase]);
|
|
111 |
int[][] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
109 |
112 |
mControl.applyScrambles(moves);
|
|
113 |
mCurrMove = mNumMoves;
|
110 |
114 |
}
|
111 |
115 |
else
|
112 |
116 |
{
|
|
117 |
mControl = act.getControl();
|
113 |
118 |
mCurrPhase = 0;
|
114 |
119 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length;
|
115 |
120 |
mCurrMove = 0;
|
116 |
|
mControl = act.getControl();
|
117 |
121 |
int[][] moves = transformMoves(mMoves, false);
|
118 |
122 |
mControl.applyScrambles(moves);
|
119 |
123 |
}
|
... | ... | |
203 |
207 |
|
204 |
208 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
205 |
209 |
|
206 |
|
void setMoves(SolverActivity act, int[][] moves, int phase)
|
|
210 |
private void glowCubits(ObjectControl control, int[] cubits)
|
207 |
211 |
{
|
|
212 |
StringBuilder sb = new StringBuilder();
|
|
213 |
sb.append("Glowing: ");
|
|
214 |
|
|
215 |
for( int c: cubits )
|
|
216 |
{
|
|
217 |
sb.append(' ');
|
|
218 |
sb.append(c);
|
|
219 |
}
|
|
220 |
|
|
221 |
android.util.Log.e("D", sb.toString() );
|
|
222 |
}
|
|
223 |
|
|
224 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
225 |
|
|
226 |
private int[] computeCubitsInvolved(int[][] subphases)
|
|
227 |
{
|
|
228 |
int numCubits = 0;
|
|
229 |
for(int[] sub : subphases) numCubits += (sub==null ? 0 : sub.length);
|
|
230 |
|
|
231 |
int[] ret = new int[numCubits];
|
|
232 |
int index = 0;
|
|
233 |
|
|
234 |
for(int[] sub : subphases)
|
|
235 |
if( sub!=null )
|
|
236 |
for(int s : sub)
|
|
237 |
ret[index++] = s;
|
|
238 |
|
|
239 |
return ret;
|
|
240 |
}
|
|
241 |
|
|
242 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
243 |
|
|
244 |
void setSolution(SolverActivity act, int[][] moves, int phase, int[][] subphases)
|
|
245 |
{
|
|
246 |
mCubitsInvolved[phase] = subphases==null ? null : computeCubitsInvolved(subphases);
|
208 |
247 |
mMoves[phase] = moves;
|
209 |
248 |
if( phase==0 ) mNumMoves = (moves==null ? 0 : moves.length);
|
210 |
249 |
mCurrPhase = 0;
|
... | ... | |
273 |
312 |
mControl = act.getControl();
|
274 |
313 |
mControl.blockTouch(MOVES_PLACE_1);
|
275 |
314 |
mControl.addRotation(this, move[0], (1<<move[1]), move[2], MILLIS_PER_DEGREE);
|
|
315 |
|
|
316 |
if( mCurrPhase==mNumPhases-1 && mCurrMove==mNumMoves )
|
|
317 |
glowCubits(mControl,mCubitsInvolved[mCurrPhase]);
|
276 |
318 |
}
|
277 |
319 |
else if( mCurrPhase<mNumPhases-1 )
|
278 |
320 |
{
|
|
321 |
glowCubits(mControl,mCubitsInvolved[mCurrPhase]);
|
279 |
322 |
mCurrPhase++;
|
280 |
323 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length;
|
281 |
324 |
mCurrMove = 0;
|
... | ... | |
285 |
328 |
mCurrPhase = 0;
|
286 |
329 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length;
|
287 |
330 |
mCurrMove = 0;
|
288 |
|
mControl = act.getControl();
|
289 |
|
|
290 |
331 |
int[][] moves = transformMoves(mMoves, false);
|
|
332 |
mControl = act.getControl();
|
291 |
333 |
mControl.applyScrambles(moves);
|
292 |
334 |
}
|
293 |
335 |
|
Step towards glowing cubits involved in a phase.