commit bc6b4c0b73d5926db65819f87b44368ffe2d8d15
Author: leszek <leszek@koltunski.pl>
Date:   Tue Sep 19 12:50:38 2023 +0200

    fix for scrambling

diff --git a/src/main/java/org/distorted/objectlib/helpers/ObjectSignature.java b/src/main/java/org/distorted/objectlib/helpers/ObjectSignature.java
index a12013b6..c2b85e03 100644
--- a/src/main/java/org/distorted/objectlib/helpers/ObjectSignature.java
+++ b/src/main/java/org/distorted/objectlib/helpers/ObjectSignature.java
@@ -456,14 +456,14 @@ public class ObjectSignature implements Comparable<ObjectSignature>
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public ObjectSignature turn(int axis, int layer, int turn)
+  public ObjectSignature turn(int ax, int layer, int turn)
     {
     ObjectSignature ret = new ObjectSignature(this);
 
     // I don't understand it, but Firebase shows mCycles is occasionally null here.
-    if( mCycles!=null && mCycles[axis]!=null )
+    if( mCycles!=null && mCycles[ax]!=null )
       {
-      int[][] cycles = mCycles[axis][layer];
+      int[][] cycles = mCycles[ax][layer];
 
       // it can happen that there are no cycles in this layer: 2x1x2 axis 0 layer 0.
       if( cycles!=null && cycles.length>0 && cycles[0]!=null )
@@ -996,7 +996,7 @@ public class ObjectSignature implements Comparable<ObjectSignature>
 
   private float[] getPosition(int index, float[][][] centers, int len)
     {
-    int num = 0, i1=0, i2=0;
+    int num=0, i1=0, i2=0;
 
     for(int i=0; i<len; i++)
       {
@@ -1038,19 +1038,18 @@ public class ObjectSignature implements Comparable<ObjectSignature>
     int numVariants = centers.length;
     for(float[][] center : centers) numCubits += center.length;
 
-    ArrayList<float[]> mTouch = new ArrayList<>();
+    ArrayList<float[]> touch = new ArrayList<>();
 
     for(int i=0; i<numCubits; i++)
       {
       float[] first = getPosition(i,centers,numVariants);
+      float ox = scale*first[0];
+      float oy = scale*first[1];
+      float oz = scale*first[2];
 
       for(int j = i+1; j<numCubits; j++)
         {
         float[] second = getPosition(j,centers,numVariants);
-
-        float ox = scale*first[0];
-        float oy = scale*first[1];
-        float oz = scale*first[2];
         float tx = scale*second[0];
         float ty = scale*second[1];
         float tz = scale*second[2];
@@ -1061,15 +1060,15 @@ public class ObjectSignature implements Comparable<ObjectSignature>
           float yc = (ty+oy)/2;
           float zc = (tz+oz)/2;
 
-          float[] touch = new float[] {xc, yc, zc};
-          mTouch.add(touch);
+          float[] t = new float[] {xc, yc, zc};
+          touch.add(t);
           }
         }
       }
 
-    mNumCubitTouches = mTouch.size();
+    mNumCubitTouches = touch.size();
     mCubitTouch = new float[mNumCubitTouches][];
-    for(int i=0; i<mNumCubitTouches; i++) mCubitTouch[i] = mTouch.remove(0);
+    for(int i=0; i<mNumCubitTouches; i++) mCubitTouch[i] = touch.remove(0);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectControl.java b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
index f41a156a..b0fef488 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectControl.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
@@ -15,7 +15,7 @@ import org.distorted.library.helpers.QuatHelper;
 import org.distorted.library.type.Static4D;
 
 import org.distorted.objectlib.effects.BaseEffect;
-import org.distorted.objectlib.helpers.BlockController;
+//import org.distorted.objectlib.helpers.BlockController;
 import org.distorted.objectlib.helpers.MovesFinished;
 import org.distorted.objectlib.helpers.ObjectLibInterface;
 import org.distorted.objectlib.helpers.OperatingSystemInterface;
diff --git a/src/main/java/org/distorted/objectlib/scrambling/ScrambleStateLocallyBandaged.java b/src/main/java/org/distorted/objectlib/scrambling/ScrambleStateLocallyBandaged.java
index 44ce103b..9b8afe3b 100644
--- a/src/main/java/org/distorted/objectlib/scrambling/ScrambleStateLocallyBandaged.java
+++ b/src/main/java/org/distorted/objectlib/scrambling/ScrambleStateLocallyBandaged.java
@@ -230,14 +230,10 @@ public class ScrambleStateLocallyBandaged
     ObjectSignature[] ret = new ObjectSignature[mNumMoves];
     int index = 0;
 
-    String s = mSignature.getString();
-    android.util.Log.e("D", "signature: "+s);
-
     for(int axis=0; axis<mNumAxis; axis++)
       for(int layer=0; layer<mLayer[axis]; layer++)
         {
         mIsUnblocked[axis][layer] = mSignature.isUnblockedFromLeft(axis,layer);
-        android.util.Log.e("D", "unblocked ax "+axis+" layer "+layer+" : "+mIsUnblocked[axis][layer]);
         }
 
     for(int axis=0; axis<mNumAxis; axis++)
@@ -287,24 +283,33 @@ public class ScrambleStateLocallyBandaged
         scramble[0] = axis;
         scramble[1] = moveIndex % mSize[axis];
 
-        if( mTurns[axis]==3 )
-          {
-          switch(moveIndex/mSize[axis])
-            {
-            case 0: scramble[2] =-1; break;
-            case 1: scramble[2] = 2; break;
-            case 2: scramble[2] = 1; break;
-            }
-          }
-        else if( mTurns[axis]==2 )
+        switch( mTurns[axis] )
           {
-          switch(moveIndex/mSize[axis])
-            {
-            case 0: scramble[2] =-1; break;
-            case 1: scramble[2] = 1; break;
-            }
+          case 2: switch(moveIndex/mSize[axis])
+                    {
+                    case 0: scramble[2] =-1; break;
+                    case 1: scramble[2] = 1; break;
+                    }
+                  break;
+          case 3: switch(moveIndex/mSize[axis])
+                    {
+                    case 0: scramble[2] =-1; break;
+                    case 1: scramble[2] = 2; break;
+                    case 2: scramble[2] = 1; break;
+                    }
+                  break;
+          case 4: switch(moveIndex/mSize[axis])
+                    {
+                    case 0: scramble[2] =-1; break;
+                    case 1: scramble[2] =-2; break;
+                    case 2: scramble[2] = 2; break;
+                    case 3: scramble[2] = 1; break;
+                    }
+                  break;
+          default:scramble[2] = 1;
+                  android.util.Log.e("D", "ScrambleStateLocallyBandaged: unsupported turns: "+mTurns[axis]);
           }
-        else scramble[2] = 1;
+
         return;
         }
 
