commit 4a5157a1fadaa268955fbb3198c340f2268c7533
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Oct 12 17:39:58 2021 +0200

    Rotations of a Cuboid - finished.

diff --git a/src/main/java/org/distorted/objectlib/helpers/ScrambleState.java b/src/main/java/org/distorted/objectlib/helpers/ScrambleState.java
index 24c712fa..f8739a31 100644
--- a/src/main/java/org/distorted/objectlib/helpers/ScrambleState.java
+++ b/src/main/java/org/distorted/objectlib/helpers/ScrambleState.java
@@ -25,7 +25,7 @@ import java.util.Random;
 
 public class ScrambleState
 {
-  private final int mTotal, mNumAxis;
+  private final int mTotal, mNumAxis, mNumNonZero;
   private final int[] mNum;
   private final int[] mInfo;
   private final int[] mTmp;
@@ -39,7 +39,7 @@ public class ScrambleState
 
     mNumAxis = axis.length;
     mNum = new int[mNumAxis];
-    int total =0;
+    int nonzero=0, total =0;
 
     for(int i=0; i<mNumAxis; i++)
       {
@@ -47,6 +47,9 @@ public class ScrambleState
       total += mNum[i];
       }
 
+    for(int i=0; i<mNumAxis; i++) if( mNum[i]>0 ) nonzero++;
+
+    mNumNonZero = nonzero;
     mTotal = total;
 
     mInfo = new int[LEN*total];
@@ -84,6 +87,8 @@ public class ScrambleState
     {
     int num=0, total=0, max=0, ax, layer;
 
+    if( mNumNonZero<2 ) indexExcluded=-1;
+
     for(int i=0; i<mTotal; i++)
       {
       ax = mInfo[LEN*i];
diff --git a/src/main/java/org/distorted/objectlib/main/TwistyObjectScrambler.java b/src/main/java/org/distorted/objectlib/main/TwistyObjectScrambler.java
index 903f9f7c..46efb52b 100644
--- a/src/main/java/org/distorted/objectlib/main/TwistyObjectScrambler.java
+++ b/src/main/java/org/distorted/objectlib/main/TwistyObjectScrambler.java
@@ -69,40 +69,6 @@ public class TwistyObjectScrambler
       }
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// QUATS[i]*QUATS[j] = QUATS[QUAT_MULT[i][j]]
-
-  void initializeQuatMult()
-    {
-    mQuatMult = new int[][]
-      {
-        {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,},
-        {  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,  0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12,},
-        {  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,  0,  1, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13,},
-        {  3,  4,  5,  6,  7,  8,  9, 10, 11,  0,  1,  2, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14,},
-        {  4,  5,  6,  7,  8,  9, 10, 11,  0,  1,  2,  3, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15,},
-        {  5,  6,  7,  8,  9, 10, 11,  0,  1,  2,  3,  4, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16,},
-        {  6,  7,  8,  9, 10, 11,  0,  1,  2,  3,  4,  5, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17,},
-        {  7,  8,  9, 10, 11,  0,  1,  2,  3,  4,  5,  6, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18,},
-        {  8,  9, 10, 11,  0,  1,  2,  3,  4,  5,  6,  7, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19,},
-        {  9, 10, 11,  0,  1,  2,  3,  4,  5,  6,  7,  8, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20,},
-        { 10, 11,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,},
-        { 11,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,},
-        { 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13,  0, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,},
-        { 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14,  1,  0, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,},
-        { 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15,  2,  1,  0, 11, 10,  9,  8,  7,  6,  5,  4,  3,},
-        { 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16,  3,  2,  1,  0, 11, 10,  9,  8,  7,  6,  5,  4,},
-        { 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17,  4,  3,  2,  1,  0, 11, 10,  9,  8,  7,  6,  5,},
-        { 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18,  5,  4,  3,  2,  1,  0, 11, 10,  9,  8,  7,  6,},
-        { 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19,  6,  5,  4,  3,  2,  1,  0, 11, 10,  9,  8,  7,},
-        { 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20,  7,  6,  5,  4,  3,  2,  1,  0, 11, 10,  9,  8,},
-        { 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21,  8,  7,  6,  5,  4,  3,  2,  1,  0, 11, 10,  9,},
-        { 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0, 11, 10,},
-        { 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0, 11,},
-        { 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0,}
-      };
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void initializeScrambling()
@@ -155,6 +121,44 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// QUATS[i]*QUATS[j] = QUATS[QUAT_MULT[i][j]]
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void initializeQuatMult()
+    {
+    mQuatMult = new int[][]
+      {
+        {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,},
+        {  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,  0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12,},
+        {  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,  0,  1, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13,},
+        {  3,  4,  5,  6,  7,  8,  9, 10, 11,  0,  1,  2, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14,},
+        {  4,  5,  6,  7,  8,  9, 10, 11,  0,  1,  2,  3, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15,},
+        {  5,  6,  7,  8,  9, 10, 11,  0,  1,  2,  3,  4, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16,},
+        {  6,  7,  8,  9, 10, 11,  0,  1,  2,  3,  4,  5, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17,},
+        {  7,  8,  9, 10, 11,  0,  1,  2,  3,  4,  5,  6, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18,},
+        {  8,  9, 10, 11,  0,  1,  2,  3,  4,  5,  6,  7, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19,},
+        {  9, 10, 11,  0,  1,  2,  3,  4,  5,  6,  7,  8, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20,},
+        { 10, 11,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,},
+        { 11,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,},
+        { 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13,  0, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,},
+        { 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14,  1,  0, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,},
+        { 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15,  2,  1,  0, 11, 10,  9,  8,  7,  6,  5,  4,  3,},
+        { 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16,  3,  2,  1,  0, 11, 10,  9,  8,  7,  6,  5,  4,},
+        { 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17,  4,  3,  2,  1,  0, 11, 10,  9,  8,  7,  6,  5,},
+        { 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18,  5,  4,  3,  2,  1,  0, 11, 10,  9,  8,  7,  6,},
+        { 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19,  6,  5,  4,  3,  2,  1,  0, 11, 10,  9,  8,  7,},
+        { 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20,  7,  6,  5,  4,  3,  2,  1,  0, 11, 10,  9,  8,},
+        { 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21,  8,  7,  6,  5,  4,  3,  2,  1,  0, 11, 10,  9,},
+        { 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0, 11, 10,},
+        { 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0, 11,},
+        { 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10,  9,  8,  7,  6,  5,  4,  3,  2,  1,  0,}
+      };
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private boolean cornerIsUp(int index)
     {
@@ -162,6 +166,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private boolean cornerIsLeft(int index)
     {
@@ -183,6 +188,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private boolean quatIsBad(int quatIndex, int corner)
     {
@@ -201,6 +207,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private boolean isPermittedDo(int angle)
     {
@@ -220,6 +227,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private boolean isPermittedUp(int angle)
     {
@@ -239,6 +247,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private void computePermittedAngles()
     {
@@ -258,6 +267,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private int getNextAngle(Random rnd, int layer)
     {
@@ -268,6 +278,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private int getNextAngleNotZero(Random rnd, int layer)
     {
@@ -278,6 +289,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private int makeQuat(int axis,int index)
     {
@@ -287,6 +299,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private boolean cornerBelongs(int index, int axis, int layer)
     {
@@ -303,6 +316,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private void updateCornerQuats(int[] rotInfo)
     {
@@ -325,6 +339,7 @@ public class TwistyObjectScrambler
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// TYPE 1
 
   private void randomizeNewScramble1(int[][] scramble, Random rnd, int curr, int total)
     {
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java b/src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java
index 3d875c14..9569da43 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java
@@ -75,6 +75,8 @@ public class TwistyCuboid extends Twisty6
 
   private int[] createEdges(int size, boolean full, int vertex)
     {
+    if( size==1 ) return null;
+
     if( full )
       {
       int[] ret = new int[9*size];
@@ -128,29 +130,52 @@ public class TwistyCuboid extends Twisty6
       int[][] mY = new int[16][];
       int[][] mZ = new int[16][];
 
-      for(int i=1; i<16; i++) mX[i] = createEdges(X,Y==Z,i);
-      for(int i=1; i<16; i++) mY[i] = createEdges(Y,X==Z,i);
-      for(int i=1; i<16; i++) mZ[i] = createEdges(Z,X==Y,i);
+      for(int i=0; i<16; i++)
+        {
+        mX[i] = createEdges(X,Y==Z,i);
+        mY[i] = createEdges(Y,X==Z,i);
+        mZ[i] = createEdges(Z,X==Y,i);
+        }
 
-      mStates = new ScrambleState[]
+      if( X>1 && Y>1 && Z>1 )
         {
-        new ScrambleState( new int[][] { mX[ 1], mY[ 2], mZ[ 3] } ),  //  0 0
-        new ScrambleState( new int[][] {   null, mY[ 4], mZ[ 5] } ),  //  1 x
-        new ScrambleState( new int[][] { mX[ 6],   null, mZ[ 7] } ),  //  2 y
-        new ScrambleState( new int[][] { mX[ 8], mY[ 9],   null } ),  //  3 z
-        new ScrambleState( new int[][] { mX[10],   null, mZ[ 7] } ),  //  4 xy
-        new ScrambleState( new int[][] { mX[11], mY[ 9],   null } ),  //  5 xz
-        new ScrambleState( new int[][] {   null, mY[12], mZ[ 5] } ),  //  6 yx
-        new ScrambleState( new int[][] { mX[ 8], mY[13],   null } ),  //  7 yz
-        new ScrambleState( new int[][] {   null, mY[ 4], mZ[14] } ),  //  8 zx
-        new ScrambleState( new int[][] { mX[ 6],   null, mZ[15] } ),  //  9 zy
-        new ScrambleState( new int[][] {   null,   null, mZ[ 5] } ),  // 10 xyx
-        new ScrambleState( new int[][] {   null, mY[ 4],   null } ),  // 11 xzx
-        new ScrambleState( new int[][] {   null,   null, mZ[ 7] } ),  // 12 yxy
-        new ScrambleState( new int[][] { mX[ 6],   null,   null } ),  // 13 yzy
-        new ScrambleState( new int[][] {   null, mY[ 9],   null } ),  // 14 zxz
-        new ScrambleState( new int[][] { mX[ 8],   null,   null } ),  // 15 zyz
-        };
+        mStates = new ScrambleState[]
+          {
+          new ScrambleState( new int[][] { mX[ 1], mY[ 2], mZ[ 3] } ),  //  0 0
+          new ScrambleState( new int[][] {   null, mY[ 4], mZ[ 5] } ),  //  1 x
+          new ScrambleState( new int[][] { mX[ 6],   null, mZ[ 7] } ),  //  2 y
+          new ScrambleState( new int[][] { mX[ 8], mY[ 9],   null } ),  //  3 z
+          new ScrambleState( new int[][] { mX[10],   null, mZ[ 7] } ),  //  4 xy
+          new ScrambleState( new int[][] { mX[11], mY[ 9],   null } ),  //  5 xz
+          new ScrambleState( new int[][] {   null, mY[12], mZ[ 5] } ),  //  6 yx
+          new ScrambleState( new int[][] { mX[ 8], mY[13],   null } ),  //  7 yz
+          new ScrambleState( new int[][] {   null, mY[ 4], mZ[14] } ),  //  8 zx
+          new ScrambleState( new int[][] { mX[ 6],   null, mZ[15] } ),  //  9 zy
+          new ScrambleState( new int[][] {   null,   null, mZ[ 5] } ),  // 10 xyx
+          new ScrambleState( new int[][] {   null, mY[ 4],   null } ),  // 11 xzx
+          new ScrambleState( new int[][] {   null,   null, mZ[ 7] } ),  // 12 yxy
+          new ScrambleState( new int[][] { mX[ 6],   null,   null } ),  // 13 yzy
+          new ScrambleState( new int[][] {   null, mY[ 9],   null } ),  // 14 zxz
+          new ScrambleState( new int[][] { mX[ 8],   null,   null } ),  // 15 zyz
+          };
+        }
+      else if( X==1 && Y==1 && Z==1 )
+        {
+        int[] state = new int[] {0,-1,0,0,1,0,0,2,0};
+
+        mStates = new ScrambleState[]
+          {
+          new ScrambleState( new int[][] { state, state, state } )
+          };
+        }
+      else
+        {
+        mStates = new ScrambleState[]
+          {
+          new ScrambleState( new int[][] { mX[ 0], mY[ 0], mZ[ 0] } )
+          };
+        }
+
       }
 
     return mStates;
