Revision 45dc5cd7
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/objectlib/tablebases/TBCuboid323.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
16 | 16 |
|
17 |
public class TBCuboid323 extends TablebasesAbstract
|
|
17 |
public class TBCuboid323 extends TablebasesPruning
|
|
18 | 18 |
{ |
19 | 19 |
private static final int[][] CORNER_MAP = new int[][] |
20 | 20 |
{ |
... | ... | |
40 | 40 |
}; |
41 | 41 |
|
42 | 42 |
private static boolean mUpper; |
43 |
private int[][] mAngles; |
|
43 | 44 |
|
44 | 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
45 | 46 |
|
... | ... | |
133 | 134 |
|
134 | 135 |
public TBCuboid323(OperatingSystemInterface os) |
135 | 136 |
{ |
136 |
super(os,org.distorted.objectlib.R.raw.cu_232_tablebase);
|
|
137 |
super(os,null,null);
|
|
137 | 138 |
} |
138 | 139 |
|
139 | 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
140 | 141 |
|
141 | 142 |
int[][] getBasicAngles() |
142 | 143 |
{ |
143 |
int[] tmp2 = {2,2,2}; |
|
144 |
int[] tmp4 = {4,4}; |
|
145 |
return new int[][] { tmp2,tmp4,tmp2 }; |
|
144 |
if( mAngles==null ) |
|
145 |
{ |
|
146 |
int[] tmp2 = {2,2,2}; |
|
147 |
int[] tmp4 = {4,4}; |
|
148 |
return new int[][] { tmp2,tmp4,tmp2 }; |
|
149 |
} |
|
150 |
|
|
151 |
return mAngles; |
|
146 | 152 |
} |
147 | 153 |
|
148 | 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
202 | 208 |
|
203 | 209 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
204 | 210 |
// specifically for the tablebase |
211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
212 |
// we can never really move the fixed front edge, because if we do so, we would also rotate the |
|
213 |
// rotation axis themselves! (see getIndex() where the cubit quats are normalized) |
|
214 |
// Fixed front edge is either edge1 or edge3, depending on value of mUpper |
|
215 |
// (mUpper==true --> fixed==3, else fixed==1) |
|
216 |
// |
|
217 |
|
|
218 |
@Override |
|
219 |
int[] newMove(int axis, int layer, int angle) |
|
220 |
{ |
|
221 |
//if( axis==0 && layer==2 ) return new int[] { axis, 3, angle==1 ? 1:-1}; |
|
222 |
//if( axis==3 && layer==0 ) return new int[] { axis, 6, angle==1 ? 1:-1}; |
|
223 |
|
|
224 |
if( axis==1 ) |
|
225 |
{ |
|
226 |
|
|
227 |
} |
|
228 |
|
|
229 |
int maxAngle = mAngles[axis][layer]; |
|
230 |
angle = maxAngle-angle; |
|
231 |
if( angle> 0.5f*maxAngle ) angle -= maxAngle; |
|
232 |
return new int[] { axis, (1<<layer), angle }; |
|
233 |
} |
|
234 |
|
|
205 | 235 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
206 | 236 |
// 8!*8!/4 --> https://www.jaapsch.net/puzzles/domino.htm |
207 | 237 |
|
... | ... | |
217 | 247 |
return 13; |
218 | 248 |
} |
219 | 249 |
|
250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
|
|
252 |
int[] getMidPruningLevels() |
|
253 |
{ |
|
254 |
return new int[] {6,7}; |
|
255 |
} |
|
256 |
|
|
257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
258 |
|
|
259 |
int[] getHighPruningLevels() |
|
260 |
{ |
|
261 |
return new int[] {17,18}; |
|
262 |
} |
|
263 |
|
|
264 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
265 |
|
|
266 |
int getGodsNumber() |
|
267 |
{ |
|
268 |
return 18; |
|
269 |
} |
|
270 |
|
|
271 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
272 |
|
|
273 |
boolean moveCanProceed(int lastA, int lastR, int currA, int currR) |
|
274 |
{ |
|
275 |
return (lastA!=currA) || (lastR!=currR); |
|
276 |
} |
|
277 |
|
|
220 | 278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
221 | 279 |
|
222 | 280 |
private int findIndex(int[] table, int value) |
... | ... | |
231 | 289 |
|
232 | 290 |
private boolean isFrontEdgeInItsPlace(int[] perm) |
233 | 291 |
{ |
234 |
return perm[mUpper ? 3 : 1]==0; |
|
292 |
int index = mUpper?3:1; |
|
293 |
return perm[index]==index; |
|
294 |
} |
|
295 |
|
|
296 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
297 |
|
|
298 |
private void correctQuats(int[] quats) |
|
299 |
{ |
|
300 |
int mult=0, index = mUpper? 11:9; |
|
301 |
|
|
302 |
switch(quats[index]) |
|
303 |
{ |
|
304 |
case 0: case 5: return; |
|
305 |
case 4: case 7: mult=2; break; |
|
306 |
case 1: case 3: mult=3; break; |
|
307 |
case 2: case 6: mult=4; break; |
|
308 |
} |
|
309 |
|
|
310 |
for(int i=0; i<16; i++) quats[i] = getMultQuat(mult,quats[i]); |
|
235 | 311 |
} |
236 | 312 |
|
237 | 313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
238 | 314 |
|
239 | 315 |
public int[] getQuats(int index) |
240 | 316 |
{ |
241 |
int cornerPermNum = index%20160;
|
|
242 |
index /= 20160;
|
|
317 |
int cornerPermNum = index%40320;
|
|
318 |
index /= 40320;
|
|
243 | 319 |
boolean inPlace = ((index%2)==0); |
244 | 320 |
int edgePermNum = index/2; |
245 | 321 |
|
... | ... | |
272 | 348 |
int[] corner_perm = new int[8]; |
273 | 349 |
int[] edge_perm8 = new int[8]; |
274 | 350 |
|
351 |
correctQuats(quats); |
|
352 |
|
|
275 | 353 |
for(int i=0; i<8; i++) |
276 | 354 |
{ |
277 | 355 |
corner_perm[i] = findIndex( CORNER_MAP[i], quats[i ]); |
... | ... | |
284 | 362 |
int edge_perm_num = TablebaseHelpers.computePermutationNum(edge_perm7); |
285 | 363 |
boolean inPlace = isFrontEdgeInItsPlace(edge_perm8); |
286 | 364 |
|
287 |
return corner_perm_num + 20160*( (inPlace?0:1) + 2*edge_perm_num);
|
|
365 |
return corner_perm_num + 40320*( (inPlace?0:1) + 2*edge_perm_num);
|
|
288 | 366 |
} |
289 | 367 |
} |
290 | 368 |
|
Also available in: Unified diff
CU_323 solver: corrections.