Revision a91ac171
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/objectlib/algsolvers/AlgSolver.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
public abstract class AlgSolver |
18 | 18 |
{ |
19 |
public static final int MODE_OP = 0; // solve both orientation and permutation |
|
20 |
public static final int MODE_O = 1; // solve orientation |
|
21 |
public static final int MODE_P = 2; // solve permutation |
|
19 |
public static final int MODE_ALL_AT_ONCE_OP = 0; // define a subset of cubits; solve their |
|
20 |
// orientation and permutation all in one go |
|
21 |
// (think white cross stage in Beginner's 3x3) |
|
22 |
public static final int MODE_ONE_BY_ONE_OP = 1; // define a subset of cubits; solve their |
|
23 |
// orientation and permutation one-by-one in |
|
24 |
// 'sub-phases' (think white corners stage in Beginner's 3x3) |
|
25 |
public static final int MODE_CYCLIC_P_FIRST = 2; // define a cyclic subset of cubits (i.e a single |
|
26 |
// cubit and a quat ) and solve it in two sub-phases: |
|
27 |
// permutation first and then orientation |
|
28 |
// (think yellow corners stage in Beginner's 3x3) |
|
29 |
public static final int MODE_CYCLIC_O_FIRST = 3; // define a cyclic subset of cubits (i.e a single |
|
30 |
// cubit and a quat ) and solve it in two sub-phases: |
|
31 |
// orientation first and then permutation |
|
32 |
// (think yellow edges stage in Beginner's 3x3) |
|
22 | 33 |
|
23 | 34 |
protected static class SolverPhase |
24 | 35 |
{ |
25 | 36 |
// A list of cubit indices that have to be solved by this phase |
26 | 37 |
private final int[] mIndices; |
27 |
private final int mMode; // OP, O or P
|
|
38 |
private final int mMode; // see constants above
|
|
28 | 39 |
private final int mNumIndices; |
29 | 40 |
|
30 | 41 |
public SolverPhase(int[] indices, int mode) |
... | ... | |
45 | 56 |
|
46 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
47 | 58 |
|
48 |
public AlgSolver(TwistyObject object, int[][] phases, int[] modes)
|
|
59 |
public AlgSolver(TwistyObject object, int[][] cubits, int[] modes)
|
|
49 | 60 |
{ |
50 | 61 |
mObject = object; |
51 | 62 |
|
52 |
mNumPhases = phases.length;
|
|
63 |
mNumPhases = cubits.length;
|
|
53 | 64 |
mPhases = new SolverPhase[mNumPhases]; |
54 |
for(int i=0; i<mNumPhases; i++) mPhases[i] = new SolverPhase(phases[i],modes[i]);
|
|
65 |
for(int i=0; i<mNumPhases; i++) mPhases[i] = new SolverPhase(cubits[i],modes[i]);
|
|
55 | 66 |
} |
56 | 67 |
|
57 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
90 | 101 |
|
91 | 102 |
public int[][][] solution(int[] quats, OperatingSystemInterface osi) |
92 | 103 |
{ |
93 |
int[][][] ret = new int[mNumPhases][][];
|
|
104 |
int[][][] solution_moves = new int[mNumPhases][][];
|
|
94 | 105 |
|
95 | 106 |
for(int i=0; i<mNumPhases; i++) |
96 | 107 |
{ |
97 |
ret[i] = solutionOfPhase(i,quats,osi);
|
|
108 |
solution_moves[i] = solutionOfPhase(i,quats,osi);
|
|
98 | 109 |
|
99 |
if( ret[i]==null )
|
|
110 |
if( solution_moves[i]==null )
|
|
100 | 111 |
{ |
101 | 112 |
osi.reportError("AlgSolver: error solving phase "+i); |
102 | 113 |
return null; |
103 | 114 |
} |
104 | 115 |
} |
105 | 116 |
|
106 |
return ret;
|
|
117 |
return solution_moves;
|
|
107 | 118 |
} |
108 | 119 |
} |
Also available in: Unified diff
Minor