Revision 8316f9ab
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/solvers/SolverDino4.java | ||
---|---|---|
87 | 87 |
return 0; |
88 | 88 |
} |
89 | 89 |
|
90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
91 |
|
|
92 |
private void remap(int[] perm, int[] edges, int index, int section) |
|
93 |
{ |
|
94 |
int val = edges[index]; |
|
95 |
|
|
96 |
for(int i=index;i<12; i++) |
|
97 |
if( edges[i]==val ) |
|
98 |
{ |
|
99 |
edges[i]=-1; |
|
100 |
perm[i] = section; |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
|
106 |
private int[] getPermutation(int[] edges) |
|
107 |
{ |
|
108 |
int[] perm = new int[12]; |
|
109 |
|
|
110 |
int index0 = 0; |
|
111 |
remap(perm,edges,index0,0); |
|
112 |
|
|
113 |
int index1 = index0+1; |
|
114 |
|
|
115 |
for(;index1<12;index1++) |
|
116 |
if( edges[index1]>=0 ) break; |
|
117 |
remap(perm,edges,index1,1); |
|
118 |
|
|
119 |
int index2 = index1+1; |
|
120 |
|
|
121 |
for(;index2<12;index2++) |
|
122 |
if( edges[index2]>=0 ) break; |
|
123 |
remap(perm,edges,index2,2); |
|
124 |
|
|
125 |
int index3 = index2+1; |
|
126 |
|
|
127 |
for(;index3<12;index3++) |
|
128 |
if( edges[index3]>=0 ) break; |
|
129 |
remap(perm,edges,index3,3); |
|
130 |
|
|
131 |
return perm; |
|
132 |
} |
|
133 |
|
|
90 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
91 | 135 |
|
92 | 136 |
public int tablebaseIndex(TwistyObject object) |
... | ... | |
97 | 141 |
int result1 = checkEdges(edges); |
98 | 142 |
if( result1<0 ) return result1; |
99 | 143 |
|
100 |
return TBDino4.indexFromPartition(edges[0]); |
|
144 |
int[] perm = getPermutation(edges[0]); |
|
145 |
return TBDino4.indexFromPartition(perm); |
|
101 | 146 |
} |
102 | 147 |
|
103 | 148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
131 | 176 |
{ |
132 | 177 |
if( mSolver==null ) |
133 | 178 |
{ |
134 |
mSolver = ImplementedTablebasesList.createUnpacked(ObjectSignatures.DIN4_3); |
|
135 |
if( mSolver!=null ) mSolver.createTablebase(-1); |
|
179 |
mSolver = ImplementedTablebasesList.createPacked(res,ObjectSignatures.DIN4_3); |
|
136 | 180 |
} |
137 | 181 |
|
138 | 182 |
return mSolver!=null ? mSolver.solution(index,null) : null; |
Also available in: Unified diff
Dino4 solver: code finished, but still doesn't work.