Revision cd595931
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/objectlib/tablebases/TablebasesPruning.java | ||
---|---|---|
315 | 315 |
|
316 | 316 |
if( childIndex==0 ) |
317 | 317 |
{ |
318 |
android.util.Log.e("D", "1 jumped to mid: index="+childIndex); |
|
319 |
|
|
320 | 318 |
solution[0][0] = childIndex; |
321 | 319 |
solution[0][1] = 0; |
322 | 320 |
return true; |
... | ... | |
326 | 324 |
|
327 | 325 |
if( containingTable>=0 ) |
328 | 326 |
{ |
329 |
android.util.Log.e("D", "2 jumped to mid: index="+childIndex); |
|
330 |
|
|
331 | 327 |
solution[0][0] = childIndex; |
332 | 328 |
solution[0][1] = mMidTables[containingTable].getLevel(); |
333 | 329 |
return true; |
... | ... | |
346 | 342 |
} |
347 | 343 |
|
348 | 344 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
349 |
// ret: [0][] --> (num moves,old depth,?,?) ; [1...N-1][] --> moves.
|
|
345 |
// ret: [0][] --> (new index,new depth,num moves,?) ; [1...N-1][] --> moves.
|
|
350 | 346 |
|
351 | 347 |
private int[][] jumpToMidOrZero(int index, int maxJump, int lastA, int lastR) |
352 | 348 |
{ |
... | ... | |
357 | 353 |
for(int i=1; i<=maxJump; i++) |
358 | 354 |
if( jumpMidZeroRecursive(index,i,1,lastA,lastR,solution) ) |
359 | 355 |
{ |
360 |
solution[0][0] = i;
|
|
356 |
solution[0][2] = i;
|
|
361 | 357 |
return solution; |
362 | 358 |
} |
363 | 359 |
|
... | ... | |
379 | 375 |
move[2]=1; |
380 | 376 |
move[3]=1; |
381 | 377 |
|
382 |
if( jump==3 ) android.util.Log.e("D", "trying index="+index+" depth="+depth+" lastA="+lastA+" lastR="+lastR); |
|
383 |
|
|
384 | 378 |
for(int ax=0; ax<mNumAxis; ax++) |
385 | 379 |
for(int cubit=0; cubit<mNumCubits; cubit++) |
386 | 380 |
rotRow[cubit][ax] = computeRow(mPosition[cubit],quats[cubit],ax); |
387 |
/* |
|
388 |
if( index==1719861 ) |
|
389 |
{ |
|
390 |
StringBuilder sb4 = new StringBuilder(); |
|
391 |
for(int a=0; a<mNumAxis; a++) |
|
392 |
{ |
|
393 |
for(int c=0; c<mNumCubits; c++) |
|
394 |
{ |
|
395 |
sb4.append(mRotRow[c][a]); |
|
396 |
sb4.append(' '); |
|
397 |
} |
|
398 |
sb4.append("\n"); |
|
399 | 381 |
|
400 |
} |
|
401 |
android.util.Log.e("D", "1 rotRows= \n"+sb4 ); |
|
402 |
} |
|
403 |
*/ |
|
404 | 382 |
for(int s=0; s<mScalingFactor; s++) |
405 | 383 |
{ |
406 | 384 |
int ax = move[0]; |
... | ... | |
419 | 397 |
int newQuat = getMultQuat(quat,currQuat); |
420 | 398 |
tmp[cubit] = newQuat; |
421 | 399 |
} |
422 |
/* |
|
423 |
if( depth==1 && ax==1 && layer==1 && move[2]==3 ) |
|
424 |
{ |
|
425 |
StringBuilder sb2 = new StringBuilder(); |
|
426 |
for(int i=0; i<8; i++) { sb2.append(' '); sb2.append(quats[i]); } |
|
427 |
android.util.Log.e("D", " quats= "+sb2 ); |
|
428 |
|
|
429 |
StringBuilder sb3 = new StringBuilder(); |
|
430 |
for(int i=0; i<8; i++) { sb3.append(' '); sb3.append(tmp[i]); } |
|
431 |
android.util.Log.e("D", " tmpQuats= "+sb3 ); |
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
android.util.Log.e("D", " index= "+index ); |
|
436 |
} |
|
437 |
|
|
438 |
|
|
439 |
if( index==1719861 ) |
|
440 |
{ |
|
441 |
StringBuilder sb4 = new StringBuilder(); |
|
442 |
for(int a=0; a<mNumAxis; a++) |
|
443 |
{ |
|
444 |
for(int c=0; c<mNumCubits; c++) |
|
445 |
{ |
|
446 |
sb4.append(mRotRow[c][a]); |
|
447 |
sb4.append(' '); |
|
448 |
} |
|
449 |
sb4.append("\n"); |
|
450 |
|
|
451 |
} |
|
452 |
android.util.Log.e("D", "2 rotRows= \n"+sb4 ); |
|
453 |
} |
|
454 |
*/ |
|
455 | 400 |
|
456 | 401 |
int childIndex = getIndex(tmp); |
457 | 402 |
if( childIndex==0 ) return true; |
... | ... | |
486 | 431 |
private int[][] concatenateMoves(int[][] high, int[][] jump1, int[][] mid, int[][] jump2) |
487 | 432 |
{ |
488 | 433 |
int len1 = high ==null ? 0 : high.length-1; |
489 |
int len2 = jump1==null ? 0 : jump1[0][0];
|
|
434 |
int len2 = jump1==null ? 0 : jump1[0][2];
|
|
490 | 435 |
int len3 = mid ==null ? 0 : mid.length-1; |
491 | 436 |
int len4 = jump2==null ? 0 : jump2[0][0]; |
492 | 437 |
|
... | ... | |
526 | 471 |
{ |
527 | 472 |
if( jump1Moves[0][0]==0 ) |
528 | 473 |
{ |
529 |
return concatenateMoves(null,null,null,jump1Moves);
|
|
474 |
return concatenateMoves(null,jump1Moves,null,null);
|
|
530 | 475 |
} |
531 | 476 |
if( jump1Moves[0][1]==mLowestMid ) |
532 | 477 |
{ |
... | ... | |
536 | 481 |
} |
537 | 482 |
|
538 | 483 |
index = jump1Moves[0][0]; |
539 |
int len = jump1Moves.length;
|
|
540 |
lastA = jump1Moves[len-1][0];
|
|
541 |
lastR = jump1Moves[len-1][1];
|
|
484 |
int len = jump1Moves[0][2];
|
|
485 |
lastA = jump1Moves[len][0]; |
|
486 |
lastR = jump1Moves[len][1]; |
|
542 | 487 |
} |
543 | 488 |
|
544 | 489 |
int[][] midMoves = traverseBlock(index,mMidTables,lastA,lastR); |
... | ... | |
551 | 496 |
} |
552 | 497 |
else throw new RuntimeException("error traversing mid Tables"); |
553 | 498 |
|
554 |
android.util.Log.e("D", "index now="+index+" depth now "+midMoves[0][1]+" ax="+midMoves[1][0]+" row="+midMoves[1][1]+" angle="+midMoves[1][2]); |
|
555 |
|
|
556 | 499 |
int[][] jump2Moves = jumpToZero(index,mLowestMid-1,lastA,lastR); |
557 | 500 |
if( jump2Moves==null ) throw new RuntimeException("2 error jumping to 0"); |
558 | 501 |
return concatenateMoves(highMoves,jump1Moves,midMoves,jump2Moves); |
Also available in: Unified diff
TablebasesPruning seems to be working now, at least with Cube2.