commit c65092dd1aae2d303374b03fec157e455fca06e1
Author: leszek <leszek@koltunski.pl>
Date:   Sun Dec 22 13:14:59 2024 +0100

    Standarize solver 'validity of position' methods.

diff --git a/src/main/java/org/distorted/solvers/SolverTablebase.java b/src/main/java/org/distorted/solvers/SolverTablebase.java
index 1cba4986..2be5c228 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebase.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebase.java
@@ -11,6 +11,7 @@ package org.distorted.solvers;
 
 import android.content.res.Resources;
 
+import org.distorted.main.R;
 import org.distorted.objectlib.helpers.OperatingSystemInterface;
 import org.distorted.objectlib.main.TwistyObject;
 import org.distorted.objectlib.tablebases.ImplementedTablebasesList;
@@ -21,6 +22,34 @@ import org.distorted.solverui.ScreenSolver;
 
 public abstract class SolverTablebase implements SolvingInterface
 {
+  private static final int[][] colorsHex =
+    {
+      {R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 },
+      {R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7  },
+      {R.string.color_blue1  ,R.string.color_blue2  ,R.string.color_blue3  ,R.string.color_blue4  ,R.string.color_blue5  ,R.string.color_blue6  ,R.string.color_blue7   },
+      {R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7  },
+      {R.string.color_red1   ,R.string.color_red2   ,R.string.color_red3   ,R.string.color_red4   ,R.string.color_red5   ,R.string.color_red6   ,R.string.color_red7    },
+      {R.string.color_orange1,R.string.color_orange2,R.string.color_orange3,R.string.color_orange4,R.string.color_orange5,R.string.color_orange6,R.string.color_orange7 },
+    };
+  private static final int[][] colorsTet =
+    {
+      {R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7  },
+      {R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 },
+      {R.string.color_blue1  ,R.string.color_blue2  ,R.string.color_blue3  ,R.string.color_blue4  ,R.string.color_blue5  ,R.string.color_blue6  ,R.string.color_blue7   },
+      {R.string.color_red1   ,R.string.color_red2   ,R.string.color_red3   ,R.string.color_red4   ,R.string.color_red5   ,R.string.color_red6   ,R.string.color_red7    },
+    };
+  private static final int[][] colorsOct =
+    {
+      {R.string.color_violet1,R.string.color_violet2,R.string.color_violet3,R.string.color_violet4,R.string.color_violet5,R.string.color_violet6,R.string.color_violet7 },
+      {R.string.color_grey1  ,R.string.color_grey2  ,R.string.color_grey3  ,R.string.color_grey4  ,R.string.color_grey5  ,R.string.color_grey6  ,R.string.color_grey7   },
+      {R.string.color_blue1  ,R.string.color_blue2  ,R.string.color_blue3  ,R.string.color_blue4  ,R.string.color_blue5  ,R.string.color_blue6  ,R.string.color_blue7   },
+      {R.string.color_red1   ,R.string.color_red2   ,R.string.color_red3   ,R.string.color_red4   ,R.string.color_red5   ,R.string.color_red6   ,R.string.color_red7    },
+      {R.string.color_orange1,R.string.color_orange2,R.string.color_orange3,R.string.color_orange4,R.string.color_orange5,R.string.color_orange6,R.string.color_orange7 },
+      {R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7  },
+      {R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7  },
+      {R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 },
+    };
+
   private final OperatingSystemInterface mOS;
   private final Resources mRes;
   private final TwistyObject mObject;
@@ -44,6 +73,9 @@ public abstract class SolverTablebase implements SolvingInterface
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
+  int getHexColor(int color,int variant) { return colorsHex[color][variant]; }
+  int getTetColor(int color,int variant) { return colorsTet[color][variant]; }
+  int getOctColor(int color,int variant) { return colorsOct[color][variant]; }
   int[] getExtra() { return null; }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseCU232.java b/src/main/java/org/distorted/solvers/SolverTablebaseCU232.java
index 061877c9..6a80d22a 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseCU232.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseCU232.java
@@ -292,63 +292,12 @@ public class SolverTablebaseCU232 extends SolverTablebase
     return edge_perm_num + 6*corner_perm_num;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow4;
-      case 1: return R.string.color_white4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_green4;
-      case 4: return R.string.color_red4;
-      case 5: return R.string.color_orange4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow3;
-      case 1: return R.string.color_white3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_green3;
-      case 4: return R.string.color_red3;
-      case 5: return R.string.color_orange3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex6(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow6;
-      case 1: return R.string.color_white6;
-      case 2: return R.string.color_blue6;
-      case 3: return R.string.color_green6;
-      case 4: return R.string.color_red6;
-      case 5: return R.string.color_orange6;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String edgeError(Resources res, int face0, int face1)
     {
-    int j0 = getColorIndex3(face0);
-    int j1 = getColorIndex6(face1);
+    int j0 = getHexColor(face0,3);
+    int j1 = getHexColor(face1,6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -360,9 +309,9 @@ public class SolverTablebaseCU232 extends SolverTablebase
 
   private String cornerError(Resources res, int face0, int face1, int face2)
     {
-    int j0 = getColorIndex3(face0);
-    int j1 = getColorIndex3(face1);
-    int j2 = getColorIndex4(face2);
+    int j0 = getHexColor(face0,3);
+    int j1 = getHexColor(face1,3);
+    int j2 = getHexColor(face2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseCU323.java b/src/main/java/org/distorted/solvers/SolverTablebaseCU323.java
index 105780e1..d4f8732f 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseCU323.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseCU323.java
@@ -295,80 +295,12 @@ public class SolverTablebaseCU323 extends SolverTablebase
     return corner_perm_num + 40320*( centersInPlace + 2*edge_perm_num);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_yellow4;
-      case 1: return R.string.color_white4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_green4;
-      case 4: return R.string.color_red4;
-      case 5: return R.string.color_orange4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_yellow3;
-      case 1: return R.string.color_white3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_green3;
-      case 4: return R.string.color_red3;
-      case 5: return R.string.color_orange3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex5(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_yellow5;
-      case 1: return R.string.color_white5;
-      case 2: return R.string.color_blue5;
-      case 3: return R.string.color_green5;
-      case 4: return R.string.color_red5;
-      case 5: return R.string.color_orange5;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex6(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_yellow6;
-      case 1: return R.string.color_white6;
-      case 2: return R.string.color_blue6;
-      case 3: return R.string.color_green6;
-      case 4: return R.string.color_red6;
-      case 5: return R.string.color_orange6;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String edgeTwistedError(Resources res, int color0, int color1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -380,9 +312,9 @@ public class SolverTablebaseCU323 extends SolverTablebase
 
   private String cornerTwistedError(Resources res, int color0, int color1, int color2)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex3(color1);
-    int j2 = getColorIndex5(color2);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,3);
+    int j2 = getHexColor(color2,5);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -395,8 +327,8 @@ public class SolverTablebaseCU323 extends SolverTablebase
 
   private String edgeMissingError(Resources res, int color0, int color1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -408,9 +340,9 @@ public class SolverTablebaseCU323 extends SolverTablebase
 
   private String cornerMissingError(Resources res, int color0, int color1, int color2)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex3(color1);
-    int j2 = getColorIndex4(color2);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,3);
+    int j2 = getHexColor(color2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseCUBE2.java b/src/main/java/org/distorted/solvers/SolverTablebaseCUBE2.java
index d32cd1b2..3bee0086 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseCUBE2.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseCUBE2.java
@@ -208,47 +208,13 @@ public class SolverTablebaseCUBE2 extends SolverTablebase
     return twistNum + 729*permNum;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow4;
-      case 1: return R.string.color_white4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_green4;
-      case 4: return R.string.color_red4;
-      case 5: return R.string.color_orange4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow3;
-      case 1: return R.string.color_white3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_green3;
-      case 4: return R.string.color_red3;
-      case 5: return R.string.color_orange3;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String cornerError(Resources res, int face0, int face1, int face2)
     {
-    int j0 = getColorIndex3(face0);
-    int j1 = getColorIndex3(face1);
-    int j2 = getColorIndex4(face2);
+    int j0 = getHexColor(face0,3);
+    int j1 = getHexColor(face1,3);
+    int j2 = getHexColor(face2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseDIAM2.java b/src/main/java/org/distorted/solvers/SolverTablebaseDIAM2.java
index bc025ab3..11017df3 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseDIAM2.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseDIAM2.java
@@ -387,68 +387,12 @@ android.util.Log.e("D", "corn twist: "+corners_twist[0]+" "+corners_twist[1]+" "
     return centers_perm_num + 12*(totalTwist + 32*corners_perm_num);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_violet4;
-      case 1: return R.string.color_grey4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_red4;
-      case 4: return R.string.color_orange4;
-      case 5: return R.string.color_green4;
-      case 6: return R.string.color_white4;
-      case 7: return R.string.color_yellow4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_violet3;
-      case 1: return R.string.color_grey3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_red3;
-      case 4: return R.string.color_orange3;
-      case 5: return R.string.color_green3;
-      case 6: return R.string.color_white3;
-      case 7: return R.string.color_yellow3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex2(int face)
-    {
-    switch(face)
-      {
-      case 0: return R.string.color_violet2;
-      case 1: return R.string.color_grey2;
-      case 2: return R.string.color_blue2;
-      case 3: return R.string.color_red2;
-      case 4: return R.string.color_orange2;
-      case 5: return R.string.color_green2;
-      case 6: return R.string.color_white2;
-      case 7: return R.string.color_yellow2;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String centerError(Resources res, int face)
     {
-    String color = res.getString(getColorIndex2(face));
+    int index = getOctColor(face,2);
+    String color = res.getString(index);
     return res.getString(R.string.solver_generic_missing_center,color);
     }
 
@@ -456,8 +400,10 @@ android.util.Log.e("D", "corn twist: "+corners_twist[0]+" "+corners_twist[1]+" "
 
   private String cornerError(Resources res, int f1, int f2)
     {
-    String c1 = res.getString(getColorIndex3(f1));
-    String c2 = res.getString(getColorIndex4(f2));
+    int i1 = getOctColor(f1,3);
+    int i2 = getOctColor(f2,4);
+    String c1 = res.getString(i1);
+    String c2 = res.getString(i2);
     return res.getString(R.string.solver_generic_missing_corner2,c1,c2);
     }
 
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseDINO6.java b/src/main/java/org/distorted/solvers/SolverTablebaseDINO6.java
index c60cf3b4..c6a134af 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseDINO6.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseDINO6.java
@@ -331,46 +331,12 @@ public class SolverTablebaseDINO6 extends SolverTablebase
     return TBDino6.getIndexFromPerm(perm);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_yellow3;
-      case 1: return R.string.color_white3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_green3;
-      case 4: return R.string.color_red3;
-      case 5: return R.string.color_orange3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex6(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_yellow6;
-      case 1: return R.string.color_white6;
-      case 2: return R.string.color_blue6;
-      case 3: return R.string.color_green6;
-      case 4: return R.string.color_red6;
-      case 5: return R.string.color_orange6;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String edgeMissingError(Resources res, int color0, int color1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -382,8 +348,8 @@ public class SolverTablebaseDINO6 extends SolverTablebase
 
   private String edgeTwistedError(Resources res, int color0, int color1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -395,8 +361,8 @@ public class SolverTablebaseDINO6 extends SolverTablebase
 
   private String edgeMonoError(Resources res, int color)
     {
-    int j0 = getColorIndex3(color);
-    int j1 = getColorIndex6(color);
+    int j0 = getHexColor(color,3);
+    int j1 = getHexColor(color,6);
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
 
@@ -407,8 +373,8 @@ public class SolverTablebaseDINO6 extends SolverTablebase
 
   private String edgeTwiceError(Resources res, int color0, int color1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getHexColor(color0,3);
+    int j1 = getHexColor(color1,6);
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
 
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseJING2.java b/src/main/java/org/distorted/solvers/SolverTablebaseJING2.java
index 8c2f4bfa..d8681b15 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseJING2.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseJING2.java
@@ -395,73 +395,13 @@ public class SolverTablebaseJING2 extends SolverTablebase
     return green_face + 4*(vertexTwist + 81*(edgeTwist + 32*perm_num));
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_green3;
-      case 1: return R.string.color_yellow3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_red3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_green4;
-      case 1: return R.string.color_yellow4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_red4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getFaceIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_green3;
-      case 1: return R.string.color_yellow3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_red3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getFaceIndex6(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_green6;
-      case 1: return R.string.color_yellow6;
-      case 2: return R.string.color_blue6;
-      case 3: return R.string.color_red6;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String cornerError(Resources res, int color0, int color1, int color2)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex3(color1);
-    int j2 = getColorIndex4(color2);
+    int j0 = getTetColor(color0,3);
+    int j1 = getTetColor(color1,3);
+    int j2 = getTetColor(color2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -474,8 +414,8 @@ public class SolverTablebaseJING2 extends SolverTablebase
 
   private String edgeError(Resources res, int face0, int face1)
     {
-    int j0 = getFaceIndex3(face0);
-    int j1 = getFaceIndex6(face1);
+    int j0 = getTetColor(mFaceColors[face0],3);
+    int j1 = getTetColor(mFaceColors[face1],6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
diff --git a/src/main/java/org/distorted/solvers/SolverTablebasePDIA3.java b/src/main/java/org/distorted/solvers/SolverTablebasePDIA3.java
index 215840f5..4605e0aa 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebasePDIA3.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebasePDIA3.java
@@ -253,68 +253,12 @@ android.util.Log.e("D", "ret="+(total_twist + 2048*centers_perm_num) );
     return total_twist + 2048*centers_perm_num;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_violet4;
-      case 1: return R.string.color_grey4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_red4;
-      case 4: return R.string.color_orange4;
-      case 5: return R.string.color_green4;
-      case 6: return R.string.color_white4;
-      case 7: return R.string.color_yellow4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_violet3;
-      case 1: return R.string.color_grey3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_red3;
-      case 4: return R.string.color_orange3;
-      case 5: return R.string.color_green3;
-      case 6: return R.string.color_white3;
-      case 7: return R.string.color_yellow3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex2(int face)
-    {
-    switch(face)
-      {
-      case 0: return R.string.color_violet2;
-      case 1: return R.string.color_grey2;
-      case 2: return R.string.color_blue2;
-      case 3: return R.string.color_red2;
-      case 4: return R.string.color_orange2;
-      case 5: return R.string.color_green2;
-      case 6: return R.string.color_white2;
-      case 7: return R.string.color_yellow2;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String centerError(Resources res, int face)
     {
-    String color = res.getString(getColorIndex2(face));
+    int index = getOctColor(face,2);
+    String color = res.getString(index);
     return res.getString(R.string.solver_generic_missing_center,color);
     }
 
@@ -322,8 +266,10 @@ android.util.Log.e("D", "ret="+(total_twist + 2048*centers_perm_num) );
 
   private String cornerError(Resources res, int f1, int f2)
     {
-    String c1 = res.getString(getColorIndex3(f1));
-    String c2 = res.getString(getColorIndex4(f2));
+    int i1 = getOctColor(f1,3);
+    int i2 = getOctColor(f2,4);
+    String c1 = res.getString(i1);
+    String c2 = res.getString(i2);
     return res.getString(R.string.solver_generic_missing_corner2,c1,c2);
     }
 
diff --git a/src/main/java/org/distorted/solvers/SolverTablebasePYRA3.java b/src/main/java/org/distorted/solvers/SolverTablebasePYRA3.java
index 1b783d86..31600bc6 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebasePYRA3.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebasePYRA3.java
@@ -397,73 +397,13 @@ public class SolverTablebasePYRA3 extends SolverTablebase
     return vertexTwist + 81*(edgeTwist + 32*perm_num);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_green3;
-      case 1: return R.string.color_yellow3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_red3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int color)
-    {
-    switch(color)
-      {
-      case 0: return R.string.color_green4;
-      case 1: return R.string.color_yellow4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_red4;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getFaceIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_green3;
-      case 1: return R.string.color_yellow3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_red3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getFaceIndex6(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_green6;
-      case 1: return R.string.color_yellow6;
-      case 2: return R.string.color_blue6;
-      case 3: return R.string.color_red6;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String cornerError(Resources res, int color0, int color1, int color2)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex3(color1);
-    int j2 = getColorIndex4(color2);
+    int j0 = getTetColor(color0,3);
+    int j1 = getTetColor(color1,3);
+    int j2 = getTetColor(color2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -476,9 +416,9 @@ public class SolverTablebasePYRA3 extends SolverTablebase
 
   private String vertexError(Resources res, int color0, int color1, int color2)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex3(color1);
-    int j2 = getColorIndex4(color2);
+    int j0 = getTetColor(color0,3);
+    int j1 = getTetColor(color1,3);
+    int j2 = getTetColor(color2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -491,8 +431,8 @@ public class SolverTablebasePYRA3 extends SolverTablebase
 
   private String edgeError(Resources res, int color0, int color1)
     {
-    int j0 = getFaceIndex3(color0);
-    int j1 = getFaceIndex6(color1);
+    int j0 = getTetColor(mFaceColors[color0],3);
+    int j1 = getTetColor(mFaceColors[color1],6);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
diff --git a/src/main/java/org/distorted/solvers/SolverTablebaseSKEW2.java b/src/main/java/org/distorted/solvers/SolverTablebaseSKEW2.java
index 7139b165..1b64ed50 100644
--- a/src/main/java/org/distorted/solvers/SolverTablebaseSKEW2.java
+++ b/src/main/java/org/distorted/solvers/SolverTablebaseSKEW2.java
@@ -323,64 +323,13 @@ public class SolverTablebaseSKEW2 extends SolverTablebase
     return center_perm_num+ 360*(totalTwist + 2187*freeLoc[0]);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex2(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow2;
-      case 1: return R.string.color_white2;
-      case 2: return R.string.color_blue2;
-      case 3: return R.string.color_green2;
-      case 4: return R.string.color_red2;
-      case 5: return R.string.color_orange2;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex3(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow3;
-      case 1: return R.string.color_white3;
-      case 2: return R.string.color_blue3;
-      case 3: return R.string.color_green3;
-      case 4: return R.string.color_red3;
-      case 5: return R.string.color_orange3;
-      }
-
-    return -1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int getColorIndex4(int face)
-    {
-    switch(mFaceColors[face])
-      {
-      case 0: return R.string.color_yellow4;
-      case 1: return R.string.color_white4;
-      case 2: return R.string.color_blue4;
-      case 3: return R.string.color_green4;
-      case 4: return R.string.color_red4;
-      case 5: return R.string.color_orange4;
-      }
-
-    return -1;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private String cornerError(Resources res, int face0, int face1, int face2)
     {
-    int j0 = getColorIndex3(face0);
-    int j1 = getColorIndex3(face1);
-    int j2 = getColorIndex4(face2);
+    int j0 = getHexColor(face0,3);
+    int j1 = getHexColor(face1,3);
+    int j2 = getHexColor(face2,4);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -393,7 +342,7 @@ public class SolverTablebaseSKEW2 extends SolverTablebase
 
   private String centerError(Resources res, int face)
     {
-    int color = getColorIndex2(face);
+    int color = getHexColor(face,2);
     String clr= res.getString(color);
     return res.getString(R.string.solver_generic_missing_center,clr);
     }
diff --git a/src/main/java/org/distorted/solvers/SolvingInterface.java b/src/main/java/org/distorted/solvers/SolvingInterface.java
index 71034ba5..75b04b9e 100644
--- a/src/main/java/org/distorted/solvers/SolvingInterface.java
+++ b/src/main/java/org/distorted/solvers/SolvingInterface.java
@@ -15,5 +15,5 @@ import org.distorted.solverui.ScreenSolver;
 
 public interface SolvingInterface
 {
-  public void solve(ScreenSolver screen);
+  void solve(ScreenSolver screen);
 }
