commit c76be0a64c9e554b1d1477dca244d14e119c031f
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Mar 21 17:00:39 2023 +0100

    Progess with Skewb solver.

diff --git a/src/main/java/org/distorted/solvers/SolverSkewb.java b/src/main/java/org/distorted/solvers/SolverSkewb.java
index c231f098..e70b8055 100644
--- a/src/main/java/org/distorted/solvers/SolverSkewb.java
+++ b/src/main/java/org/distorted/solvers/SolverSkewb.java
@@ -15,6 +15,7 @@ import org.distorted.main.R;
 import org.distorted.objectlib.main.ObjectSignatures;
 import org.distorted.objectlib.main.TwistyObject;
 import org.distorted.objectlib.tablebases.ImplementedTablebasesList;
+import org.distorted.objectlib.tablebases.TBSkewb;
 import org.distorted.objectlib.tablebases.TablebaseHelpers;
 import org.distorted.objectlib.tablebases.TablebasesAbstract;
 
@@ -194,105 +195,6 @@ public class SolverSkewb extends SolverTablebase
     return 0;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  // [1][] are the 3 quats the 1st 'fixed' corner will have when 'fakeTwisted' (which in case of
-  // the fixed corners is the same as the final twist) with respectively twist 0,1,2.
-
-  private final int[][] fixedQuats = { {0,1,2},{0,7,8},{0,6,5},{0,4,3} };
-
-  // [1][2][] are the 3 quats the 1st free corner, when permuted to the location of the 2nd corner,
-  // will have when it is 'fakeTwisted' with fakeTwist 0,1,2.
-  // fakeTwist is an intermediate twist which needs yet to be translated to the final twist of the
-  // corners (which needs to sum up to something divisible by 3).
-
-  private final int[][][] freeQuats=
-    {
-        { {0,3,4},{9,8,1},{6,11,2},{7,10,5} },
-        { {9,2,7},{0,5,6},{1,10,3},{4,11,8} },
-        { {5,1,11},{2,4,10},{0,8,7},{9,3,6} },
-        { {8,6,10},{3,7,11},{9,5,4},{0,2,1} }
-    };
-
-  private void fillInQuats(int[] output, int[] perm, int[] twist)
-    {
-    output[0] = fixedQuats[0][twist[0]];
-    output[1] = freeQuats[0][perm[0]][twist[1]];
-    output[2] = freeQuats[1][perm[1]][twist[2]];
-    output[3] = fixedQuats[1][twist[3]];
-    output[4] = freeQuats[2][perm[2]][twist[3]];
-    output[5] = fixedQuats[2][twist[5]];
-    output[6] = fixedQuats[3][twist[6]];
-    output[7] = freeQuats[3][perm[3]][twist[7]];
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int computeLocation(int quat)
-    {
-    for(int i=0; i<4; i++)
-      {
-      int[] q = freeQuats[0][i];
-      if( quat==q[0] || quat==q[1] || quat==q[2] ) return i;
-      }
-
-    android.util.Log.e("D", "error in computeLocation, quat="+quat);
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int retFixed(int index, int quat)
-    {
-    int[] qs = fixedQuats[index];
-
-    if( quat==qs[0]) return 0;
-    if( quat==qs[1]) return 1;
-    if( quat==qs[2]) return 2;
-
-    android.util.Log.e("D", "error in retFixed, index="+index+" quat="+quat);
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int retFree(int index, int quat)
-    {
-    int[][] qs = freeQuats[index];
-
-    for(int i=0; i<4; i++)
-      {
-      if( quat==qs[i][0]) return 0;
-      if( quat==qs[i][1]) return 1;
-      if( quat==qs[i][2]) return 2;
-      }
-
-    android.util.Log.e("D", "error in retFree, index="+index+" quat="+quat);
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// In case of the four 'fixed' corners (0,3,5,6) which do not change their location,
-// the twist is natural: 0 in the init positions and increasing 1 mod 3 on each CW turn.
-//
-// In case of the four 'free' corners their twist is relative to the position of the 'free'
-// tetrahedron. And so, for example the twist of free corner 1 (whose 0th face is orange) is equal
-// to 0 if free corner 7 is on the same face like 0th face of corner 1 (which is the case in init
-// position); then once free corners 2,4,7 permute CW, twist of corner 1 increases by 1 mod 3.
-
-  private void computeCornerTwists(int[] twists, int[] quats)
-    {
-    twists[0] = retFixed(0,quats[0]);
-    twists[3] = retFixed(1,quats[3]);
-    twists[5] = retFixed(2,quats[5]);
-    twists[6] = retFixed(3,quats[6]);
-
-    twists[1] = retFree(0,quats[1]);
-    twists[2] = retFree(1,quats[2]);
-    twists[4] = retFree(2,quats[4]);
-    twists[7] = retFree(3,quats[7]);
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private int retCornerPerm(int index, int[] perm)
@@ -331,7 +233,7 @@ public class SolverSkewb extends SolverTablebase
       else                   twists[i] = 2;
       }
 
-    fillInQuats(quats,perm,twists);
+    TBSkewb.fillInQuats(quats,perm,twists);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -369,7 +271,7 @@ for(int i=0; i<6; i++) android.util.Log.e("D", "face "+i+" : "+mFaceColors[i]);
     if( result4<0 ) return result4;
 
     computeCornerQuats(quats,corners,freePerm);
-    computeCornerTwists(twist,quats);
+    TBSkewb.computeCornerTwists(twist,quats);
 /*
 for(int i=0; i<4; i++) android.util.Log.e("D", "perm "+i+" : "+freePerm[i]);
 for(int i=0; i<8; i++) android.util.Log.e("D", "quat "+i+" : "+quats[i]);
@@ -379,7 +281,7 @@ for(int i=0; i<8; i++) android.util.Log.e("D", "twist "+i+" : "+twist[i]);
     if( (total%3)!=0 ) return ERROR_CORNER_TWISTED;
     int totalTwist = twist[0]+ 3*(twist[1]+ 3*(twist[2]+ 3*(twist[3]+ 3*(twist[4]+ 3*(twist[5]+ 3*twist[6])))));
 
-    int locationOfFree0 = computeLocation(quats[1]);
+    int locationOfFree0 = TBSkewb.computeLocation(quats[1]);
 
     return center_perm_num+ 360*(totalTwist + 2187*locationOfFree0);
     }
@@ -500,8 +402,8 @@ for(int i=0; i<8; i++) android.util.Log.e("D", "twist "+i+" : "+twist[i]);
 
       if( mSolver!=null )
         {
-        mSolver.createTablebase(-1);
-        mSolver.pack();
+        mSolver.createTablebase(2);
+      //  mSolver.pack();
         }
       }
 
