Revision 185dd0a1
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/solvers/SolverPyraminx.java | ||
---|---|---|
515 | 515 |
return null; |
516 | 516 |
} |
517 | 517 |
|
518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
519 |
|
|
520 |
private void addMove(int[] move, int axis, int twist) |
|
521 |
{ |
|
522 |
move[0] = axis; |
|
523 |
move[1] = (1<<2); |
|
524 |
move[2] = (twist==2 ? -1:twist); |
|
525 |
} |
|
526 |
|
|
527 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
528 |
|
|
529 |
private int[][] constructTipMoves(int[] twist) |
|
530 |
{ |
|
531 |
int total = 0; |
|
532 |
|
|
533 |
for(int i=0; i<4; i++) |
|
534 |
if( twist[i]!=0 ) total++; |
|
535 |
|
|
536 |
if( total>0 ) |
|
537 |
{ |
|
538 |
int[][] moves = new int[total][3]; |
|
539 |
|
|
540 |
int index=0; |
|
541 |
if( twist[0]!=0 ) { addMove(moves[index],1,twist[0]); index++; } |
|
542 |
if( twist[1]!=0 ) { addMove(moves[index],0,twist[1]); index++; } |
|
543 |
if( twist[2]!=0 ) { addMove(moves[index],3,twist[2]); index++; } |
|
544 |
if( twist[3]!=0 ) { addMove(moves[index],2,twist[3]); } |
|
545 |
|
|
546 |
return moves; |
|
547 |
} |
|
548 |
|
|
549 |
return null; |
|
550 |
} |
|
551 |
|
|
552 | 518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
553 | 519 |
|
554 | 520 |
public int[][] solution(int index, Resources res) |
... | ... | |
558 | 524 |
mSolver = ImplementedTablebasesList.createPacked(res, ObjectSignatures.PYRA_3); |
559 | 525 |
} |
560 | 526 |
|
561 |
int[][] moves1 = mSolver!=null ? mSolver.solution(index) : null; |
|
562 |
int[][] moves2 = constructTipMoves(mCornerTwist); |
|
563 |
|
|
564 |
int len1 = (moves1==null ? 0:moves1.length); |
|
565 |
int len2 = (moves2==null ? 0:moves2.length); |
|
566 |
|
|
567 |
int[][] moves = new int[len1+len2][3]; |
|
568 |
|
|
569 |
if( len1>0 ) System.arraycopy(moves1, 0, moves, 0, len1); |
|
570 |
if( len2>0 ) System.arraycopy(moves2, 0, moves, len1, len2); |
|
571 |
|
|
572 |
return moves; |
|
527 |
return mSolver!=null ? mSolver.solution(index,mCornerTwist) : null; |
|
573 | 528 |
} |
574 | 529 |
} |
575 | 530 |
|
Also available in: Unified diff
Move corner orientation from SolverPyraminx to TablebasesPyraminx (we'll need it for better-looking tablebases scrambling)