commit f171c91ebdb75fb994254707ca28c1e5df24c965
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sat Jun 5 01:11:52 2021 +0200

    Square-1: progress with automatic scrambling.

diff --git a/.gitignore b/.gitignore
index b72757aa..c7d5ecce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,4 @@ Thumbs.db
 # yes, ignore the .iml
 *.iml
 /google-services.json
+/release/output-metadata.json
diff --git a/src/main/java/org/distorted/objects/TwistySquare1.java b/src/main/java/org/distorted/objects/TwistySquare1.java
index 192f9aa5..45fbedad 100644
--- a/src/main/java/org/distorted/objects/TwistySquare1.java
+++ b/src/main/java/org/distorted/objects/TwistySquare1.java
@@ -227,6 +227,48 @@ class TwistySquare1 extends TwistyObject
       { 3, 0, 4, 1, 0, 0 },
     };
 
+  // quat indices that make corner cubits bandage the puzzle.
+  private static final int[][] BAD_CORNER_QUATS = new int[][]
+    {
+      { 2, 8,17,23},
+      { 5,11,14,20},
+      { 8, 2,23,17},
+      {11, 5,20,14},
+      {17,23, 2, 8},
+      {14,20, 5,11},
+      {23,17, 8, 2},
+      {20,14,11, 5}
+    };
+
+  // QUAT[i]*QUAT[j] = QUAT_MULT[i][j]
+  private static final int[][] QUAT_MULT = 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 static MeshBase[] mMeshes;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/res/raw/compute_quats.c b/src/main/res/raw/compute_quats.c
index 743e4f89..1f590acc 100644
--- a/src/main/res/raw/compute_quats.c
+++ b/src/main/res/raw/compute_quats.c
@@ -136,25 +136,32 @@ int is_the_same(float* q1, float* q2)
 
 ///////////////////////////////////////////////////////////////////
 
-void insert(float* quat, float* to)
+int getIndexInTable(float* quat, float* table)
   {
   for(int i=0; i<inserted; i++)
     {
-    if( is_the_same(quat,to+4*i)==1 ) return;
+    if( is_the_same(quat,table+4*i)==1 ) return i;
     }
 
-  if( inserted<NUM_QUATS )
-    {
-    to[4*inserted+0] = quat[0];
-    to[4*inserted+1] = quat[1];
-    to[4*inserted+2] = quat[2];
-    to[4*inserted+3] = quat[3];
+  return -1;
+  }
 
-    inserted++;
-    }
-  else
+///////////////////////////////////////////////////////////////////
+
+void insert(float* quat, float* table)
+  {
+  if( getIndexInTable(quat,table)<0 )
     {
-    printf("Error: inserted=%d\n", inserted);
+    if( inserted<NUM_QUATS )
+      {
+      table[4*inserted+0] = quat[0];
+      table[4*inserted+1] = quat[1];
+      table[4*inserted+2] = quat[2];
+      table[4*inserted+3] = quat[3];
+
+      inserted++;
+      }
+    else printf("Error: inserted=%d\n", inserted);
     }
   }
 
@@ -207,10 +214,27 @@ int main(int argc, char** argv)
     }
   while( num < inserted );
 
+  printf("\n");
+
   for(int i=0; i<inserted; i++)
     {
     printf( "%2d %7.4f %7.4f %7.4f %7.4f\n", i, table[4*i], table[4*i+1], table[4*i+2], table[4*i+3] );
     }
 
+  printf("\n");
+
+  for(int i=0; i<inserted; i++)
+    {
+    printf("{");
+
+    for(int j=0; j<inserted; j++)
+      {
+      multiply_quats( table+4*i, table+4*j, tmp);
+      num = getIndexInTable(tmp,table);
+      printf("%3d," , num);
+      }
+    printf("},\n");
+    }
+ 
 return 0;
 }
