Project

General

Profile

« Previous | Next » 

Revision 713af0c5

Added by Leszek Koltunski over 1 year ago

Jing Solver: correct detection of missing edge colors.

View differences:

src/main/java/org/distorted/solvers/SolverJing.java
47 47
  private static final int ERROR_TWO_CENTERS        = -19;
48 48

  
49 49
  private TablebasesAbstract mSolver;
50
  private int[] mFaceColors;
50 51

  
51 52
///////////////////////////////////////////////////////////////////////////////////////////////////
52 53

  
......
349 350
    int result1 = checkAllCornersPresent(corners);
350 351
    if( result1<0 ) return result1;
351 352

  
352
    int[] faces = computeFaceColors(corners);
353
    int[][] edgeColors = computeEdgeColors(faces);
353
    mFaceColors = computeFaceColors(corners);
354
    int[][] edgeColors = computeEdgeColors(mFaceColors);
354 355

  
355 356
    getEdges(object,edges);
356 357
    int result2 = checkAllEdgesPresent(edges,edgeColors);
......
362 363

  
363 364
    for(int i=0; i<4; i++)
364 365
      {
365
      corner_twist[i] = computePieceTwist(i,corners[i],faces);
366
      corner_twist[i] = computePieceTwist(i,corners[i],mFaceColors);
366 367
      if( corner_twist[i]<0 ) return ERROR_CORNERS_CANNOT;
367 368
      }
368 369

  
......
373 374
    if( !even ) return ERROR_TWO_EDGES;
374 375
    int[] edge_twist = new int[6];
375 376
    TBPyraminx.getEdgeTwist(edge_twist,quats,0);
376
/*
377
for(int i=0; i<4; i++) android.util.Log.e("D", "cornerTwist "+i+" : "+corner_twist[i]);
378
for(int i=0; i<6; i++) android.util.Log.e("D", "edgeTwist "+i+" : "+edge_twist[i]);
379
for(int i=0; i<6; i++) android.util.Log.e("D", "edge perm "+i+" : "+permutation[i]);
380
*/
381
    int twist_gr = computeCenterTwist(centers,faces[1],faces[2]);
382
    int twist_ry = computeCenterTwist(centers,faces[2],faces[0]);
377

  
378
    int twist_gr = computeCenterTwist(centers,mFaceColors[1],mFaceColors[2]);
379
    int twist_ry = computeCenterTwist(centers,mFaceColors[2],mFaceColors[0]);
383 380

  
384 381
    if( (twist_ry-twist_gr+1)%3 != 0 ) return ERROR_TWO_CENTERS;
385 382

  
......
388 385

  
389 386
    if( (total_twist-twist_gr)%3 !=0 ) return ERROR_CORNER_TWISTED;
390 387

  
391
    int green_face = getFaceOfCenter(faces[1],centers);
388
    int green_face = getFaceOfCenter(mFaceColors[1],centers);
392 389

  
393 390
    int totalEdgeTwist=0;
394 391
    for(int i=0; i<6; i++) totalEdgeTwist += edge_twist[i];
......
398 395
    int edgeTwist = edge_twist[0]+ 2*(edge_twist[1]+ 2*(edge_twist[2]+ 2*(edge_twist[3]+ 2*edge_twist[4])));
399 396
    int perm_num = TablebaseHelpers.computeEvenPermutationNum(permutation);
400 397

  
401
//android.util.Log.e("D", "ret: green_face="+green_face+" vertTwist="+vertexTwist+" edgeTwist="+edgeTwist+" perm: "+perm_num);
402

  
403 398
    return green_face + 4*(vertexTwist + 81*(edgeTwist + 32*perm_num));
404 399
    }
405 400

  
......
435 430

  
436 431
///////////////////////////////////////////////////////////////////////////////////////////////////
437 432

  
438
  private int getColorIndex6(int color)
433
  private int getFaceIndex3(int face)
439 434
    {
440
    switch(color)
435
    switch(mFaceColors[face])
436
      {
437
      case 0: return R.string.color_green3;
438
      case 1: return R.string.color_yellow3;
439
      case 2: return R.string.color_blue3;
440
      case 3: return R.string.color_red3;
441
      }
442

  
443
    return -1;
444
    }
445

  
446
///////////////////////////////////////////////////////////////////////////////////////////////////
447

  
448
  private int getFaceIndex6(int face)
449
    {
450
    switch(mFaceColors[face])
441 451
      {
442 452
      case 0: return R.string.color_green6;
443 453
      case 1: return R.string.color_yellow6;
......
465 475

  
466 476
///////////////////////////////////////////////////////////////////////////////////////////////////
467 477

  
468
  private String edgeError(Resources res, int color0, int color1)
478
  private String edgeError(Resources res, int face0, int face1)
469 479
    {
470
    int j0 = getColorIndex3(color0);
471
    int j1 = getColorIndex6(color1);
480
    int j0 = getFaceIndex3(face0);
481
    int j1 = getFaceIndex6(face1);
472 482

  
473 483
    String c0 = res.getString(j0);
474 484
    String c1 = res.getString(j1);
......
487 497
      case ERROR_CORNER_GYR_MISSING: return cornerError(res,3,1,0);
488 498
      case ERROR_CORNER_GYB_MISSING: return cornerError(res,2,1,0);
489 499
      case ERROR_EDGE_RB_MISSING   : return edgeError(res,3,2);
490
      case ERROR_EDGE_RY_MISSING   : return edgeError(res,3,1);
491
      case ERROR_EDGE_RG_MISSING   : return edgeError(res,3,0);
492
      case ERROR_EDGE_YB_MISSING   : return edgeError(res,2,1);
493
      case ERROR_EDGE_GB_MISSING   : return edgeError(res,2,0);
500
      case ERROR_EDGE_RY_MISSING   : return edgeError(res,2,0);
501
      case ERROR_EDGE_RG_MISSING   : return edgeError(res,2,1);
502
      case ERROR_EDGE_YB_MISSING   : return edgeError(res,3,0);
503
      case ERROR_EDGE_GB_MISSING   : return edgeError(res,3,1);
494 504
      case ERROR_EDGE_GY_MISSING   : return edgeError(res,1,0);
495 505
      case ERROR_CENTER_G_MISSING  : String colorG = res.getString(R.string.color_green2);
496 506
                                     return res.getString(R.string.solver_generic_missing_center,colorG);

Also available in: Unified diff