Project

General

Profile

« Previous | Next » 

Revision 74cc695a

Added by Leszek Koltunski about 1 year ago

Pyraminx solver: tablebase working now (tipless, tips to be added in the SolverPyraminx class)

View differences:

src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java
436 436

  
437 437
      if( !found )
438 438
        {
439
        android.util.Log.e("D", "solution error: no move found!");
439
        android.util.Log.e("D", "----> solution error: no move found!");
440 440
        return null;
441 441
        }
442 442
      }
......
517 517

  
518 518
    return moves;
519 519
    }
520

  
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522

  
523
  public boolean test(int index)
524
    {
525
    if( !mInitialized ) return false;
526

  
527
    int[] data = new int[4];
528
    byte level = mTablebase.retrievePacked(index);
529
    int[] quats = getQuats(index);
530
    int numQuats = quats.length;
531
    int[] tmpQuats = new int[numQuats];
532

  
533
    data[0]=0;
534
    data[1]=0;
535
    data[2]=1;
536
    data[3]=1;
537

  
538
    for(int ax=0; ax<mNumAxis; ax++)
539
      for(int cubit=0; cubit<mNumCubits; cubit++)
540
        mRotRow[cubit][ax] = computeRow(mPosition[cubit],quats[cubit],ax);
541

  
542
    for(int s=0; s<mScalingFactor; s++)
543
      {
544
      int ax    = data[0];
545
      int layer = data[1];
546
      int quat  = data[3];
547

  
548
      if( mRotatable[ax][layer] )
549
        {
550
        int bitLayer = (1<<layer);
551
        System.arraycopy(quats, 0, tmpQuats, 0, numQuats);
552

  
553
        for(int cubit=0; cubit<mNumCubits; cubit++)
554
          if( mRotRow[cubit][ax]==bitLayer )
555
            {
556
            int currQuat = tmpQuats[cubit];
557
            int newQuat = getMultQuat(quat,currQuat);
558
            tmpQuats[cubit] = newQuat;
559
            }
560

  
561
        int childIndex = getIndex(tmpQuats);
562
        byte newLevel = mTablebase.retrievePacked(childIndex);
563

  
564
        if( ((newLevel-level+1)%3) == 0 ) return true;
565
        }
566

  
567
      getNextAxisLayerAngleQuat(data);
568
      }
569

  
570
    return false;
571
    }
520 572
}

Also available in: Unified diff