Project

General

Profile

« Previous | Next » 

Revision 5b9d6595

Added by Leszek Koltunski about 1 year ago

Dino6 solver: corrections to the pruning engine.

View differences:

src/main/java/org/distorted/objectlib/tablebases/TablebasesPruning.java
274 274

  
275 275
///////////////////////////////////////////////////////////////////////////////////////////////////
276 276

  
277
  private boolean jumpMidZeroRecursive(int index, int jump, int depth, int lastA, int lastR, int[][] solution)
277
  private boolean jumpMidSolvedRecursive(int index, int jump, int depth, int lastA, int lastR, int[][] solution)
278 278
    {
279 279
    int[] quats   = getQuats(index);
280 280
    int numQuats  = quats.length;
......
328 328
          return true;
329 329
          }
330 330

  
331
        if( jump>1 && jumpMidZeroRecursive(childIndex, jump-1, depth+1, ax, layer, solution) )
331
        if( jump>1 && jumpMidSolvedRecursive(childIndex, jump-1, depth+1, ax, layer, solution) )
332 332
          {
333 333
          return true;
334 334
          }
......
343 343
///////////////////////////////////////////////////////////////////////////////////////////////////
344 344
// ret: [0][] --> (new index,new depth,num moves,?) ; [1...N-1][] --> moves.
345 345

  
346
  private int[][] jumpToMidOrZero(int index, int maxJump, int lastA, int lastR)
346
  private int[][] jumpToMidOrSolved(int index, int maxJump, int lastA, int lastR)
347 347
    {
348 348
    if( midTablesContain(index)>=0 ) return null;
349 349

  
350 350
    int[][] solution = new int[maxJump+1][4];
351 351

  
352 352
    for(int i=1; i<=maxJump; i++)
353
      if( jumpMidZeroRecursive(index,i,1,lastA,lastR,solution) )
353
      if( jumpMidSolvedRecursive(index,i,1,lastA,lastR,solution) )
354 354
        {
355 355
        solution[0][2] = i;
356 356
        return solution;
......
361 361

  
362 362
///////////////////////////////////////////////////////////////////////////////////////////////////
363 363

  
364
  private boolean jumpZeroRecursive(int index, int jump, int depth, int lastA, int lastR, int[][] solution)
364
  private boolean jumpToSolvedRecursive(int index, int jump, int depth, int lastA, int lastR, int[][] solution)
365 365
    {
366 366
    int[] quats  = getQuats(index);
367 367
    int numQuats = quats.length;
......
398 398
            }
399 399

  
400 400
        int childIndex = getIndex(tmp);
401
        if( childIndex==0 ) return true;
402
        if( jump>1 && jumpZeroRecursive(childIndex, jump-1, depth+1, ax, layer, solution) ) return true;
401
        if( isSolved(childIndex) ) return true;
402
        if( jump>1 && jumpToSolvedRecursive(childIndex, jump-1, depth+1, ax, layer, solution) ) return true;
403 403
        }
404 404

  
405 405
      getNextAxisLayerAngleQuat(move);
......
411 411
///////////////////////////////////////////////////////////////////////////////////////////////////
412 412
// ret: [0][] --> (numMoves,old depth,?,?) ; [1...N-1][] --> moves.
413 413

  
414
  private int[][] jumpToZero(int index, int maxJump, int lastA, int lastR)
414
  private int[][] jumpToSolved(int index, int maxJump, int lastA, int lastR)
415 415
    {
416 416
    int[][] solution = new int[maxJump+1][4];
417 417

  
418 418
    for(int i=1; i<=maxJump; i++)
419
      if( jumpZeroRecursive(index,i,1,lastA,lastR,solution) )
419
      if( jumpToSolvedRecursive(index,i,1,lastA,lastR,solution) )
420 420
        {
421 421
        solution[0][0] = i;
422 422
        return solution;
......
464 464
      }
465 465

  
466 466
    int maxJump = Math.max(mLowestHigh-1-mHighestMid,mLowestMid/2);
467
    int[][] jump1Moves = jumpToMidOrZero(index,maxJump,lastA,lastR);
467
    int[][] jump1Moves = jumpToMidOrSolved(index,maxJump,lastA,lastR);
468 468

  
469 469
    if( jump1Moves!=null )
470 470
      {
471
      if( jump1Moves[0][0]==0 )
471
      if( isSolved(jump1Moves[0][0]) )
472 472
        {
473 473
        return concatenateMoves(null,jump1Moves,null,null);
474 474
        }
475 475
      if( jump1Moves[0][1]==mLowestMid )
476 476
        {
477
        int[][] jump2Moves = jumpToZero(index,mLowestMid-1,-1,0);
478
        if( jump2Moves==null ) throw new RuntimeException("1 error jumping to 0");
477
        int[][] jump2Moves = jumpToSolved(index,mLowestMid-1,-1,0);
478
        if( jump2Moves==null ) throw new RuntimeException("1 error jumping to Solved");
479 479
        return concatenateMoves(null,null,null,jump2Moves);
480 480
        }
481 481

  
......
495 495
      }
496 496
    else throw new RuntimeException("error traversing mid Tables");
497 497

  
498
    int[][] jump2Moves = jumpToZero(index,mLowestMid-1,lastA,lastR);
499
    if( jump2Moves==null ) throw new RuntimeException("2 error jumping to 0");
498
    int[][] jump2Moves = jumpToSolved(index,mLowestMid-1,lastA,lastR);
499
    if( jump2Moves==null ) throw new RuntimeException("2 error jumping to Solved");
500 500
    return concatenateMoves(highMoves,jump1Moves,midMoves,jump2Moves);
501 501
    }
502 502
}

Also available in: Unified diff