Project

General

Profile

« Previous | Next » 

Revision 185dd0a1

Added by Leszek Koltunski almost 2 years ago

Move corner orientation from SolverPyraminx to TablebasesPyraminx (we'll need it for better-looking tablebases scrambling)

View differences:

src/main/java/org/distorted/solvers/SolverCuboid232.java
427 427
      mSolver = ImplementedTablebasesList.createPacked(res, ObjectSignatures.CU_232);
428 428
      }
429 429

  
430
    return mSolver!=null ? mSolver.solution(index) : null;
430
    return mSolver!=null ? mSolver.solution(index,null) : null;
431 431
    }
432 432
}  
433 433

  
src/main/java/org/distorted/solvers/SolverIvyCube.java
247 247
      mSolver = ImplementedTablebasesList.createPacked(res, ObjectSignatures.IVY_2);
248 248
      }
249 249

  
250
    return mSolver!=null ? mSolver.solution(index) : null;
250
    return mSolver!=null ? mSolver.solution(index,null) : null;
251 251
    }
252 252
}  
253 253

  
src/main/java/org/distorted/solvers/SolverPyraminx.java
515 515
    return null;
516 516
    }
517 517

  
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

  
520
  private void addMove(int[] move, int axis, int twist)
521
    {
522
    move[0] = axis;
523
    move[1] = (1<<2);
524
    move[2] = (twist==2 ? -1:twist);
525
    }
526

  
527
///////////////////////////////////////////////////////////////////////////////////////////////////
528

  
529
  private int[][] constructTipMoves(int[] twist)
530
    {
531
    int total = 0;
532

  
533
    for(int i=0; i<4; i++)
534
      if( twist[i]!=0 ) total++;
535

  
536
    if( total>0 )
537
      {
538
      int[][] moves = new int[total][3];
539

  
540
      int index=0;
541
      if( twist[0]!=0 ) { addMove(moves[index],1,twist[0]); index++; }
542
      if( twist[1]!=0 ) { addMove(moves[index],0,twist[1]); index++; }
543
      if( twist[2]!=0 ) { addMove(moves[index],3,twist[2]); index++; }
544
      if( twist[3]!=0 ) { addMove(moves[index],2,twist[3]);          }
545

  
546
      return moves;
547
      }
548

  
549
    return null;
550
    }
551

  
552 518
///////////////////////////////////////////////////////////////////////////////////////////////////
553 519

  
554 520
  public int[][] solution(int index, Resources res)
......
558 524
      mSolver = ImplementedTablebasesList.createPacked(res, ObjectSignatures.PYRA_3);
559 525
      }
560 526

  
561
    int[][] moves1 = mSolver!=null ? mSolver.solution(index) : null;
562
    int[][] moves2 = constructTipMoves(mCornerTwist);
563

  
564
    int len1 = (moves1==null ? 0:moves1.length);
565
    int len2 = (moves2==null ? 0:moves2.length);
566

  
567
    int[][] moves = new int[len1+len2][3];
568

  
569
    if( len1>0 ) System.arraycopy(moves1, 0, moves,    0, len1);
570
    if( len2>0 ) System.arraycopy(moves2, 0, moves, len1, len2);
571

  
572
    return moves;
527
    return mSolver!=null ? mSolver.solution(index,mCornerTwist) : null;
573 528
    }
574 529
}  
575 530

  
src/main/java/org/distorted/solvers/SolverPyraminxDuo.java
292 292
      mSolver = ImplementedTablebasesList.createPacked(res, ObjectSignatures.PDUO_2);
293 293
      }
294 294

  
295
    return mSolver!=null ? mSolver.solution(index) : null;
295
    return mSolver!=null ? mSolver.solution(index,null) : null;
296 296
    }
297 297
}  
298 298

  
src/main/java/org/distorted/solvers/SolverSkewbDiamond.java
493 493
      mSolver = ImplementedTablebasesList.createPacked(res, ObjectSignatures.DIAM_2);
494 494
      }
495 495

  
496
    return mSolver!=null ? mSolver.solution(index) : null;
496
    return mSolver!=null ? mSolver.solution(index,null) : null;
497 497
    }
498 498
}  
499 499

  

Also available in: Unified diff