commit 38589947f1d07600e5deef4460d56e9a4a954b24
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Aug 30 10:51:31 2021 +0200

    Unify scrambling across all 4 bandaged objects.

diff --git a/src/main/java/org/distorted/objects/TwistyBandaged2Bar.java b/src/main/java/org/distorted/objects/TwistyBandaged2Bar.java
index 2deaf02e..b2c59f17 100644
--- a/src/main/java/org/distorted/objects/TwistyBandaged2Bar.java
+++ b/src/main/java/org/distorted/objects/TwistyBandaged2Bar.java
@@ -21,6 +21,7 @@ package org.distorted.objects;
 
 import android.content.res.Resources;
 
+import org.distorted.helpers.ScrambleStateGraph;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshSquare;
@@ -67,6 +68,13 @@ class TwistyBandaged2Bar extends TwistyBandagedAbstract
                      DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
     {
     super(size, quat, texture, mesh, effects, moves, ObjectList.BAN2, res, scrWidth);
+
+    mStates = new ScrambleStateGraph[]
+      {
+      new ScrambleStateGraph( new int[][] { {}                                          , {0,1,1, 0,-1,1, 2,1,2, 2,-1,2}, {} }),
+      new ScrambleStateGraph( new int[][] { {0,-1,1, 0,1,1, 0,2,1, 2,-1,1, 2,1,1, 2,2,1}, {0,2,1, 2,2,1}                , {} }),
+      new ScrambleStateGraph( new int[][] { {}, {0,2,2, 2,2,2}                , {0,-1,2, 0,1,2, 0,2,2, 2,-1,2, 2,1,2, 2,2,2} })
+      };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -86,43 +94,6 @@ class TwistyBandaged2Bar extends TwistyBandagedAbstract
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 
-  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
-    {
-    if( curr==0 )
-      {
-      int random = rnd.nextInt(4);
-
-      scramble[curr][0] = 1;
-      scramble[curr][1] = random>1      ?  2:0;
-      scramble[curr][2] = random%2 == 0 ? -1:1;
-      }
-    else
-      {
-      boolean even = ((curr%2) == 0);
-      int angle = rnd.nextInt(4);
-
-      scramble[curr][0] = even ? 1 : scramble[0][1];
-      scramble[curr][1] = rnd.nextInt(3);
-
-      if( even == (scramble[curr][1]==1) )
-        {
-        switch(angle)
-          {
-          case 0: scramble[curr][2] = -2; break;
-          case 1: scramble[curr][2] = -1; break;
-          case 2: scramble[curr][2] =  1; break;
-          case 3: scramble[curr][2] =  2; break;
-          }
-        }
-      else
-        {
-        scramble[curr][2] = angle>1 ? 2:-2;
-        }
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
   public int getObjectName(int numLayers)
     {
     return R.string.bandaged_2bar;
diff --git a/src/main/java/org/distorted/objects/TwistyBandaged3Plate.java b/src/main/java/org/distorted/objects/TwistyBandaged3Plate.java
index c40bd786..24efdfe4 100644
--- a/src/main/java/org/distorted/objects/TwistyBandaged3Plate.java
+++ b/src/main/java/org/distorted/objects/TwistyBandaged3Plate.java
@@ -34,44 +34,6 @@ import java.util.Random;
 
 class TwistyBandaged3Plate extends TwistyBandagedAbstract
 {
-  private int mCurrState;
-  private int mIndexExcluded;
-
-  // The 16 'significant' states of the 3Plate bandaged cube.
-  // One State means one arrangement of the three 2x2 'plates'. Such State precisely defines which
-  // rotations of the Cube are possible.
-  // There are 27 such states in total, but 2 of them are unreachable from the initial State, and
-  // 9 more are 'insignificant' - i.e. States which only permit rotation along a single axis.
-  // When doing an automatic scramble, we never want to enter such 'insignificant' states because
-  // that would mean we'd have to do two rotations in a row along the same axis.
-  //
-  // 4th State's first 'x' array being '2,-1,10, 2, 2,13' means the following:
-  // if we are in the 4th state, and make move (2,-1) [i.e. rotation along the X axis, 2nd row, -1 angle]
-  // then we will land in state 10. If we make move (2,2), we will land in state 13. There are no other
-  // 'x' moves that lead to a 'significant' state.
-
-  private final ScrambleStateGraph[] mStates = new ScrambleStateGraph[]
-    {
-    new ScrambleStateGraph( new int[][] {{ 2,-1, 1, 2, 1, 6                  }, { 0,-1, 5, 0, 1, 3                  }, { 2,-1, 2, 2, 1, 4                  }} ),
-    new ScrambleStateGraph( new int[][] {{ 2, 1, 0                           }, {                                   }, { 2, 1,10, 2, 2, 7                  }} ),
-    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,11, 0, 2, 8                  }, { 2, 1, 0                           }} ),
-    new ScrambleStateGraph( new int[][] {{ 2, 1,12, 2, 2, 9                  }, { 0,-1, 0                           }, {                                   }} ),
-    new ScrambleStateGraph( new int[][] {{ 2,-1,10, 2, 2,13                  }, {                                   }, { 2,-1, 0                           }} ),
-    new ScrambleStateGraph( new int[][] {{                                   }, { 0, 1, 0                           }, { 2,-1,11, 2, 2,14                  }} ),
-    new ScrambleStateGraph( new int[][] {{ 2,-1, 0                           }, { 0, 1,12, 0, 2,15                  }, {                                   }} ),
-    new ScrambleStateGraph( new int[][] {{                                   }, { 2,-2, 7, 2,-1, 7, 2, 1, 7, 2, 2, 7}, { 2,-1,10, 2, 2, 1                  }} ),
-    new ScrambleStateGraph( new int[][] {{ 0,-2, 8, 0,-1, 8, 0, 1, 8, 0, 2, 8}, { 0, 1,11, 0, 2, 2                  }, {                                   }} ),
-    new ScrambleStateGraph( new int[][] {{ 2,-1,12, 2, 2, 3                  }, {                                   }, { 0,-2, 9, 0,-1, 9, 0, 1, 9, 0, 2, 9}} ),
-    new ScrambleStateGraph( new int[][] {{ 2,-1,13, 2, 1, 4                  }, { 2,-2,10, 2,-1,10, 2, 1,10, 2, 2,10}, { 2,-1, 1, 2, 1, 7                  }} ),
-    new ScrambleStateGraph( new int[][] {{ 0,-2,11, 0,-1,11, 0, 1,11, 0, 2,11}, { 0,-1, 8, 0, 1, 2                  }, { 2,-1,14, 2, 1, 5                  }} ),
-    new ScrambleStateGraph( new int[][] {{ 2,-1, 3, 2, 1, 9                  }, { 0,-1, 6, 0, 1,15                  }, { 0,-2,12, 0,-1,12, 0, 1,12, 0, 2,12}} ),
-    new ScrambleStateGraph( new int[][] {{ 2, 1,10, 2, 2, 4                  }, { 2,-2,13, 2,-1,13, 2, 1,13, 2, 2,13}, {                                   }} ),
-    new ScrambleStateGraph( new int[][] {{ 0,-2,14, 0,-1,14, 0, 1,14, 0, 2,14}, {                                   }, { 2, 1,11, 2, 2, 5                  }} ),
-    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,12, 0, 2, 6                  }, { 0,-2,15, 0,-1,15, 0, 1,15, 0, 2,15}} )
-    };
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
   private static final float[][] POSITIONS = new float[][]
       {
        {-1.0f,  1.0f,  1.0f, -1.0f,  0.0f,  1.0f,  0.0f,  1.0f,  1.0f,  0.0f,  0.0f,  1.0f},
@@ -101,6 +63,26 @@ class TwistyBandaged3Plate extends TwistyBandagedAbstract
                        DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
     {
     super(size, quat, texture, mesh, effects, moves, ObjectList.BAN3, res, scrWidth);
+
+    mStates = new ScrambleStateGraph[]
+    {
+    new ScrambleStateGraph( new int[][] {{ 2,-1, 1, 2, 1, 6                  }, { 0,-1, 5, 0, 1, 3                  }, { 2,-1, 2, 2, 1, 4                  }} ),
+    new ScrambleStateGraph( new int[][] {{ 2, 1, 0                           }, {                                   }, { 2, 1,10, 2, 2, 7                  }} ),
+    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,11, 0, 2, 8                  }, { 2, 1, 0                           }} ),
+    new ScrambleStateGraph( new int[][] {{ 2, 1,12, 2, 2, 9                  }, { 0,-1, 0                           }, {                                   }} ),
+    new ScrambleStateGraph( new int[][] {{ 2,-1,10, 2, 2,13                  }, {                                   }, { 2,-1, 0                           }} ),
+    new ScrambleStateGraph( new int[][] {{                                   }, { 0, 1, 0                           }, { 2,-1,11, 2, 2,14                  }} ),
+    new ScrambleStateGraph( new int[][] {{ 2,-1, 0                           }, { 0, 1,12, 0, 2,15                  }, {                                   }} ),
+    new ScrambleStateGraph( new int[][] {{                                   }, { 2,-2, 7, 2,-1, 7, 2, 1, 7, 2, 2, 7}, { 2,-1,10, 2, 2, 1                  }} ),
+    new ScrambleStateGraph( new int[][] {{ 0,-2, 8, 0,-1, 8, 0, 1, 8, 0, 2, 8}, { 0, 1,11, 0, 2, 2                  }, {                                   }} ),
+    new ScrambleStateGraph( new int[][] {{ 2,-1,12, 2, 2, 3                  }, {                                   }, { 0,-2, 9, 0,-1, 9, 0, 1, 9, 0, 2, 9}} ),
+    new ScrambleStateGraph( new int[][] {{ 2,-1,13, 2, 1, 4                  }, { 2,-2,10, 2,-1,10, 2, 1,10, 2, 2,10}, { 2,-1, 1, 2, 1, 7                  }} ),
+    new ScrambleStateGraph( new int[][] {{ 0,-2,11, 0,-1,11, 0, 1,11, 0, 2,11}, { 0,-1, 8, 0, 1, 2                  }, { 2,-1,14, 2, 1, 5                  }} ),
+    new ScrambleStateGraph( new int[][] {{ 2,-1, 3, 2, 1, 9                  }, { 0,-1, 6, 0, 1,15                  }, { 0,-2,12, 0,-1,12, 0, 1,12, 0, 2,12}} ),
+    new ScrambleStateGraph( new int[][] {{ 2, 1,10, 2, 2, 4                  }, { 2,-2,13, 2,-1,13, 2, 1,13, 2, 2,13}, {                                   }} ),
+    new ScrambleStateGraph( new int[][] {{ 0,-2,14, 0,-1,14, 0, 1,14, 0, 2,14}, {                                   }, { 2, 1,11, 2, 2, 5                  }} ),
+    new ScrambleStateGraph( new int[][] {{                                   }, { 0,-1,12, 0, 2, 6                  }, { 0,-2,15, 0,-1,15, 0, 1,15, 0, 2,15}} )
+    };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -120,28 +102,6 @@ class TwistyBandaged3Plate extends TwistyBandagedAbstract
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 
-  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
-    {
-    if( curr==0 )
-      {
-      mCurrState     = 0;
-      mIndexExcluded =-1;
-      }
-
-    int total = mStates[mCurrState].getTotal(mIndexExcluded);
-    int random= rnd.nextInt(total);
-    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
-
-    scramble[curr][0] = info[0];
-    scramble[curr][1] = info[1];
-    scramble[curr][2] = info[2];
-
-    mCurrState     = info[3];
-    mIndexExcluded = info[0];
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
   public int getObjectName(int numLayers)
     {
     return R.string.bandaged_3plate;
diff --git a/src/main/java/org/distorted/objects/TwistyBandagedAbstract.java b/src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
index 4433b3d7..aec7fa9f 100644
--- a/src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
+++ b/src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
@@ -23,12 +23,15 @@ import android.content.res.Resources;
 
 import org.distorted.helpers.ObjectShape;
 import org.distorted.helpers.ObjectSticker;
+import org.distorted.helpers.ScrambleStateGraph;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshSquare;
 import org.distorted.library.type.Static3D;
 import org.distorted.library.type.Static4D;
 
+import java.util.Random;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 abstract class TwistyBandagedAbstract extends TwistyObject
@@ -148,6 +151,10 @@ abstract class TwistyBandagedAbstract extends TwistyObject
       }
     }
 
