commit 0c2d3013ebdc5451022f3c032f659f8e8ad80689
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Mar 20 10:40:13 2023 +0100

    Pyraminx Solver: correct detection of missing edge colors.

diff --git a/src/main/java/org/distorted/solvers/SolverPyraminx.java b/src/main/java/org/distorted/solvers/SolverPyraminx.java
index 019077f1..20f83305 100644
--- a/src/main/java/org/distorted/solvers/SolverPyraminx.java
+++ b/src/main/java/org/distorted/solvers/SolverPyraminx.java
@@ -48,6 +48,7 @@ public class SolverPyraminx extends SolverTablebase
 
   private TablebasesAbstract mSolver;
   private int[] mCornerTwist;
+  private int[] mFaceColors;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -354,13 +355,15 @@ public class SolverPyraminx extends SolverTablebase
     int result2 = checkAllVerticesPresent(vertices);
     if( result2<0 ) return result2;
 
-    int[] faces1 = computeFaceColors(corners);
-    int[] faces2 = computeFaceColors(vertices);
+    int[] facesC = computeFaceColors(corners);
+    int[] facesV = computeFaceColors(vertices);
 
-    int result3 = checkAgreement(faces1,faces2);
+    int result3 = checkAgreement(facesC,facesV);
     if( result3<0 ) return result3;
 
-    int[][] edgeColors = computeEdgeColors(faces1);
+    mFaceColors = facesC;
+
+    int[][] edgeColors = computeEdgeColors(mFaceColors);
 
     getEdges(object,edges);
     int result4 = checkAllEdgesPresent(edges,edgeColors);
@@ -368,13 +371,13 @@ public class SolverPyraminx extends SolverTablebase
 
     for(int i=0; i<4; i++)
       {
-      mCornerTwist[i] = computePieceTwist(i,corners[i],faces1);
+      mCornerTwist[i] = computePieceTwist(i,corners[i],mFaceColors);
       if( mCornerTwist[i]<0 ) return ERROR_CORNERS_CANNOT;
       }
 
     for(int i=0; i<4; i++)
       {
-      vertex_twist[i] = computePieceTwist(i,vertices[i],faces1);
+      vertex_twist[i] = computePieceTwist(i,vertices[i],mFaceColors);
       if( vertex_twist[i]<0 ) return ERROR_VERTICES_CANNOT;
       }
 
@@ -429,9 +432,24 @@ public class SolverPyraminx extends SolverTablebase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  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;
@@ -476,8 +494,8 @@ public class SolverPyraminx extends SolverTablebase
 
   private String edgeError(Resources res, int color0, int color1)
     {
-    int j0 = getColorIndex3(color0);
-    int j1 = getColorIndex6(color1);
+    int j0 = getFaceIndex3(color0);
+    int j1 = getFaceIndex6(color1);
 
     String c0 = res.getString(j0);
     String c1 = res.getString(j1);
@@ -500,10 +518,10 @@ public class SolverPyraminx extends SolverTablebase
       case ERROR_VERTEX_GYR_MISSING: return vertexError(res,3,1,0);
       case ERROR_VERTEX_GYB_MISSING: return vertexError(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_EDGE_TWISTED      : return res.getString(R.string.solver_generic_edge_twist);
       case ERROR_CORNERS_CANNOT    : return res.getString(R.string.solver_generic_corners_cannot);
