commit 8e6dc2490073f8b4f9ac867481e397884379a28f
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Jun 17 13:51:24 2021 +0200

    Correct rotations of the Cube - eliminate one cse when four consecutive rotations collapse into one or a NOP.

diff --git a/src/main/java/org/distorted/objects/TwistyCube.java b/src/main/java/org/distorted/objects/TwistyCube.java
index 805e9aac..184ba1e4 100644
--- a/src/main/java/org/distorted/objects/TwistyCube.java
+++ b/src/main/java/org/distorted/objects/TwistyCube.java
@@ -307,8 +307,24 @@ class TwistyCube extends TwistyObject
       }
     else
       {
-      int newVector = rnd.nextInt(NUM_AXIS -1);
+      int newVector = rnd.nextInt(NUM_AXIS-1);
       scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector);
+
+      // All three axis must be present among every four consecutive rotations.
+      // Otherwise in case of odd-sized cubes we can get four consecutive rotations
+      // that collapse to a NOP
+      // (X,midLayer,180)->(Y,midLayer,180)->(X,midLayer,180)->(Y,midLayer,180) = NOP
+      if( curr>=3 && scramble[curr-1][0]==scramble[curr-3][0] )
+        {
+        for( int ax=0; ax<NUM_AXIS; ax++)
+          {
+          if( scramble[curr-1][0]!=ax && scramble[curr-2][0]!=ax )
+            {
+            scramble[curr][0] = ax;
+            break;
+            }
+          }
+        }
       }
 
     float rowFloat = rnd.nextFloat();
