commit 5b9e0ba45bd13872c4b931a4a62a3ce22dbf8a26
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Apr 25 13:22:12 2023 +0200

    CU_323 solver: new schema.

diff --git a/src/main/java/org/distorted/objectlib/tablebases/TBCuboid323.java b/src/main/java/org/distorted/objectlib/tablebases/TBCuboid323.java
index 735d9807..6c7d74e9 100644
--- a/src/main/java/org/distorted/objectlib/tablebases/TBCuboid323.java
+++ b/src/main/java/org/distorted/objectlib/tablebases/TBCuboid323.java
@@ -40,36 +40,20 @@ public class TBCuboid323 extends TablebasesPruning
           {6,7,4,2,5,3,1,0}
       };
 
-  private static boolean mFixedEdgeIsDown;
-  private int[][] mAngles;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public static void initialize()
-    {
-    mFixedEdgeIsDown = true;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// We must have perm[1]==1 or perm[1]==3, depending on if inPlace==true;
-// remove this extraneous perm member.
+// remove perm[1] which is always equal to 1.
 
   public static int[] edgePermTo7(int[] perm)
     {
     int[] ret = new int[7];
 
-    ret[0] = perm[0];
-    ret[1] = perm[2];
-    ret[2] = perm[3];
-    ret[3] = perm[4];
-    ret[4] = perm[5];
-    ret[5] = perm[6];
-    ret[6] = perm[7];
-
-    int val = perm[1];
-
-    for(int i=0; i<7; i++)
-      if( ret[i]>val ) ret[i]--;
+    ret[0] = perm[0]; if( ret[0]>1 ) ret[0]--;
+    ret[1] = perm[2]; if( ret[1]>1 ) ret[1]--;
+    ret[2] = perm[3]; if( ret[2]>1 ) ret[2]--;
+    ret[3] = perm[4]; if( ret[3]>1 ) ret[3]--;
+    ret[4] = perm[5]; if( ret[4]>1 ) ret[4]--;
+    ret[5] = perm[6]; if( ret[5]>1 ) ret[5]--;
+    ret[6] = perm[7]; if( ret[6]>1 ) ret[6]--;
 
     return ret;
     }
@@ -77,19 +61,18 @@ public class TBCuboid323 extends TablebasesPruning
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // reverse the above
 
-  private static int[] edgePermTo8(int[] perm, boolean inPlace)
+  private static int[] edgePermTo8(int[] perm)
     {
     int[] ret = new int[8];
-    int val = inPlace ? 1:3;
 
-    ret[0] = perm[0]; if( ret[0]>=val ) ret[0]++;
-    ret[1] = val;
-    ret[2] = perm[1]; if( ret[2]>=val ) ret[2]++;
-    ret[3] = perm[2]; if( ret[3]>=val ) ret[3]++;
-    ret[4] = perm[3]; if( ret[4]>=val ) ret[4]++;
-    ret[5] = perm[4]; if( ret[5]>=val ) ret[5]++;
-    ret[6] = perm[5]; if( ret[6]>=val ) ret[6]++;
-    ret[7] = perm[6]; if( ret[7]>=val ) ret[7]++;
+    ret[0] = perm[0]; if( ret[0]>=1 ) ret[0]++;
+    ret[1] = 1;
+    ret[2] = perm[1]; if( ret[2]>=1 ) ret[2]++;
+    ret[3] = perm[2]; if( ret[3]>=1 ) ret[3]++;
+    ret[4] = perm[3]; if( ret[4]>=1 ) ret[4]++;
+    ret[5] = perm[4]; if( ret[5]>=1 ) ret[5]++;
+    ret[6] = perm[5]; if( ret[6]>=1 ) ret[6]++;
+    ret[7] = perm[6]; if( ret[7]>=1 ) ret[7]++;
 
     return ret;
     }
@@ -105,21 +88,16 @@ public class TBCuboid323 extends TablebasesPruning
 
   public TBCuboid323(OperatingSystemInterface os)
     {
-    super(os,new int[] {R.raw.cu_323_pruning6,R.raw.cu_323_pruning7}, new int[] {R.raw.cu_323_pruning17,R.raw.cu_323_pruning18});
+    super(os,new int[] {R.raw.cu_323_pruning7,R.raw.cu_323_pruning8}, new int[] {R.raw.cu_323_pruning18});
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   int[][] getBasicAngles()
     {
-    if( mAngles==null )
-      {
-      int[] tmp2 = {2,2,2};
-      int[] tmp4 = {4,4};
-      mAngles = new int[][] { tmp2,tmp4,tmp2 };
-      }
-
-    return mAngles;
+    int[] tmp2 = {2,2,2};
+    int[] tmp4 = {4,4};
+    return new int[][] { tmp2,tmp4,tmp2 };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -174,33 +152,11 @@ public class TBCuboid323 extends TablebasesPruning
 
   boolean[][] getRotatable()
     {
-    return new boolean[][] { {true,false,true},{true,false},{true,false,true} };
+    return new boolean[][] { {true,false,true},{false,true},{true,true,false} };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // specifically for the tablebase
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// edge1 (i.e. the edge which is initially in the lower front) needs to stay in front.
-
-  @Override
-  int[] newMove(int axis, int layer, int angle)
-    {
-    if( axis==2 && layer==2 ) mFixedEdgeIsDown = !mFixedEdgeIsDown;
-    if( axis==1 )
-      {
-      if( angle==3 ) angle=-1;
-
-      if( layer==0 &&  mFixedEdgeIsDown ) return new int[] { axis, 2, angle };
-      if( layer==1 && !mFixedEdgeIsDown ) return new int[] { axis, 1, angle };
-      }
-
-    int maxAngle = mAngles[axis][layer];
-    angle = maxAngle-angle;
-    if( angle> 0.5f*maxAngle ) angle -= maxAngle;
-
-    return new int[] { axis, (1<<layer), angle };
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // 8!*8!/4 --> https://www.jaapsch.net/puzzles/domino.htm
 
@@ -220,14 +176,14 @@ public class TBCuboid323 extends TablebasesPruning
 
   int[] getMidPruningLevels()
     {
-    return new int[] {6,7};
+    return new int[] {7,8};
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   int[] getHighPruningLevels()
     {
-    return null;//new int[] {17,18};
+    return new int[] {18};
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -256,31 +212,15 @@ public class TBCuboid323 extends TablebasesPruning
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public static boolean isFrontEdgeInItsPlace(int[] perm)
+  private int centersInverted(int[] quats)
     {
-    return perm[1]==1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void normalizeQuats(int[] quats)
-    {
-    int mult=0;
-
-    switch(quats[9])
-      {
-      case 0: case 5: return;
-      case 4: case 7: mult=2; break;
-      case 1: case 3: mult=3; break;
-      case 2: case 6: mult=4; break;
-      }
-
-    for(int i=0; i<16; i++) quats[i] = getMultQuat(mult,quats[i]);
+    int q = quats[16];
+    return (q==0 || q==2 || q==3 || q==4) ? 0 : 1;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public static int[] quatsFromPermutations(int[] corner, int[] edge8)
+  public static int[] quatsFromPermutations(int[] corner, int[] edge8, int centers)
     {
     int[] quats = new int[18];
 
@@ -295,6 +235,17 @@ public class TBCuboid323 extends TablebasesPruning
       quats[i+8] = q;
       }
 
+    if( centers==0 )
+      {
+      quats[16]=0;
+      quats[17]=0;
+      }
+    else
+      {
+      quats[16]=5;
+      quats[17]=5;
+      }
+
     return quats;
     }
 
@@ -316,16 +267,16 @@ public class TBCuboid323 extends TablebasesPruning
 
   public int[] getQuats(int index)
     {
-    int cornerPermNum = index%40320;
+    int cornerPermNum = (index%40320);
     index /= 40320;
-    boolean inPlace = ((index%2)==0);
+    int centers = (index%2);
     int edgePermNum = index/2;
 
     int[] corner_perm = new int[8];
     TablebaseHelpers.getPermutationFromNum(corner_perm,8,cornerPermNum);
     int[] edge_perm7 = new int[7];
     TablebaseHelpers.getPermutationFromNum(edge_perm7,7,edgePermNum);
-    int[] edge_perm8 = edgePermTo8(edge_perm7,inPlace);
+    int[] edge_perm8 = edgePermTo8(edge_perm7);
 /*
 TablebaseHelpers.displayTable(corner_perm, "CORNER");
 TablebaseHelpers.displayTable(edge_perm8, "EDGE8");
@@ -333,15 +284,13 @@ TablebaseHelpers.displayTable(edge_perm7, "EDGE7");
 android.util.Log.e("D", "inPlace="+inPlace);
 */
 
-    return quatsFromPermutations(corner_perm,edge_perm8);
+    return quatsFromPermutations(corner_perm,edge_perm8,centers);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public int getIndex(int[] quats)
     {
-    normalizeQuats(quats);
-
     int[] corner_perm = new int[8];
     cornerFromQuats(corner_perm,quats);
     int[] edge_perm8  = new int[8];
@@ -350,9 +299,9 @@ android.util.Log.e("D", "inPlace="+inPlace);
 
     int corner_perm_num = TablebaseHelpers.computePermutationNum(corner_perm);
     int edge_perm_num = TablebaseHelpers.computePermutationNum(edge_perm7);
-    boolean inPlace = isFrontEdgeInItsPlace(edge_perm8);
+    int centers = centersInverted(quats);
 
-    return corner_perm_num + 40320*( (inPlace?0:1) + 2*edge_perm_num);
+    return corner_perm_num + 40320*( centers + 2*edge_perm_num);
     }
 }  
 
diff --git a/src/main/res/raw/cu_323_pruning17.db b/src/main/res/raw/cu_323_pruning17.db
deleted file mode 100644
index aa9651f4..00000000
Binary files a/src/main/res/raw/cu_323_pruning17.db and /dev/null differ
diff --git a/src/main/res/raw/cu_323_pruning18.db b/src/main/res/raw/cu_323_pruning18.db
index aa26d51c..8648db6a 100644
Binary files a/src/main/res/raw/cu_323_pruning18.db and b/src/main/res/raw/cu_323_pruning18.db differ
diff --git a/src/main/res/raw/cu_323_pruning6.db b/src/main/res/raw/cu_323_pruning6.db
deleted file mode 100644
index 79990860..00000000
Binary files a/src/main/res/raw/cu_323_pruning6.db and /dev/null differ
diff --git a/src/main/res/raw/cu_323_pruning7.db b/src/main/res/raw/cu_323_pruning7.db
index 133ff72c..fdaf8af0 100644
Binary files a/src/main/res/raw/cu_323_pruning7.db and b/src/main/res/raw/cu_323_pruning7.db differ
