Project

General

Profile

« Previous | Next » 

Revision 3a43ea70

Added by Leszek Koltunski almost 2 years ago

Fx the solver to be able to handle the case when someone repainted the faces in a different order

View differences:

src/main/java/org/distorted/solvers/SolverPyraminxDuo.java
87 87

  
88 88
///////////////////////////////////////////////////////////////////////////////////////////////////
89 89

  
90
  private int getFaceOfGreenCenter(int[] centers)
90
  private int getFaceOfCenter(int color, int[] centers)
91 91
    {
92
    if( centers[0]==0 ) return 0;
93
    if( centers[1]==0 ) return 1;
94
    if( centers[2]==0 ) return 2;
95
    if( centers[3]==0 ) return 3;
92
    if( centers[0]==color ) return 0;
93
    if( centers[1]==color ) return 1;
94
    if( centers[2]==color ) return 2;
95
    if( centers[3]==color ) return 3;
96 96

  
97 97
    return -1;
98 98
    }
......
220 220
    int result2 = checkAllCentersPresent(centers);
221 221
    if( result2<0 ) return result2;
222 222

  
223
    int twist_gr = computeCenterTwist(centers,0,3);
224
    int twist_ry = computeCenterTwist(centers,3,1);
223
    int[] missing = computeMissingCornerColor(corners);
224

  
225
    int twist_gr = computeCenterTwist(centers,missing[1],missing[2]);
226
    int twist_ry = computeCenterTwist(centers,missing[2],missing[0]);
225 227

  
226 228
    if( (twist_ry-twist_gr+1)%3 != 0 ) return ERROR_TWO_CENTERS_SWAP;
227 229

  
228 230
    int total_twist=0;
229
    int[] missing = computeMissingCornerColor(corners);
230 231

  
231 232
    for(int i=0; i<4; i++)
232 233
      {
......
237 238

  
238 239
    if( (total_twist-twist_gr)%3 !=0 ) return ERROR_CORNER_TWISTED;
239 240

  
240
    int green_face = getFaceOfGreenCenter(centers);
241
    int green_face = getFaceOfCenter(missing[1],centers);
241 242

  
242 243
    return green_face + 4*(corner_twist[3] + 3*(corner_twist[2] + 3*(corner_twist[1] + 3*corner_twist[0])));
243 244
    }

Also available in: Unified diff