commit 20898e6f25f6f267eb9b1bf38341c745489ad03f
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Aug 30 23:03:23 2021 +0200

    Convert both Dinos to the new, unified scrambling method.

diff --git a/src/main/java/org/distorted/objects/TwistyDino.java b/src/main/java/org/distorted/objects/TwistyDino.java
index 38e4c7ca..b29cd550 100644
--- a/src/main/java/org/distorted/objects/TwistyDino.java
+++ b/src/main/java/org/distorted/objects/TwistyDino.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;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public abstract class TwistyDino extends TwistyObject
@@ -117,6 +120,10 @@ public abstract class TwistyDino extends TwistyObject
     mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
     }
 
+  private int mCurrState;
+  private int mIndexExcluded;
+  ScrambleStateGraph[] mStates;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
@@ -233,6 +240,28 @@ public abstract class TwistyDino 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/TwistyDino4.java b/src/main/java/org/distorted/objects/TwistyDino4.java
index af29b0b4..74bc327e 100644
--- a/src/main/java/org/distorted/objects/TwistyDino4.java
+++ b/src/main/java/org/distorted/objects/TwistyDino4.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;
@@ -41,6 +42,19 @@ public class TwistyDino4 extends TwistyDino
               DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
     {
     super(size, quat, texture, mesh, effects, moves, ObjectList.DIN4, res, scrWidth);
+
+    mStates = new ScrambleStateGraph[]
+      {
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{0,1,5,0,-1,5              },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {                          },{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {                          },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1              },{                          },{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{                          },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{                          },{0,1,7,0,-1,7              } } ),
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{                          },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{                          } } ),
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{                          } } ),
+      };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -71,29 +85,6 @@ public class TwistyDino4 extends TwistyDino
     return true;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
-    {
-    if( curr==0 )
-      {
-      scramble[curr][0] = rnd.nextInt(NUM_AXIS);
-      scramble[curr][1] = (scramble[curr][0]==1 || scramble[curr][0]==2) ? 0:2;
-      }
-    else
-      {
-      int newVector = rnd.nextInt(NUM_AXIS-1);
-      scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
-      scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1];
-      }
-
-    switch( rnd.nextInt(2) )
-      {
-      case 0: scramble[curr][2] = -1; break;
-      case 1: scramble[curr][2] =  1; break;
-      }
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public int getObjectName(int numLayers)
diff --git a/src/main/java/org/distorted/objects/TwistyDino6.java b/src/main/java/org/distorted/objects/TwistyDino6.java
index d84c2221..a8352ab7 100644
--- a/src/main/java/org/distorted/objects/TwistyDino6.java
+++ b/src/main/java/org/distorted/objects/TwistyDino6.java
@@ -21,14 +21,13 @@ 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;
 import org.distorted.library.type.Static4D;
 import org.distorted.main.R;
 
-import java.util.Random;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class TwistyDino6 extends TwistyDino
@@ -43,6 +42,19 @@ public class TwistyDino6 extends TwistyDino
               DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
     {
     super(size, quat, texture, mesh, effects, moves, ObjectList.DINO, res, scrWidth);
+
+    mStates = new ScrambleStateGraph[]
+      {
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1, 2,1,2,2,-1,2},{0,1,3,0,-1,3, 2,1,4,2,-1,4},{0,1,5,0,-1,5, 2,1,6,2,-1,6},{0,1,7,0,-1,7, 2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {                          },{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {                          },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1              },{                          },{              2,1,6,2,-1,6},{0,1,7,0,-1,7              } } ),
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{                          },{0,1,5,0,-1,5,             },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{                          },{0,1,7,0,-1,7              } } ),
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{                          },{              2,1,8,2,-1,8} } ),
+      new ScrambleStateGraph( new int[][] { {              2,1,2,2,-1,2},{0,1,3,0,-1,3              },{0,1,5,0,-1,5,             },{                          } } ),
+      new ScrambleStateGraph( new int[][] { {0,1,1,0,-1,1              },{              2,1,4,2,-1,4},{              2,1,6,2,-1,6},{                          } } ),
+      };
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -101,29 +113,6 @@ public class TwistyDino6 extends TwistyDino
     return false;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
-    {
-    if( curr==0 )
-      {
-      scramble[curr][0] = rnd.nextInt(NUM_AXIS);
-      scramble[curr][1] = rnd.nextFloat()<=0.5f ? 0:2;
-      }
-    else
-      {
-      int newVector = rnd.nextInt(NUM_AXIS-1);
-      scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
-      scramble[curr][1] = scramble[curr-1][0]+scramble[curr][0]==3 ? 2-scramble[curr-1][1] : scramble[curr-1][1];
-      }
-
-    switch( rnd.nextInt(2) )
-      {
-      case 0: scramble[curr][2] = -1; break;
-      case 1: scramble[curr][2] =  1; break;
-      }
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public int getObjectName(int numLayers)
