Revision 7f84a768
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/patterns/RubikPattern.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
public class RubikPattern |
32 | 32 |
{ |
33 |
private static final int DURATION_MILLIS = 800;
|
|
33 |
private static final int DURATION_MILLIS = 750;
|
|
34 | 34 |
|
35 | 35 |
private int[] numCategories = new int[NUM_OBJECTS]; |
36 | 36 |
private int[] currentCategory = new int[NUM_OBJECTS]; |
... | ... | |
217 | 217 |
numMove = moveStr.length()/4; |
218 | 218 |
moves = new int[numMove][3]; |
219 | 219 |
curMove = numMove; |
220 |
|
|
221 |
int digit0, digit1, digit2; |
|
222 |
|
|
223 |
for(int i=0; i<numMove; i++) |
|
224 |
{ |
|
225 |
digit0 = moveStr.charAt(4*i+1)-'0'; |
|
226 |
digit1 = moveStr.charAt(4*i+2)-'0'; |
|
227 |
digit2 = moveStr.charAt(4*i+3)-'0'; |
|
228 |
|
|
229 |
moves[i][0] = (10*digit0+digit1)/32; |
|
230 |
moves[i][1] = (10*digit0+digit1)%32; |
|
231 |
moves[i][2] = 2-digit2; |
|
232 |
} |
|
233 |
|
|
220 |
parseMoves(moves,numMove,moveStr); |
|
234 | 221 |
moveStr = null; |
235 | 222 |
mInitialized = true; |
236 | 223 |
} |
... | ... | |
266 | 253 |
{ |
267 | 254 |
if( !mInitialized ) initialize(); |
268 | 255 |
|
269 |
curMove++; |
|
270 |
|
|
271 | 256 |
if( mCanRotate ) |
272 | 257 |
{ |
258 |
curMove++; |
|
259 |
|
|
273 | 260 |
if( curMove>numMove ) |
274 | 261 |
{ |
275 | 262 |
curMove= 0; |
... | ... | |
297 | 284 |
else |
298 | 285 |
{ |
299 | 286 |
android.util.Log.e("pattern", "failed to make Move!"); |
300 |
curMove--; |
|
301 | 287 |
} |
302 | 288 |
} |
303 | 289 |
|
... | ... | |
307 | 293 |
{ |
308 | 294 |
if( !mInitialized ) initialize(); |
309 | 295 |
|
310 |
curMove--; |
|
311 |
|
|
312 | 296 |
if( mCanRotate ) |
313 | 297 |
{ |
298 |
curMove--; |
|
299 |
|
|
314 | 300 |
if( curMove<0 ) |
315 | 301 |
{ |
316 | 302 |
curMove=numMove; |
... | ... | |
338 | 324 |
else |
339 | 325 |
{ |
340 | 326 |
android.util.Log.e("pattern", "failed to back Move!"); |
341 |
curMove++; |
|
342 | 327 |
} |
343 | 328 |
} |
344 | 329 |
|
... | ... | |
405 | 390 |
return mThis; |
406 | 391 |
} |
407 | 392 |
|
393 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
394 |
|
|
395 |
public static void parseMoves(int[][] result, int numMoves, String moves) |
|
396 |
{ |
|
397 |
int digit0, digit1, digit2; |
|
398 |
|
|
399 |
for(int i=0; i<numMoves; i++) |
|
400 |
{ |
|
401 |
digit0 = moves.charAt(4*i+1)-'0'; |
|
402 |
digit1 = moves.charAt(4*i+2)-'0'; |
|
403 |
digit2 = moves.charAt(4*i+3)-'0'; |
|
404 |
|
|
405 |
result[i][0] = (10*digit0+digit1)/32; |
|
406 |
result[i][1] = (10*digit0+digit1)%32; |
|
407 |
result[i][2] = 2-digit2; |
|
408 |
} |
|
409 |
} |
|
410 |
|
|
408 | 411 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
409 | 412 |
|
410 | 413 |
public int getNumCategories(int tab) |
Also available in: Unified diff
Progress with the 3x3x3 Solver.
Hopefully the only thing that remains to be done is to implement the RubikStateSolver.retCubeString().