Revision f4b24b79
Added by Leszek Koltunski 11 months ago
| src/main/java/org/distorted/objects/RubikObject.java | ||
|---|---|---|
| 81 | 81 |
int patternOrdinal = RubikPatternList.getOrdinal(mObjectIndex); |
| 82 | 82 |
mPatterns = RubikPatternList.getPatterns(patternOrdinal); |
| 83 | 83 |
|
| 84 |
mSolverOrdinal = SolvingList.getSolverOrdinal(mObjectIndex);
|
|
| 84 |
mSolverOrdinal = SolvingList.getSolverOrdinal(mObjectOrdinal);
|
|
| 85 | 85 |
mExtrasOrdinal = -1; |
| 86 | 86 |
|
| 87 | 87 |
mObjectVersion = meta.objectVersion(); |
| src/main/java/org/distorted/solvers/SolverTablebase.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 15 | 15 |
import org.distorted.objectlib.main.TwistyObject; |
| 16 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 17 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 16 | 18 |
import org.distorted.solverui.ScreenSolver; |
| 17 | 19 |
|
| 18 | 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 22 | 24 |
private final OperatingSystemInterface mOS; |
| 23 | 25 |
private final Resources mRes; |
| 24 | 26 |
private final TwistyObject mObject; |
| 27 |
private TablebasesAbstract mSolver; |
|
| 25 | 28 |
|
| 26 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 27 | 30 |
|
| 28 | 31 |
public abstract int tablebaseIndex(TwistyObject object); |
| 29 | 32 |
public abstract String error(int index, Resources res); |
| 30 |
public abstract int[][] solution(int index, OperatingSystemInterface os); |
|
| 31 | 33 |
|
| 32 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | 35 |
// PUBLIC API |
| ... | ... | |
| 40 | 42 |
mObject= object; |
| 41 | 43 |
} |
| 42 | 44 |
|
| 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 46 |
|
|
| 47 |
int[] getExtra() { return null; }
|
|
| 48 |
|
|
| 43 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 50 |
|
| 45 | 51 |
public void solve(ScreenSolver screen) |
| ... | ... | |
| 48 | 54 |
|
| 49 | 55 |
if( index>=0 ) |
| 50 | 56 |
{
|
| 51 |
int[][] moves = solution(index,mOS); |
|
| 57 |
if( mSolver==null ) |
|
| 58 |
{
|
|
| 59 |
mSolver = ImplementedTablebasesList.createPacked(mOS, mObject.getShortName() ); |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
mSolver.initialize(); |
|
| 63 |
int[][] moves = mSolver!=null ? mSolver.solution(index,getExtra(),mOS) : null; |
|
| 52 | 64 |
screen.setSolved(moves); |
| 53 | 65 |
} |
| 54 | 66 |
else |
| src/main/java/org/distorted/solvers/SolverTablebaseCU232.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 20 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 21 | 18 |
|
| 22 | 19 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 23 | 20 |
|
| ... | ... | |
| 41 | 38 |
private static final int ERROR_EDGE_TWISTED = -14; |
| 42 | 39 |
private static final int ERROR_CORNER_TWISTED = -15; |
| 43 | 40 |
|
| 44 |
TablebasesAbstract mSolver; |
|
| 45 | 41 |
private final int[] mFaceColors; |
| 46 | 42 |
|
| 47 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 402 | 398 |
|
| 403 | 399 |
return null; |
| 404 | 400 |
} |
| 405 |
|
|
| 406 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 407 |
|
|
| 408 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 409 |
{
|
|
| 410 |
if( mSolver==null ) |
|
| 411 |
{
|
|
| 412 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.CU_232.name() ); |
|
| 413 |
} |
|
| 414 |
|
|
| 415 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 416 |
} |
|
| 417 | 401 |
} |
| 418 | 402 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseCU323.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TBCuboid323; |
| 20 | 18 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 21 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 22 | 19 |
|
| 23 | 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 21 |
// a few cu_323 max (depth 18) indices: 1180633, 1180642, 1182044, 1190482, 128151851, 128190028 |
|
| 24 | 22 |
|
| 25 | 23 |
public class SolverTablebaseCU323 extends SolverTablebase |
| 26 | 24 |
{
|
| ... | ... | |
| 30 | 28 |
private static final int ERROR_EDGE_TWISTED = -4; |
| 31 | 29 |
private static final int ERROR_CORNER_TWISTED = -5; |
| 32 | 30 |
|
| 33 |
TablebasesAbstract mSolver; |
|
| 34 | 31 |
private final int[] mFaceColors; |
| 35 | 32 |
private int mErrorColor1, mErrorColor2, mErrorColor3; |
| 36 | 33 |
|
| ... | ... | |
| 437 | 434 |
|
| 438 | 435 |
return null; |
| 439 | 436 |
} |
| 440 |
|
|
| 441 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 442 |
// a few cu_323 max (depth 18) indices: |
|
| 443 |
// 1180633, 1180642, 1182044, 1190482, 128151851, 128190028 |
|
| 444 |
|
|
| 445 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 446 |
{
|
|
| 447 |
if( mSolver==null ) |
|
| 448 |
{
|
|
| 449 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.CU_323.name() ); |
|
| 450 |
} |
|
| 451 |
|
|
| 452 |
((TBCuboid323)mSolver).initialize(); |
|
| 453 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 454 |
} |
|
| 455 | 437 |
} |
| 456 | 438 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseCUBE2.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 20 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 21 | 18 |
import org.distorted.objectlib.tablebases.TBCube2; |
| 22 | 19 |
|
| 23 | 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 35 | 32 |
private static final int ERROR_CORNERS_CANNOT = -9; |
| 36 | 33 |
private static final int ERROR_CORNER_TWISTED = -10; |
| 37 | 34 |
|
| 38 |
TablebasesAbstract mSolver; |
|
| 39 | 35 |
private final int[] mFaceColors; |
| 40 | 36 |
|
| 41 | 37 |
//////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 281 | 277 |
|
| 282 | 278 |
return null; |
| 283 | 279 |
} |
| 284 |
|
|
| 285 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 286 |
|
|
| 287 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 288 |
{
|
|
| 289 |
if( mSolver==null ) |
|
| 290 |
{
|
|
| 291 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.CUBE_2.name() ); |
|
| 292 |
} |
|
| 293 |
|
|
| 294 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 295 |
} |
|
| 296 | 280 |
} |
| 297 | 281 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseDIAM2.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 20 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 21 | 18 |
|
| 22 | 19 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 23 | 20 |
|
| ... | ... | |
| 45 | 42 |
private static final int ERROR_CORNER_TWIST_180 = -18; |
| 46 | 43 |
private static final int ERROR_CORNERS_CANNOT = -19; |
| 47 | 44 |
|
| 48 |
private TablebasesAbstract mSolver; |
|
| 49 | 45 |
private final int[] mFaceColors; |
| 50 | 46 |
|
| 51 | 47 |
private static final int[] FREE_CENTERS = {0,2,5,7};
|
| ... | ... | |
| 496 | 492 |
|
| 497 | 493 |
return null; |
| 498 | 494 |
} |
| 499 |
|
|
| 500 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 501 |
|
|
| 502 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 503 |
{
|
|
| 504 |
if( mSolver==null ) |
|
| 505 |
{
|
|
| 506 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.DIAM_2.name()); |
|
| 507 |
} |
|
| 508 |
|
|
| 509 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 510 |
} |
|
| 511 | 495 |
} |
| 512 | 496 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseDINO4.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 | 17 |
import org.distorted.objectlib.shape.ShapeColors; |
| 19 | 18 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
| 20 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 21 | 19 |
import org.distorted.objectlib.tablebases.TBDino4; |
| 22 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 23 | 20 |
|
| 24 | 21 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 25 | 22 |
|
| 26 | 23 |
public class SolverTablebaseDINO4 extends SolverTablebase |
| 27 | 24 |
{
|
| 28 | 25 |
private static final int ERROR_EDGE_THREE = -1; |
| 29 |
private TablebasesAbstract mSolver; |
|
| 30 | 26 |
private int mErrorColor; |
| 31 | 27 |
|
| 32 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 169 | 165 |
|
| 170 | 166 |
return res.getString(R.string.solver_generic_edge_three,color); |
| 171 | 167 |
} |
| 172 |
|
|
| 173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 174 |
|
|
| 175 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 176 |
{
|
|
| 177 |
if( mSolver==null ) |
|
| 178 |
{
|
|
| 179 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.DIN4_3.name() ); |
|
| 180 |
} |
|
| 181 |
|
|
| 182 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 183 |
} |
|
| 184 | 168 |
} |
| 185 | 169 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseDINO6.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TBDino6; |
| 20 | 18 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 21 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 22 | 19 |
|
| 23 | 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 24 | 21 |
|
| ... | ... | |
| 37 | 34 |
{5,2},{0,5},{5,3},{1,5}
|
| 38 | 35 |
}; |
| 39 | 36 |
|
| 40 |
private TablebasesAbstract mSolver; |
|
| 41 | 37 |
private final int[] mFaceColors; |
| 42 | 38 |
private int mErrorColor1, mErrorColor2; |
| 43 | 39 |
|
| ... | ... | |
| 435 | 431 |
|
| 436 | 432 |
return null; |
| 437 | 433 |
} |
| 438 |
|
|
| 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 440 |
|
|
| 441 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 442 |
{
|
|
| 443 |
if( mSolver==null ) |
|
| 444 |
{
|
|
| 445 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.DINO_3.name() ); |
|
| 446 |
} |
|
| 447 |
|
|
| 448 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 449 |
} |
|
| 450 | 434 |
} |
| 451 | 435 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseIVY2.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 20 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 21 | 18 |
|
| 22 | 19 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 23 | 20 |
|
| ... | ... | |
| 32 | 29 |
private static final int ERROR_TWO_CENTERS_SWAP = -7; |
| 33 | 30 |
private static final int ERROR_CORNERS_CANNOT = -8; |
| 34 | 31 |
|
| 35 |
TablebasesAbstract mSolver; |
|
| 36 |
|
|
| 37 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 | 33 |
|
| 39 | 34 |
private int checkAllCentersPresent(int[] centers) |
| ... | ... | |
| 238 | 233 |
|
| 239 | 234 |
return null; |
| 240 | 235 |
} |
| 241 |
|
|
| 242 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 243 |
|
|
| 244 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 245 |
{
|
|
| 246 |
if( mSolver==null ) |
|
| 247 |
{
|
|
| 248 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.IVY_2.name() ); |
|
| 249 |
} |
|
| 250 |
|
|
| 251 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 252 |
} |
|
| 253 | 236 |
} |
| 254 | 237 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseJING2.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TBPyraminx; |
| 20 | 18 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 21 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 22 | 19 |
|
| 23 | 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 24 | 21 |
|
| ... | ... | |
| 47 | 44 |
private static final int ERROR_TWO_EDGES = -18; |
| 48 | 45 |
private static final int ERROR_TWO_CENTERS = -19; |
| 49 | 46 |
|
| 50 |
private TablebasesAbstract mSolver; |
|
| 51 | 47 |
private int[] mFaceColors; |
| 52 | 48 |
|
| 53 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 520 | 516 |
|
| 521 | 517 |
return null; |
| 522 | 518 |
} |
| 523 |
|
|
| 524 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 525 |
|
|
| 526 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 527 |
{
|
|
| 528 |
if( mSolver==null ) |
|
| 529 |
{
|
|
| 530 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.JING_2.name()); |
|
| 531 |
} |
|
| 532 |
|
|
| 533 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 534 |
} |
|
| 535 | 519 |
} |
| 536 | 520 |
|
| src/main/java/org/distorted/solvers/SolverTablebasePDIA3.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 20 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 21 | 18 |
|
| 22 | 19 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 23 | 20 |
|
| ... | ... | |
| 42 | 39 |
private static final int ERROR_TWO_CENTERS = -15; |
| 43 | 40 |
private static final int ERROR_CORNERS_CANNOT = -16; |
| 44 | 41 |
|
| 45 |
private TablebasesAbstract mSolver; |
|
| 46 | 42 |
private final int[] mFaceColors; |
| 47 | 43 |
|
| 48 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 359 | 355 |
|
| 360 | 356 |
return null; |
| 361 | 357 |
} |
| 362 |
|
|
| 363 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 364 |
|
|
| 365 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 366 |
{
|
|
| 367 |
if( mSolver==null ) |
|
| 368 |
{
|
|
| 369 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.PDIA_3.name() ); |
|
| 370 |
} |
|
| 371 |
|
|
| 372 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 373 |
} |
|
| 374 | 358 |
} |
| 375 | 359 |
|
| src/main/java/org/distorted/solvers/SolverTablebasePDUO2.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 20 | 17 |
|
| 21 | 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 22 | 19 |
|
| ... | ... | |
| 37 | 34 |
|
| 38 | 35 |
private static final int ERROR_CORNERS_CANNOT = -11; |
| 39 | 36 |
|
| 40 |
TablebasesAbstract mSolver; |
|
| 41 |
|
|
| 42 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 43 | 38 |
|
| 44 | 39 |
private boolean cornerEqual(int[] corner, int c1, int c2, int c3) |
| ... | ... | |
| 283 | 278 |
|
| 284 | 279 |
return null; |
| 285 | 280 |
} |
| 286 |
|
|
| 287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 288 |
|
|
| 289 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 290 |
{
|
|
| 291 |
if( mSolver==null ) |
|
| 292 |
{
|
|
| 293 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.PDUO_2.name() ); |
|
| 294 |
} |
|
| 295 |
|
|
| 296 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 297 |
} |
|
| 298 | 281 |
} |
| 299 | 282 |
|
| src/main/java/org/distorted/solvers/SolverTablebasePYRA3.java | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
import org.distorted.main.R; |
| 15 | 15 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 16 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 17 | 16 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 19 | 17 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 20 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 21 | 18 |
import org.distorted.objectlib.tablebases.TBPyraminx; |
| 22 | 19 |
|
| 23 | 20 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 47 | 44 |
private static final int ERROR_C_V_DONT_MATCH = -18; |
| 48 | 45 |
private static final int ERROR_TWO_EDGES = -19; |
| 49 | 46 |
|
| 50 |
private TablebasesAbstract mSolver; |
|
| 51 | 47 |
private int[] mCornerTwist; |
| 52 | 48 |
private int[] mFaceColors; |
| 53 | 49 |
|
| ... | ... | |
| 536 | 532 |
|
| 537 | 533 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 538 | 534 |
|
| 539 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 540 |
{
|
|
| 541 |
if( mSolver==null ) |
|
| 542 |
{
|
|
| 543 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.PYRA_3.name()); |
|
| 544 |
} |
|
| 545 |
|
|
| 546 |
return mSolver!=null ? mSolver.solution(index,mCornerTwist,os) : null; |
|
| 547 |
} |
|
| 535 |
@Override int[] getExtra() { return mCornerTwist; }
|
|
| 548 | 536 |
} |
| 549 | 537 |
|
| src/main/java/org/distorted/solvers/SolverTablebaseSKEW2.java | ||
|---|---|---|
| 16 | 16 |
|
| 17 | 17 |
import org.distorted.main.R; |
| 18 | 18 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 19 |
import org.distorted.objectlib.metadata.ListObjects; |
|
| 20 | 19 |
import org.distorted.objectlib.main.TwistyObject; |
| 21 |
import org.distorted.objectlib.tablebases.ImplementedTablebasesList; |
|
| 22 | 20 |
import org.distorted.objectlib.tablebases.TBSkewb; |
| 23 | 21 |
import org.distorted.objectlib.tablebases.TablebaseHelpers; |
| 24 |
import org.distorted.objectlib.tablebases.TablebasesAbstract; |
|
| 25 | 22 |
|
| 26 | 23 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 27 | 24 |
|
| ... | ... | |
| 51 | 48 |
private static final int ERROR_FREE_CORNERS_NOT_EVEN = -19; |
| 52 | 49 |
private static final int ERROR_FREE_CORNERS_ROTATED = -20; |
| 53 | 50 |
|
| 54 |
private TablebasesAbstract mSolver; |
|
| 55 | 51 |
private final int[] mFaceColors; |
| 56 | 52 |
|
| 57 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 435 | 431 |
|
| 436 | 432 |
return null; |
| 437 | 433 |
} |
| 438 |
|
|
| 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 440 |
|
|
| 441 |
public int[][] solution(int index, OperatingSystemInterface os) |
|
| 442 |
{
|
|
| 443 |
if( mSolver==null ) |
|
| 444 |
{
|
|
| 445 |
mSolver = ImplementedTablebasesList.createPacked(os, ListObjects.SKEW_2.name() ); |
|
| 446 |
} |
|
| 447 |
|
|
| 448 |
return mSolver!=null ? mSolver.solution(index,null,os) : null; |
|
| 449 |
} |
|
| 450 | 434 |
} |
| 451 | 435 |
|
| src/main/java/org/distorted/solvers/SolvingList.java | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
package org.distorted.solvers; |
| 11 | 11 |
|
| 12 |
import static org.distorted.objectlib.metadata.ListObjects.*; |
|
| 13 |
|
|
| 12 | 14 |
import android.content.res.Resources; |
| 13 | 15 |
|
| 14 | 16 |
import org.distorted.main.R; |
| ... | ... | |
| 23 | 25 |
|
| 24 | 26 |
public enum SolvingList |
| 25 | 27 |
{
|
| 26 |
CUBE2 (MetadataCUBE_2.INDEX, SolverTablebaseCUBE2.class, R.string.solver_cube2_title, R.string.solver_cube2_description, true),
|
|
| 27 |
CUBE3_KOCIEMBA (MetadataCUBE_3.INDEX, SolverKociembaCUBE3.class , R.string.solver_cube3_title, R.string.solver_cube3_description, true),
|
|
| 28 |
CU_232 (MetadataCU_232.INDEX, SolverTablebaseCU232.class, R.string.solver_cu232_title, R.string.solver_cu232_description, true),
|
|
| 29 |
CU_323 (MetadataCU_323.INDEX, SolverTablebaseCU323.class, R.string.solver_cu323_title, R.string.solver_cu323_description, true),
|
|
| 30 |
PYRAMINX (MetadataPYRA_3.INDEX, SolverTablebasePYRA3.class, R.string.solver_pyra3_title, R.string.solver_pyra3_description, true),
|
|
| 31 |
SKEWB (MetadataSKEW_2.INDEX, SolverTablebaseSKEW2.class, R.string.solver_skew2_title, R.string.solver_skew2_description, true),
|
|
| 32 |
PYRAMINX_DUO (MetadataPDUO_2.INDEX, SolverTablebasePDUO2.class, R.string.solver_pduo2_title, R.string.solver_pduo2_description, true),
|
|
| 33 |
IVY (MetadataIVY_2.INDEX , SolverTablebaseIVY2.class , R.string.solver_ivy_title, R.string.solver_ivy_description, true),
|
|
| 34 |
DIAMOND (MetadataDIAM_2.INDEX, SolverTablebasePDIA3.class, R.string.solver_diam2_title, R.string.solver_diam2_description, true),
|
|
| 35 |
JING2 (MetadataJING_2.INDEX, SolverTablebaseJING2.class, R.string.solver_jing2_title, R.string.solver_jing2_description, true),
|
|
| 36 |
DINO6 (MetadataDINO_3.INDEX, SolverTablebaseDINO6.class, R.string.solver_dino6_title, R.string.solver_dino6_description, true),
|
|
| 37 |
DINO4 (MetadataDIN4_3.INDEX, SolverTablebaseDINO4.class, R.string.solver_dino4_title, R.string.solver_dino4_description, true),
|
|
| 38 |
PDIA (MetadataPDIA_3.INDEX, SolverTablebasePDUO2.class, R.string.solver_pdia_title, R.string.solver_pdia_description, true),
|
|
| 28 |
CUBE2 (CUBE_2.ordinal(), SolverTablebaseCUBE2.class, R.string.solver_cube2_title, R.string.solver_cube2_description, true),
|
|
| 29 |
CUBE3_KOCIEMBA (CUBE_3.ordinal(), SolverKociembaCUBE3.class , R.string.solver_cube3_title, R.string.solver_cube3_description, true),
|
|
| 30 |
CU232 (CU_232.ordinal(), SolverTablebaseCU232.class, R.string.solver_cu232_title, R.string.solver_cu232_description, true),
|
|
| 31 |
CU323 (CU_323.ordinal(), SolverTablebaseCU323.class, R.string.solver_cu323_title, R.string.solver_cu323_description, true),
|
|
| 32 |
PYRAMINX (PYRA_3.ordinal(), SolverTablebasePYRA3.class, R.string.solver_pyra3_title, R.string.solver_pyra3_description, true),
|
|
| 33 |
SKEWB (SKEW_2.ordinal(), SolverTablebaseSKEW2.class, R.string.solver_skew2_title, R.string.solver_skew2_description, true),
|
|
| 34 |
PYRAMINX_DUO (PDUO_2.ordinal(), SolverTablebasePDUO2.class, R.string.solver_pduo2_title, R.string.solver_pduo2_description, true),
|
|
| 35 |
IVY (IVY_2.ordinal() , SolverTablebaseIVY2.class , R.string.solver_ivy_title, R.string.solver_ivy_description, true),
|
|
| 36 |
DIAMOND (DIAM_2.ordinal(), SolverTablebaseDIAM2.class, R.string.solver_diam2_title, R.string.solver_diam2_description, true),
|
|
| 37 |
JING2 (JING_2.ordinal(), SolverTablebaseJING2.class, R.string.solver_jing2_title, R.string.solver_jing2_description, true),
|
|
| 38 |
DINO6 (DINO_3.ordinal(), SolverTablebaseDINO6.class, R.string.solver_dino6_title, R.string.solver_dino6_description, true),
|
|
| 39 |
DINO4 (DIN4_3.ordinal(), SolverTablebaseDINO4.class, R.string.solver_dino4_title, R.string.solver_dino4_description, true),
|
|
| 40 |
PDIA (PDIA_3.ordinal(), SolverTablebasePDIA3.class, R.string.solver_pdia_title, R.string.solver_pdia_description, true),
|
|
| 39 | 41 |
; |
| 40 | 42 |
|
| 41 | 43 |
public static final int NUM_OBJECTS = values().length; |
| 42 | 44 |
|
| 43 |
private final int mObject; |
|
| 45 |
private final int mObjectOrdinal;
|
|
| 44 | 46 |
private final Class<? extends SolvingInterface> mClass; |
| 45 | 47 |
private final int mTitle; |
| 46 | 48 |
private final int mDescription; |
| ... | ... | |
| 71 | 73 |
public static int getSolverOrdinal(int objectOrdinal) |
| 72 | 74 |
{
|
| 73 | 75 |
for(int o=0; o<NUM_OBJECTS; o++) |
| 74 |
if( objects[o].mObject==objectOrdinal ) return o; |
|
| 76 |
if( objects[o].mObjectOrdinal==objectOrdinal ) return o;
|
|
| 75 | 77 |
|
| 76 | 78 |
return -1; |
| 77 | 79 |
} |
| ... | ... | |
| 80 | 82 |
|
| 81 | 83 |
SolvingList(int object, final Class<? extends SolvingInterface> clazz, int title, int descripton, boolean implemented) |
| 82 | 84 |
{
|
| 83 |
mObject = object;
|
|
| 84 |
mClass = clazz; |
|
| 85 |
mTitle = title; |
|
| 86 |
mDescription = descripton; |
|
| 87 |
mImplemented = implemented; |
|
| 85 |
mObjectOrdinal= object;
|
|
| 86 |
mClass = clazz;
|
|
| 87 |
mTitle = title;
|
|
| 88 |
mDescription = descripton;
|
|
| 89 |
mImplemented = implemented;
|
|
| 88 | 90 |
} |
| 89 | 91 |
|
| 90 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 110 | 112 |
|
| 111 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 112 | 114 |
|
| 113 |
public int getObject() { return mObject; }
|
|
| 115 |
public int getObjectOrdinal() { return mObjectOrdinal; }
|
|
| 114 | 116 |
public int getTitle() { return mTitle; }
|
| 115 | 117 |
public int getDescription() { return mDescription; }
|
| 116 | 118 |
public boolean isImplemented() { return mImplemented; }
|
| ... | ... | |
| 130 | 132 |
} |
| 131 | 133 |
else |
| 132 | 134 |
{
|
| 133 |
android.util.Log.e("ImplementedSolversList", "ERROR! number of SolverInterface constructors="+cons.length);
|
|
| 135 |
android.util.Log.e("SolvingList", "ERROR! number of SolverInterface constructors="+cons.length);
|
|
| 134 | 136 |
} |
| 135 | 137 |
} |
| 136 | 138 |
catch(IllegalAccessException iae) |
| 137 | 139 |
{
|
| 138 |
android.util.Log.e("ImplementedSolversList", "Illegal Access Exception: "+iae.getMessage());
|
|
| 140 |
android.util.Log.e("SolvingList", "Illegal Access Exception: "+iae.getMessage());
|
|
| 139 | 141 |
} |
| 140 | 142 |
catch(InstantiationException ie) |
| 141 | 143 |
{
|
| 142 |
android.util.Log.e("ImplementedSolversList", "Instantiation Exception: "+ie.getMessage());
|
|
| 144 |
android.util.Log.e("SolvingList", "Instantiation Exception: "+ie.getMessage());
|
|
| 143 | 145 |
} |
| 144 | 146 |
catch(InvocationTargetException ite) |
| 145 | 147 |
{
|
| 146 |
android.util.Log.e("ImplementedSolversList", "Invocation Target Exception: "+ite.getMessage());
|
|
| 148 |
android.util.Log.e("SolvingList", "Invocation Target Exception: "+ite.getMessage());
|
|
| 147 | 149 |
} |
| 148 | 150 |
|
| 149 | 151 |
return null; |
| src/main/java/org/distorted/solverui/ScreenSolver.java | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
package org.distorted.solverui; |
| 11 | 11 |
|
| 12 |
import static org.distorted.objectlib.metadata.ListObjects.*; |
|
| 13 |
|
|
| 12 | 14 |
import android.content.SharedPreferences; |
| 13 | 15 |
import android.graphics.Bitmap; |
| 14 | 16 |
import android.graphics.Canvas; |
| ... | ... | |
| 29 | 31 |
import org.distorted.main.R; |
| 30 | 32 |
import org.distorted.objectlib.main.ObjectControl; |
| 31 | 33 |
import org.distorted.objectlib.main.TwistyObject; |
| 32 |
import org.distorted.objectlib.metadata.MetadataBALL_4; |
|
| 33 |
import org.distorted.objectlib.metadata.MetadataCRYS_3; |
|
| 34 |
import org.distorted.objectlib.metadata.MetadataDIAM_2; |
|
| 35 |
import org.distorted.objectlib.metadata.MetadataDIAM_3; |
|
| 36 |
import org.distorted.objectlib.metadata.MetadataDIAM_4; |
|
| 37 |
import org.distorted.objectlib.metadata.MetadataDIN4_3; |
|
| 38 |
import org.distorted.objectlib.metadata.MetadataICOS_2; |
|
| 39 |
import org.distorted.objectlib.metadata.MetadataJING_2; |
|
| 40 |
import org.distorted.objectlib.metadata.MetadataKILO_3; |
|
| 41 |
import org.distorted.objectlib.metadata.MetadataKILO_5; |
|
| 42 |
import org.distorted.objectlib.metadata.MetadataMEGA_3; |
|
| 43 |
import org.distorted.objectlib.metadata.MetadataMEGA_5; |
|
| 44 |
import org.distorted.objectlib.metadata.MetadataMORP_2; |
|
| 45 |
import org.distorted.objectlib.metadata.MetadataMORP_3; |
|
| 46 |
import org.distorted.objectlib.metadata.MetadataMORP_4; |
|
| 47 |
import org.distorted.objectlib.metadata.MetadataPDIA_3; |
|
| 48 |
import org.distorted.objectlib.metadata.MetadataPDUO_2; |
|
| 49 |
import org.distorted.objectlib.metadata.MetadataPENT_2; |
|
| 50 |
import org.distorted.objectlib.metadata.MetadataPYRA_3; |
|
| 51 |
import org.distorted.objectlib.metadata.MetadataPYRA_4; |
|
| 52 |
import org.distorted.objectlib.metadata.MetadataPYRA_5; |
|
| 53 |
import org.distorted.objectlib.metadata.MetadataSTAR_3; |
|
| 54 |
import org.distorted.objectlib.metadata.MetadataTRAJ_3; |
|
| 55 |
import org.distorted.objectlib.metadata.MetadataTRAJ_4; |
|
| 56 |
import org.distorted.objectlib.shape.ShapeColors; |
|
| 57 |
import org.distorted.objectlib.shape.ShapeDiamond; |
|
| 58 |
import org.distorted.objectlib.shape.ShapeDodecahedron; |
|
| 59 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
|
| 60 |
import org.distorted.objectlib.shape.ShapeIcosahedron; |
|
| 61 |
import org.distorted.objectlib.shape.ShapeOctahedron; |
|
| 62 |
import org.distorted.objectlib.shape.ShapeTetrahedron; |
|
| 34 |
import org.distorted.objectlib.shape.*; |
|
| 63 | 35 |
import org.distorted.solvers.SolvingList; |
| 64 | 36 |
import org.distorted.solvers.SolvingThread; |
| 65 | 37 |
|
| ... | ... | |
| 108 | 80 |
|
| 109 | 81 |
int solverIndex= act.getSolverOrdinal(); |
| 110 | 82 |
mList = SolvingList.getSolver(solverIndex); |
| 111 |
int currentObject = mList.getObject(); |
|
| 83 |
int currentObject = mList.getObjectOrdinal();
|
|
| 112 | 84 |
control.solveOnly(); |
| 113 | 85 |
generateFaceColors(currentObject); |
| 114 | 86 |
|
| ... | ... | |
| 164 | 136 |
{
|
| 165 | 137 |
mColorMode = MODE_NORMAL; |
| 166 | 138 |
|
| 167 |
if( object==MetadataPYRA_3.INDEX ||
|
|
| 168 |
object==MetadataPYRA_4.INDEX ||
|
|
| 169 |
object==MetadataPYRA_5.INDEX ||
|
|
| 170 |
object==MetadataPDUO_2.INDEX ||
|
|
| 171 |
object==MetadataJING_2.INDEX ||
|
|
| 172 |
object==MetadataMORP_2.INDEX ||
|
|
| 173 |
object==MetadataMORP_3.INDEX ||
|
|
| 174 |
object==MetadataMORP_4.INDEX )
|
|
| 139 |
if( object==PYRA_3.ordinal() ||
|
|
| 140 |
object==PYRA_4.ordinal() ||
|
|
| 141 |
object==PYRA_5.ordinal() ||
|
|
| 142 |
object==PDUO_2.ordinal() ||
|
|
| 143 |
object==JING_2.ordinal() ||
|
|
| 144 |
object==MORP_2.ordinal() ||
|
|
| 145 |
object==MORP_3.ordinal() ||
|
|
| 146 |
object==MORP_4.ordinal() )
|
|
| 175 | 147 |
{
|
| 176 | 148 |
mNumColors = ShapeTetrahedron.NUM_FACES; |
| 177 | 149 |
mFaceColors = ShapeTetrahedron.FACE_COLORS; |
| 178 | 150 |
} |
| 179 |
else if( object==MetadataDIAM_2.INDEX ||
|
|
| 180 |
object==MetadataDIAM_3.INDEX ||
|
|
| 181 |
object==MetadataDIAM_4.INDEX ||
|
|
| 182 |
object==MetadataTRAJ_3.INDEX ||
|
|
| 183 |
object==MetadataTRAJ_4.INDEX ||
|
|
| 184 |
object==MetadataPDIA_3.INDEX )
|
|
| 151 |
else if( object==DIAM_2.ordinal() ||
|
|
| 152 |
object==DIAM_3.ordinal() ||
|
|
| 153 |
object==DIAM_4.ordinal() ||
|
|
| 154 |
object==TRAJ_3.ordinal() ||
|
|
| 155 |
object==TRAJ_4.ordinal() ||
|
|
| 156 |
object==PDIA_3.ordinal() )
|
|
| 185 | 157 |
{
|
| 186 | 158 |
mNumColors = ShapeOctahedron.NUM_FACES; |
| 187 | 159 |
mFaceColors = ShapeOctahedron.FACE_COLORS; |
| 188 | 160 |
} |
| 189 |
else if( object==MetadataCRYS_3.INDEX ||
|
|
| 190 |
object==MetadataSTAR_3.INDEX ||
|
|
| 191 |
object==MetadataPENT_2.INDEX ||
|
|
| 192 |
object==MetadataKILO_3.INDEX ||
|
|
| 193 |
object==MetadataKILO_5.INDEX ||
|
|
| 194 |
object==MetadataMEGA_3.INDEX ||
|
|
| 195 |
object==MetadataMEGA_5.INDEX )
|
|
| 161 |
else if( object==CRYS_3.ordinal() ||
|
|
| 162 |
object==STAR_3.ordinal() ||
|
|
| 163 |
object==PENT_2.ordinal() ||
|
|
| 164 |
object==KILO_3.ordinal() ||
|
|
| 165 |
object==KILO_5.ordinal() ||
|
|
| 166 |
object==MEGA_3.ordinal() ||
|
|
| 167 |
object==MEGA_5.ordinal() )
|
|
| 196 | 168 |
{
|
| 197 | 169 |
mNumColors = ShapeDodecahedron.NUM_FACES; |
| 198 | 170 |
mFaceColors = ShapeDodecahedron.FACE_COLORS; |
| 199 | 171 |
} |
| 200 |
else if( object==MetadataBALL_4.INDEX )
|
|
| 172 |
else if( object==BALL_4.ordinal() )
|
|
| 201 | 173 |
{
|
| 202 | 174 |
mNumColors = ShapeDiamond.NUM_FACES; |
| 203 | 175 |
mFaceColors = ShapeDiamond.FACE_COLORS; |
| 204 | 176 |
} |
| 205 |
else if( object==MetadataICOS_2.INDEX )
|
|
| 177 |
else if( object==ICOS_2.ordinal() )
|
|
| 206 | 178 |
{
|
| 207 | 179 |
mNumColors = ShapeIcosahedron.NUM_FACES; |
| 208 | 180 |
mFaceColors = ShapeIcosahedron.FACE_COLORS; |
| 209 | 181 |
} |
| 210 |
else if( object==MetadataDIN4_3.INDEX )
|
|
| 182 |
else if( object==DIN4_3.ordinal() )
|
|
| 211 | 183 |
{
|
| 212 | 184 |
mNumColors = 4; |
| 213 | 185 |
mFaceColors = new int[] { ShapeColors.COLOR_YELLOW, ShapeColors.COLOR_RED, ShapeColors.COLOR_BLUE, ShapeColors.COLOR_WHITE};
|
| src/main/java/org/distorted/solverui/SolverActivity.java | ||
|---|---|---|
| 62 | 62 |
Bundle b = getIntent().getExtras(); |
| 63 | 63 |
mObjectOrdinal = b!=null ? b.getInt("obj") : 0;
|
| 64 | 64 |
RubikObject object = RubikObjectList.getObject(mObjectOrdinal); |
| 65 |
int objectIndex = object==null ? -1 : object.getIndex(); |
|
| 66 |
mSolverOrdinal = SolvingList.getSolverOrdinal(objectIndex); |
|
| 65 |
mSolverOrdinal = object==null ? -1 : object.getSolverOrdinal(); |
|
| 67 | 66 |
mDisplayMessageDialog = true; |
| 68 | 67 |
|
| 69 | 68 |
computeScreenDimensions(); |
Also available in: Unified diff
Restructuring for the solvers in the app.