Project

General

Profile

« Previous | Next » 

Revision 11e67fa5

Added by Leszek Koltunski over 1 year ago

Fix SkewbDiamond solver - previously some impossible positions slipped through.

View differences:

src/main/java/org/distorted/solvers/SolverSkewbDiamond.java
41 41

  
42 42
  private static final int ERROR_TWO_CORNERS      = -15;
43 43
  private static final int ERROR_TWO_CENTERS      = -16;
44
  private static final int ERROR_CORNER_TWIST     = -17;
45
  private static final int ERROR_CORNERS_CANNOT   = -18;
44
  private static final int ERROR_CORNER_TWIST_90  = -17;
45
  private static final int ERROR_CORNER_TWIST_180 = -18;
46
  private static final int ERROR_CORNERS_CANNOT   = -19;
46 47

  
47 48
  private TablebasesAbstract mSolver;
48 49
  private final int[] mFaceColors;
......
142 143
  private int getTotalTwist(int[] twist)
143 144
    {
144 145
    int total = 0;
146
    boolean even = true;
145 147

  
146 148
    for(int i=0; i<6; i++)
147 149
      {
148 150
      int t= twist[i];
149
      if( t==1 || t==3 ) return -1;
150
      if( i<5 && t==2 ) total+=(1<<i);
151

  
152
      if( t==1 || t==3 ) return ERROR_CORNER_TWIST_90;
153
      if( t==2 )
154
        {
155
        if( i<5 )
156
          {
157
          total+=(1<<i);
158
          even = !even;
159
          }
160
        else if( even ) return ERROR_CORNER_TWIST_180;
161
        }
151 162
      }
152 163

  
153 164
    return total;
......
372 383
+corners_twist[3]+" "+corners_twist[4]+" "+corners_twist[5]);
373 384
*/
374 385
    int totalTwist = getTotalTwist(corners_twist);
375
    if( totalTwist<0 ) return ERROR_CORNER_TWIST;
386
    if( totalTwist<0 ) return totalTwist;
376 387

  
377 388
    int corners_perm_num = TablebaseHelpers.computeEvenPermutationNum(corners_perm);
378 389
    int centers_perm_num = TablebaseHelpers.computeEvenPermutationNum(free_centers_perm);
......
478 489

  
479 490
      case ERROR_TWO_CORNERS      : return res.getString(R.string.solver_generic_two_corners);
480 491
      case ERROR_TWO_CENTERS      : return res.getString(R.string.solver_generic_two_centers);
481
      case ERROR_CORNER_TWIST     : return res.getString(R.string.solver_generic_corner_twist);
492
      case ERROR_CORNER_TWIST_90  : return res.getString(R.string.solver_generic_corner_twist) + " (90)";
493
      case ERROR_CORNER_TWIST_180 : return res.getString(R.string.solver_generic_corner_twist) + " (180)";
482 494
      case ERROR_CORNERS_CANNOT   : return res.getString(R.string.solver_generic_corners_cannot);
483 495
      }
484 496

  

Also available in: Unified diff