Revision 9e7ff8d2
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/objectlib/tablebases/ImplementedTablebasesList.java | ||
---|---|---|
29 | 29 |
MIRR2 (ObjectSignatures.MIRR_2, TBCube2.class), |
30 | 30 |
JING2 (ObjectSignatures.JING_2, TBJing.class), |
31 | 31 |
SKEW2 (ObjectSignatures.SKEW_2, TBSkewb.class), |
32 |
DINO6 (ObjectSignatures.DINO_3, TBDino6.class), |
|
32 | 33 |
; |
33 | 34 |
|
34 | 35 |
public static final int NUM_OBJECTS = values().length; |
src/main/java/org/distorted/objectlib/tablebases/TBDino6.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
public class TBDino6 extends TablebasesAbstract |
21 | 21 |
{ |
22 |
private static final int[][] QUATS = |
|
23 |
{ |
|
24 |
{0,2,10,8, 1,4,6,7, 11,5,9,3}, |
|
25 |
{1,0,6,10, 2,5,8,3, 7,9,4,11}, |
|
26 |
{10,5,0,3, 7,6,4,1, 9,2,11,8}, |
|
27 |
{7,10,4,0, 5,2,3,8, 1,11,6,9}, |
|
28 |
{2,1,8,6, 0,9,10,11, 3,4,5,7 }, |
|
29 |
{3,6,5,1, 9,0,11,10, 2,7,8,4 }, |
|
30 |
{5,7,3,4, 10,11,0,9, 8,6,2,1 }, |
|
31 |
{8,4,2,7, 11,10,9,0, 5,1,3,6 }, |
|
32 |
{11,8,9,2, 4,1,7,6, 0,3,10,5}, |
|
33 |
{6,9,1,11, 3,8,5,2, 4,0,7,10}, |
|
34 |
{9,3,11,5, 6,7,1,4, 10,8,0,2}, |
|
35 |
{4,11,7,9, 8,3,2,5, 6,10,1,0} |
|
36 |
}; |
|
37 |
|
|
22 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
23 | 39 |
|
24 | 40 |
public TBDino6() |
... | ... | |
30 | 46 |
|
31 | 47 |
public TBDino6(Resources res) |
32 | 48 |
{ |
33 |
super(res,org.distorted.objectlib.R.raw.pduo_2_tablebase);
|
|
49 |
super(res,org.distorted.objectlib.R.raw.dino_3_tablebase);
|
|
34 | 50 |
} |
35 | 51 |
|
36 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
84 | 100 |
} |
85 | 101 |
|
86 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
103 |
// exclude the middle layer and movements of edge[0]. |
|
87 | 104 |
|
88 | 105 |
boolean[][] getRotatable() |
89 | 106 |
{ |
90 |
boolean[] tmp = new boolean[] {true,false,true};
|
|
107 |
boolean[] tmp = {true,false,true}; |
|
91 | 108 |
return new boolean[][] { tmp,tmp,tmp,tmp }; |
92 | 109 |
} |
93 | 110 |
|
... | ... | |
117 | 134 |
} |
118 | 135 |
|
119 | 136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
137 |
// in-place! |
|
120 | 138 |
|
121 | 139 |
private int[] getPermFromQuats(int[] quats) |
122 | 140 |
{ |
123 |
return null; // TODO |
|
141 |
for(int i=0; i<12; i++) |
|
142 |
{ |
|
143 |
int[] Q = QUATS[i]; |
|
144 |
int quat = quats[i]; |
|
145 |
|
|
146 |
for(int j=0; j<12; j++) |
|
147 |
if( Q[j]==quat ) |
|
148 |
{ |
|
149 |
quats[i] = j; |
|
150 |
break; |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
return quats; |
|
124 | 155 |
} |
125 | 156 |
|
126 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
158 |
// in-place! |
|
127 | 159 |
|
128 | 160 |
private int[] getQuatsFromPerm(int[] perm) |
129 | 161 |
{ |
130 |
return null; // TODO |
|
162 |
for(int i=0; i<12; i++) |
|
163 |
{ |
|
164 |
int p = perm[i]; |
|
165 |
perm[i] = QUATS[i][p]; |
|
166 |
} |
|
167 |
|
|
168 |
return perm; |
|
169 |
} |
|
170 |
|
|
171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
172 |
// we rotate the whole thing so that quat[0] is always 0. |
|
173 |
|
|
174 |
private void normalizeQuats(int[] quats) |
|
175 |
{ |
|
176 |
if( quats[0]!=0 ) |
|
177 |
{ |
|
178 |
int inverted = getInvertedQuat(quats[0]); |
|
179 |
quats[0] = 0; |
|
180 |
|
|
181 |
for(int i=1; i<12; i++) |
|
182 |
{ |
|
183 |
int index = quats[i]; |
|
184 |
quats[i] = getMultQuat(inverted,index); |
|
185 |
} |
|
186 |
} |
|
131 | 187 |
} |
132 | 188 |
|
133 | 189 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
145 | 201 |
|
146 | 202 |
int getIndex(int[] quats) |
147 | 203 |
{ |
204 |
//int[] q1 = new int[12]; |
|
205 |
//for(int i=0; i<12; i++) q1[i] = quats[i]; |
|
206 |
|
|
207 |
normalizeQuats(quats); |
|
208 |
|
|
209 |
//int[] q2 = new int[12]; |
|
210 |
//for(int i=0; i<12; i++) q2[i] = quats[i]; |
|
211 |
|
|
212 |
|
|
148 | 213 |
int[] perm = getPermFromQuats(quats); |
149 |
return getIndexFromPerm(perm); |
|
214 |
int ret = getIndexFromPerm(perm); |
|
215 |
/* |
|
216 |
if( ret<0 ) |
|
217 |
{ |
|
218 |
StringBuilder sb = new StringBuilder(); |
|
219 |
|
|
220 |
for(int i=0; i<12; i++) |
|
221 |
{ |
|
222 |
sb.append(' '); |
|
223 |
sb.append(q1[i]); |
|
224 |
} |
|
225 |
android.util.Log.e("D", "getIndex: returning="+ret+" orig quats: "+sb); |
|
226 |
|
|
227 |
StringBuilder sb1 = new StringBuilder(); |
|
228 |
|
|
229 |
for(int i=0; i<12; i++) |
|
230 |
{ |
|
231 |
sb1.append(' '); |
|
232 |
sb1.append(q2[i]); |
|
233 |
} |
|
234 |
android.util.Log.e("D", "getIndex: returning="+ret+" norm quats: "+sb1); |
|
235 |
|
|
236 |
|
|
237 |
StringBuilder sb2 = new StringBuilder(); |
|
238 |
|
|
239 |
for(int i=0; i<12; i++) |
|
240 |
{ |
|
241 |
sb2.append(' '); |
|
242 |
sb2.append(perm[i]); |
|
243 |
} |
|
244 |
android.util.Log.e("D", "getIndex: returning="+ret+" perm: "+sb2); |
|
245 |
} |
|
246 |
*/ |
|
247 |
return ret; |
|
150 | 248 |
} |
151 | 249 |
} |
152 | 250 |
|
src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java | ||
---|---|---|
36 | 36 |
private final int[] mNumCuts; |
37 | 37 |
|
38 | 38 |
private int[][] mQuatMult; |
39 |
private int[] mInvertedQuat; |
|
39 | 40 |
|
40 | 41 |
Tablebase mTablebase; |
41 | 42 |
boolean mInitialized; |
... | ... | |
225 | 226 |
return -2; |
226 | 227 |
} |
227 | 228 |
|
229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
230 |
|
|
231 |
int getInvertedQuat(int index) |
|
232 |
{ |
|
233 |
if( mInvertedQuat==null ) |
|
234 |
{ |
|
235 |
mInvertedQuat = new int[mNumQuats]; |
|
236 |
|
|
237 |
for(int i=0; i<mNumQuats; i++) |
|
238 |
for(int j=0; j<mNumQuats; j++) |
|
239 |
{ |
|
240 |
int result = getMultQuat(i,j); |
|
241 |
|
|
242 |
if( result==0 ) |
|
243 |
{ |
|
244 |
mInvertedQuat[i] = j; |
|
245 |
break; |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
return mInvertedQuat[index]; |
|
251 |
} |
|
252 |
|
|
228 | 253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
229 | 254 |
// assumption: all layers have the same basicAngles! |
230 | 255 |
|
... | ... | |
263 | 288 |
} |
264 | 289 |
|
265 | 290 |
int childIndex = getIndex(tmpQuats); |
266 |
if( mTablebase.insertUnpacked(childIndex,newLevel) ) ret++; |
|
291 |
|
|
292 |
if( mTablebase.insertUnpacked(childIndex,newLevel) ) |
|
293 |
{ |
|
294 |
|
|
295 |
//android.util.Log.e("D", newLevel+" inserting "+childIndex+" ax="+ax+" layer="+layer+" angle="+angle+" SUCC "+index); |
|
296 |
|
|
297 |
ret++; |
|
298 |
} |
|
299 |
else |
|
300 |
{ |
|
301 |
|
|
302 |
//android.util.Log.d("D", newLevel+" inserting "+childIndex+" ax="+ax+" layer="+layer+" angle="+angle+" FAIL "+index); |
|
303 |
|
|
304 |
} |
|
267 | 305 |
} |
268 | 306 |
} |
269 | 307 |
|
Also available in: Unified diff
Dino6 solver: tablebase computed. It doesn't quite work yet though.