commit f32c546d20d73325e5523f80506a7d87144ad75b
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Feb 28 01:09:05 2023 +0100

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

diff --git a/src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java b/src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java
index c93608a5..3d6177f3 100644
--- a/src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java
+++ b/src/main/java/org/distorted/objectlib/tablebases/TablebasesAbstract.java
@@ -256,19 +256,8 @@ public abstract class TablebasesAbstract
               int currQuat = tmpQuats[cubit];
               int newQuat = getMultQuat(quat,currQuat);
               tmpQuats[cubit] = newQuat;
-
-if( index==0 && ax==2 && layer==1 && angle==2 )
-  {
-  android.util.Log.e("D","cubit "+cubit+" belongs, oldQ="+currQuat+" quat="+quat+" new: "+newQuat);
-  }
               }
 
-if( tmpQuats[4]==0 &&  tmpQuats[5]==1 && tmpQuats[6]==4 && tmpQuats[7]==3 && tmpQuats[8]==10 && tmpQuats[9]==9 )
-  {
-  android.util.Log.e("D","index="+index+" level="+level+" ax="+ax+" layer="+layer+" angle="+angle);
-  android.util.Log.e("D", quats[4]+" "+quats[5]+" "+quats[6]+" "+quats[7]+" "+quats[8]+" "+quats[9]);
-  }
-
           int childIndex = getIndex(tmpQuats);
           if( mTablebase.insertUnpacked(childIndex,newLevel) ) ret++;
           }
diff --git a/src/main/java/org/distorted/objectlib/tablebases/TablebasesPyraminx.java b/src/main/java/org/distorted/objectlib/tablebases/TablebasesPyraminx.java
index 9faf98b2..d89053ed 100644
--- a/src/main/java/org/distorted/objectlib/tablebases/TablebasesPyraminx.java
+++ b/src/main/java/org/distorted/objectlib/tablebases/TablebasesPyraminx.java
@@ -28,7 +28,7 @@ public class TablebasesPyraminx extends TablebasesAbstract
           { 4, 8},
           { 2, 6},
           { 3, 5},
-          { 9,11}
+          {11, 9}
       };
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -150,13 +150,21 @@ public class TablebasesPyraminx extends TablebasesAbstract
 
   private void getEdgeQuats(int twist, int[] perm, int[] output)
     {
-    for(int i=0; i<6; i++)
+    int totalTwist = 0;
+
+    for(int i=0; i<5; i++)
       {
       int p = perm[i];
-      int t = twist%2;
+      int t = (twist%2);
       twist/=2;
       output[i+4] = EDGE_QUATS[p][t];
+
+      totalTwist += t;
       }
+
+    int p = perm[5];
+    int t = (totalTwist%2)==0 ? 0:1;
+    output[9] = EDGE_QUATS[p][t];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -218,7 +226,7 @@ public class TablebasesPyraminx extends TablebasesAbstract
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  int[] getQuats(int index)
+  public int[] getQuats(int index)
     {
     int vertexTwist = (index%81);
     index /= 81;
@@ -229,7 +237,7 @@ public class TablebasesPyraminx extends TablebasesAbstract
 
     getVertexQuats(vertexTwist,quats);
     int[] permutation = new int[6];
-    TablebaseHelpers.getPermutationFromNum(permutation,6,perm_num);
+    TablebaseHelpers.getEvenPermutationFromNum(permutation,6,perm_num);
     getEdgeQuats(edgeTwist,permutation,quats);
 
     return quats;
@@ -237,7 +245,7 @@ public class TablebasesPyraminx extends TablebasesAbstract
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  int getIndex(int[] quats)
+  public int getIndex(int[] quats)
     {
     int vertexTwist = getVertexTwist(quats);
     int[] permutation = new int[6];
@@ -248,15 +256,6 @@ public class TablebasesPyraminx extends TablebasesAbstract
     int edgeTwist = twist[0]+ 2*(twist[1]+ 2*(twist[2]+ 2*(twist[3]+ 2*twist[4])));
     int perm_num = TablebaseHelpers.computeEvenPermutationNum(permutation);
 
-int ret = vertexTwist + 81*(edgeTwist + 32*perm_num);
-
-if( ret<0 || ret>=933120 )
-  {
-  android.util.Log.e("D", "vertexTwist="+vertexTwist+" edgeTwist="+edgeTwist+" perm_num="+perm_num);
-  android.util.Log.e("D", "perm: "+permutation[0]+" "+permutation[1]+" "+permutation[2]+" "+permutation[3]+" "+permutation[4]+" "+permutation[5]);
-  android.util.Log.e("D", "quat: "+quats[4]+" "+quats[5]+" "+quats[6]+" "+quats[7]+" "+quats[8]+" "+quats[9]);
-  }
-
     return vertexTwist + 81*(edgeTwist + 32*perm_num);
     }
 }  