+  private int mCurrState;
+  private int mIndexExcluded;
+  ScrambleStateGraph[] mStates;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   TwistyBandagedAbstract(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
@@ -443,6 +450,28 @@ abstract class TwistyBandagedAbstract extends TwistyObject
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 
+  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
+    {
+    if( curr==0 )
+      {
+      mCurrState     = 0;
+      mIndexExcluded =-1;
+      }
+
+    int total = mStates[mCurrState].getTotal(mIndexExcluded);
+    int random= rnd.nextInt(total);
+    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
+
+    scramble[curr][0] = info[0];
+    scramble[curr][1] = info[1];
+    scramble[curr][2] = info[2];
+
+    mCurrState     = info[3];
+    mIndexExcluded = info[0];
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
   public Static3D[] getRotationAxis()
     {
     return ROT_AXIS;
diff --git a/src/main/java/org/distorted/objects/TwistyBandagedEvil.java b/src/main/java/org/distorted/objects/TwistyBandagedEvil.java
index e5708fe3..b03be895 100644
--- a/src/main/java/org/distorted/objects/TwistyBandagedEvil.java
+++ b/src/main/java/org/distorted/objects/TwistyBandagedEvil.java
@@ -34,13 +34,34 @@ import java.util.Random;
 
 class TwistyBandagedEvil extends TwistyBandagedAbstract
 {
-   private int mCurrState;
-   private int mIndexExcluded;
+  private static final float[][] POSITIONS = new float[][]
+      {
+        { 1.0f,  1.0f, -1.0f},
+        {-1.0f, -1.0f,  0.0f, -1.0f,  0.0f,  0.0f, 0.0f, -1.0f,  0.0f,  0.0f,  0.0f,  0.0f},
+        {-1.0f,  1.0f, -1.0f,  0.0f,  1.0f, -1.0f},
+        {-1.0f,  0.0f, -1.0f,  0.0f,  0.0f, -1.0f},
+        {-1.0f, -1.0f, -1.0f,  0.0f, -1.0f, -1.0f},
+        {-1.0f,  1.0f,  0.0f, -1.0f,  1.0f,  1.0f},
+        { 0.0f,  1.0f,  0.0f,  0.0f,  1.0f,  1.0f},
+        { 1.0f,  1.0f,  0.0f,  1.0f,  1.0f,  1.0f},
+        {-1.0f, -1.0f,  1.0f, -1.0f,  0.0f,  1.0f},
+        { 0.0f, -1.0f,  1.0f,  0.0f,  0.0f,  1.0f},
+        { 1.0f, -1.0f,  1.0f,  1.0f,  0.0f,  1.0f},
+        { 1.0f, -1.0f,  0.0f,  1.0f,  0.0f,  0.0f},
+        { 1.0f, -1.0f, -1.0f,  1.0f,  0.0f, -1.0f}
+      };
 
-   // The list of all 'significant' states of the Evil Cube, just like in the 3Plate Cube class.
-   // This time the list got computed automatically - by the ScrambleStateGraphProducer.computeGraph().
+  private static final int[] QUAT_INDICES = new int[]
+      { 0, 1, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 3 };
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  TwistyBandagedEvil(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
+                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
+    {
+    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN4, res, scrWidth);
 
-   private final ScrambleStateGraph[] mStates = new ScrambleStateGraph[]
+    mStates = new ScrambleStateGraph[]
      {
      new ScrambleStateGraph( new int[][] {{2, 1,  1,2,-1,  2}         , {2, 2,142,2,-1, 28}         , {0, 1,114}          }),   //0
      new ScrambleStateGraph( new int[][] {{2, 2,  2}                  , {2,-1,143}                  , {}                  }),
@@ -187,35 +208,6 @@ class TwistyBandagedEvil extends TwistyBandagedAbstract
      new ScrambleStateGraph( new int[][] {{}                          , {2, 1, 28}                  , {2,-1, 18}          }),
      new ScrambleStateGraph( new int[][] {{}                          , {2, 1,  1}                  , {2, 2, 12,2,-1, 13} })
      };
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private static final float[][] POSITIONS = new float[][]
-      {
-        { 1.0f,  1.0f, -1.0f},
-        {-1.0f, -1.0f,  0.0f, -1.0f,  0.0f,  0.0f, 0.0f, -1.0f,  0.0f,  0.0f,  0.0f,  0.0f},
-        {-1.0f,  1.0f, -1.0f,  0.0f,  1.0f, -1.0f},
-        {-1.0f,  0.0f, -1.0f,  0.0f,  0.0f, -1.0f},
-        {-1.0f, -1.0f, -1.0f,  0.0f, -1.0f, -1.0f},
-        {-1.0f,  1.0f,  0.0f, -1.0f,  1.0f,  1.0f},
-        { 0.0f,  1.0f,  0.0f,  0.0f,  1.0f,  1.0f},
-        { 1.0f,  1.0f,  0.0f,  1.0f,  1.0f,  1.0f},
-        {-1.0f, -1.0f,  1.0f, -1.0f,  0.0f,  1.0f},
-        { 0.0f, -1.0f,  1.0f,  0.0f,  0.0f,  1.0f},
-        { 1.0f, -1.0f,  1.0f,  1.0f,  0.0f,  1.0f},
-        { 1.0f, -1.0f,  0.0f,  1.0f,  0.0f,  0.0f},
-        { 1.0f, -1.0f, -1.0f,  1.0f,  0.0f, -1.0f}
-      };
-
-  private static final int[] QUAT_INDICES = new int[]
-      { 0, 1, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 3 };
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  TwistyBandagedEvil(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
-                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
-    {
-    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN4, res, scrWidth);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -235,28 +227,6 @@ class TwistyBandagedEvil extends TwistyBandagedAbstract
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 
-  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
-    {
-    if( curr==0 )
-      {
-      mCurrState     = 0;
-      mIndexExcluded =-1;
-      }
-
-    int total = mStates[mCurrState].getTotal(mIndexExcluded);
-    int random= rnd.nextInt(total);
-    int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded);
-
-    scramble[curr][0] = info[0];
-    scramble[curr][1] = info[1];
-    scramble[curr][2] = info[2];
-
-    mCurrState     = info[3];
-    mIndexExcluded = info[0];
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
   public int getObjectName(int numLayers)
     {
     return R.string.bandaged_evil;
diff --git a/src/main/java/org/distorted/objects/TwistyBandagedFused.java b/src/main/java/org/distorted/objects/TwistyBandagedFused.java
index 1b9d3bbc..ffe23986 100644
--- a/src/main/java/org/distorted/objects/TwistyBandagedFused.java
+++ b/src/main/java/org/distorted/objects/TwistyBandagedFused.java
@@ -21,6 +21,7 @@ package org.distorted.objects;
 
 import android.content.res.Resources;
 
+import org.distorted.helpers.ScrambleStateGraph;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshSquare;
@@ -72,6 +73,16 @@ class TwistyBandagedFused extends TwistyBandagedAbstract
                       DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
     {
     super(size, quat, texture, mesh, effects, moves, ObjectList.BAN1, res, scrWidth);
+
+    mStates = new ScrambleStateGraph[]
+      {
+      new ScrambleStateGraph( new int[][] {
+                                           {0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0},
+                                           {0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0},
+                                           {0,-1,0, 0,1,0, 0,2,0, 2,-1,0, 2,1,0, 2,2,0},
+                                          }
+                            )
+      };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -89,41 +100,7 @@ class TwistyBandagedFused extends TwistyBandagedAbstract
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
-    {
-    if( curr==0 )
-      {
-      scramble[curr][0] = rnd.nextInt(NUM_AXIS);
-      }
-    else
-      {
-      int newVector = rnd.nextInt(NUM_AXIS -1);
-      scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
-      }
-
-    float rowFloat = rnd.nextFloat();
-    int numLayers = getNumLayers();
-
-    for(int row=0; row<numLayers; row++)
-      {
-      if( rowFloat*numLayers <= row+1 )
-        {
-        scramble[curr][1] = row;
-        break;
-        }
-      }
-
-    switch( rnd.nextInt(4) )
-      {
-      case 0: scramble[curr][2] = -2; break;
-      case 1: scramble[curr][2] = -1; break;
-      case 2: scramble[curr][2] =  1; break;
-      case 3: scramble[curr][2] =  2; break;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC APi
 
   public int getObjectName(int numLayers)
     {
