commit 713af0c5033952e22aad9d186185a8926c1da434
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Mar 20 10:45:06 2023 +0100

    Jing Solver: correct detection of missing edge colors.

diff --git a/src/main/java/org/distorted/solvers/SolverJing.java b/src/main/java/org/distorted/solvers/SolverJing.java
index 8c86cf60..2a4f4b2f 100644
--- a/src/main/java/org/distorted/solvers/SolverJing.java
+++ b/src/main/java/org/distorted/solvers/SolverJing.java
@@ -47,6 +47,7 @@ public class SolverJing extends SolverTablebase
   private static final int ERROR_TWO_CENTERS        = -19;
 
   private TablebasesAbstract mSolver;
+  private int[] mFaceColors;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -349,8 +350,8 @@ public class SolverJing extends SolverTablebase
     int result1 = checkAllCornersPresent(corners);
     if( result1<0 ) return result1;
 
-    int[] faces = computeFaceColors(corners);
-    int[][] edgeColors = computeEdgeColors(faces);
+    mFaceColors = computeFaceColors(corners);
+    int[][] edgeColors = computeEdgeColors(mFaceColors);
 
     getEdges(object,edges);
     int result2 = checkAllEdgesPresent(edges,edgeColors);
@@ -362,7 +363,7 @@ public class SolverJing extends SolverTablebase
 
     for(int i=0; i<4; i++)
       {
-      corner_twist[i] = computePieceTwist(i,corners[i],faces);
+      corner_twist[i] = computePieceTwist(i,corners[i],mFaceColors);
       if( corner_twist[i]<0 ) return ERROR_CORNERS_CANNOT;
       }
 
@@ -373,13 +374,9 @@ public class SolverJing extends SolverTablebase
     if( !even ) return ERROR_TWO_EDGES;
     int[] edge_twist = new int[6];
     TBPyraminx.getEdgeTwist(edge_twist,quats,0);
-/*
-for(int i=0; i<4; i++) android.util.Log.e("D", "cornerTwist "+i+" : "+corner_twist[i]);
-for(int i=0; i<6; i++) android.util.Log.e("D", "edgeTwist "+i+" : "+edge_twist[i]);
-for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[i]);
-*/
-    int twist_gr = computeCenterTwist(centers,faces[1],faces[2]);
-    int twist_ry = computeCenterTwist(centers,faces[2],faces[0]);
+
+    int twist_gr = computeCenterTwist(centers,mFaceColors[1],mFaceColors[2]);
+    int twist_ry = computeCenterTwist(centers,mFaceColors[2],mFaceColors[0]);
 
     if( (twist_ry-twist_gr+1)%3 != 0 ) return ERROR_TWO_CENTERS;
 
@@ -388,7 +385,7 @@ for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[
 
     if( (total_twist-twist_gr)%3 !=0 ) return ERROR_CORNER_TWISTED;
 
-    int green_face = getFaceOfCenter(faces[1],centers);
+    int green_face = getFaceOfCenter(mFaceColors[1],centers);
 
     int totalEdgeTwist=0;
     for(int i=0; i<6; i++) totalEdgeTwist += edge_twist[i];
@@ -398,8 +395,6 @@ for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[
     int edgeTwist = edge_twist[0]+ 2*(edge_twist[1]+ 2*(edge_twist[2]+ 2*(edge_twist[3]+ 2*edge_twist[4])));
     int perm_num = TablebaseHelpers.computeEvenPermutationNum(permutation);
 
-//android.util.Log.e("D", "ret: green_face="+green_face+" vertTwist="+vertexTwist+" edgeTwist="+edgeTwist+" perm: "+perm_num);
-
     return green_face + 4*(vertexTwist + 81*(edgeTwist + 32*perm_num));
     }
 
@@ -435,9 +430,24 @@ for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private int getColorIndex6(int color)
+  private int getFaceIndex3(int face)
     {
-    switch(color)
+    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;
@@ -465,10 +475,10 @@ for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private String edgeError(Resources res, int color0, int color1)
+  private String edgeError(Resources res, int face0, int face1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getFaceIndex3(face0);
+    int j1 = getFaceIndex6(face1);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -487,10 +497,10 @@ for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[
       case ERROR_CORNER_GYR_MISSING: return cornerError(res,3,1,0);
       case ERROR_CORNER_GYB_MISSING: return cornerError(res,2,1,0);
       case ERROR_EDGE_RB_MISSING   : return edgeError(res,3,2);
-      case ERROR_EDGE_RY_MISSING   : return edgeError(res,3,1);
-      case ERROR_EDGE_RG_MISSING   : return edgeError(res,3,0);
-      case ERROR_EDGE_YB_MISSING   : return edgeError(res,2,1);
-      case ERROR_EDGE_GB_MISSING   : return edgeError(res,2,0);
+      case ERROR_EDGE_RY_MISSING   : return edgeError(res,2,0);
+      case ERROR_EDGE_RG_MISSING   : return edgeError(res,2,1);
+      case ERROR_EDGE_YB_MISSING   : return edgeError(res,3,0);
+      case ERROR_EDGE_GB_MISSING   : return edgeError(res,3,1);
       case ERROR_EDGE_GY_MISSING   : return edgeError(res,1,0);
       case ERROR_CENTER_G_MISSING  : String colorG = res.getString(R.string.color_green2);
                                      return res.getString(R.string.solver_generic_missing_center,colorG);
