Revision f51c164f
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/objectlib/tablebases/TablebaseHelpers.java | ||
---|---|---|
207 | 207 |
|
208 | 208 |
public static int computePermutationNum(int[] permutation) |
209 | 209 |
{ |
210 |
int len = permutation.length-1;
|
|
210 |
int len = permutation.length; |
|
211 | 211 |
int ret = 0; |
212 | 212 |
int mul = 3; |
213 | 213 |
|
214 |
for(int i=0; i<len; i++) |
|
214 |
for(int i=0; i<len-2; i++)
|
|
215 | 215 |
{ |
216 |
ret += swaps(len-1-i,permutation,len+1); |
|
217 |
|
|
218 |
if( i<len-1 ) |
|
219 |
{ |
|
220 |
ret *= mul; |
|
221 |
mul++; |
|
222 |
} |
|
216 |
ret += swaps(len-2-i,permutation,len); |
|
217 |
ret *= mul; |
|
218 |
mul++; |
|
223 | 219 |
} |
224 | 220 |
|
221 |
ret += swaps(0,permutation,len); |
|
222 |
|
|
225 | 223 |
return ret; |
226 | 224 |
} |
227 | 225 |
|
src/main/java/org/distorted/objectlib/tablebases/TablebasesPruning.java | ||
---|---|---|
274 | 274 |
|
275 | 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
276 | 276 |
|
277 |
private boolean jumpMidSolvedRecursive(int[] quats, int jump, int depth, int lastA, int lastR, int[][] solution) |
|
277 |
private boolean jumpMidSolvedRecursive(int[] quats, int jump, int depth, int lastA, int lastR, |
|
278 |
int[][] solution, int[][] tmpE, int[][][] rotRowE ) |
|
278 | 279 |
{ |
279 | 280 |
int numQuats = quats.length; |
280 | 281 |
int[] move = solution[depth]; |
281 |
int[] tmp = new int[mNumCubits];
|
|
282 |
int[][] rotRow= new int[mNumCubits][mNumAxis];
|
|
282 |
int[] tmp = tmpE[jump];
|
|
283 |
int[][] rotRow= rotRowE[jump];
|
|
283 | 284 |
|
284 | 285 |
move[0]=0; |
285 | 286 |
move[1]=0; |
... | ... | |
327 | 328 |
return true; |
328 | 329 |
} |
329 | 330 |
|
330 |
if( jump>1 && jumpMidSolvedRecursive(tmp, jump-1, depth+1, ax, layer, solution) ) |
|
331 |
if( jump>1 && jumpMidSolvedRecursive(tmp, jump-1, depth+1, ax, layer, solution, tmpE, rotRowE) )
|
|
331 | 332 |
{ |
332 | 333 |
return true; |
333 | 334 |
} |
... | ... | |
349 | 350 |
int[][] solution = new int[maxJump+1][4]; |
350 | 351 |
int[] quats = getQuats(index); |
351 | 352 |
|
353 |
int[][] tmpE = new int[maxJump+1][mNumCubits]; |
|
354 |
int[][][] rotRowE = new int[maxJump+1][mNumCubits][mNumAxis]; |
|
355 |
|
|
352 | 356 |
for(int i=1; i<=maxJump; i++) |
353 |
if( jumpMidSolvedRecursive(quats,i,1,lastA,lastR,solution) ) |
|
357 |
if( jumpMidSolvedRecursive(quats,i,1,lastA,lastR,solution,tmpE,rotRowE) )
|
|
354 | 358 |
{ |
355 | 359 |
solution[0][2] = i; |
356 | 360 |
return solution; |
Also available in: Unified diff
CU_323 solver: speedups