| 752 | //-1: no solution found |
| 753 | // X: solution with X moves shorter than expectation. Hence, the length of the solution is depth - X |
| 754 | private int phase2(int eidx, int esym, int cidx, int csym, int mid, int maxl, int depth, int lm) { |
| 755 | if (eidx == 0 && cidx == 0 && mid == 0) { |
| 756 | return maxl; |
| 757 | } |
| 758 | for (int m = 0; m < 10; m++) { |
| 759 | if (lm < 0 ? (m == -lm) : Util.ckmv2[lm][m]) { |
| 760 | continue; |
| 761 | } |
| 762 | int midx = CoordCube.MPermMove[mid][m]; |
| 763 | int cidxx = CoordCube.CPermMove[cidx][CubieCube.SymMove[csym][Util.ud2std[m]]]; |
| 764 | int csymx = CubieCube.SymMult[cidxx & 0xf][csym]; |
| 765 | cidxx >>= 4; |
| 766 | if (CoordCube.getPruning(CoordCube.MCPermPrun, |
| 767 | cidxx * 24 + CoordCube.MPermConj[midx][csymx]) >= maxl) { |
| 768 | continue; |
| 769 | } |
| 770 | int eidxx = CoordCube.EPermMove[eidx][CubieCube.SymMoveUD[esym][m]]; |
| 771 | int esymx = CubieCube.SymMult[eidxx & 0xf][esym]; |
| 772 | eidxx >>= 4; |
| 773 | |
| 774 | // if (CoordCube.getPruning(CoordCube.CPermECombPrun, |
| 775 | // cidxx * 70 + CoordCube.ECombConj[CubieCube.Perm2Comb[eidxx]][CubieCube.SymMultInv[csymx][esymx]]) >= maxl) { |
| 776 | // continue; |
| 777 | // } |
| 778 | if (CoordCube.getPruning(CoordCube.EPermCCombPrun, |
| 779 | eidxx * 70 + CoordCube.CCombConj[CubieCube.Perm2Comb[cidxx]][CubieCube.SymMultInv[esymx][csymx]]) >= maxl) { |
| 780 | continue; |
| 781 | } |
| 782 | if (CoordCube.getPruning(CoordCube.MEPermPrun, |
| 783 | eidxx * 24 + CoordCube.MPermConj[midx][esymx]) >= maxl) { |
| 784 | continue; |
| 785 | } |
| 786 | int ret = phase2(eidxx, esymx, cidxx, csymx, midx, maxl - 1, depth + 1, (lm < 0 && m + lm == -5) ? -lm : m); |
| 787 | if (ret >= 0) { |
| 788 | move[depth] = Util.ud2std[m]; |
| 789 | return ret; |
| 790 | } |
| 791 | } |
| 792 | return -1; |
| 793 | } |
| 794 | |
| 795 | private String solutionToString() { |
| 796 | StringBuilder sb = new StringBuilder(); |