Revision 0c2d3013
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/solvers/SolverPyraminx.java | ||
|---|---|---|
| 48 | 48 |
|
| 49 | 49 |
private TablebasesAbstract mSolver; |
| 50 | 50 |
private int[] mCornerTwist; |
| 51 |
private int[] mFaceColors; |
|
| 51 | 52 |
|
| 52 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 53 | 54 |
|
| ... | ... | |
| 354 | 355 |
int result2 = checkAllVerticesPresent(vertices); |
| 355 | 356 |
if( result2<0 ) return result2; |
| 356 | 357 |
|
| 357 |
int[] faces1 = computeFaceColors(corners);
|
|
| 358 |
int[] faces2 = computeFaceColors(vertices);
|
|
| 358 |
int[] facesC = computeFaceColors(corners);
|
|
| 359 |
int[] facesV = computeFaceColors(vertices);
|
|
| 359 | 360 |
|
| 360 |
int result3 = checkAgreement(faces1,faces2);
|
|
| 361 |
int result3 = checkAgreement(facesC,facesV);
|
|
| 361 | 362 |
if( result3<0 ) return result3; |
| 362 | 363 |
|
| 363 |
int[][] edgeColors = computeEdgeColors(faces1); |
|
| 364 |
mFaceColors = facesC; |
|
| 365 |
|
|
| 366 |
int[][] edgeColors = computeEdgeColors(mFaceColors); |
|
| 364 | 367 |
|
| 365 | 368 |
getEdges(object,edges); |
| 366 | 369 |
int result4 = checkAllEdgesPresent(edges,edgeColors); |
| ... | ... | |
| 368 | 371 |
|
| 369 | 372 |
for(int i=0; i<4; i++) |
| 370 | 373 |
{
|
| 371 |
mCornerTwist[i] = computePieceTwist(i,corners[i],faces1);
|
|
| 374 |
mCornerTwist[i] = computePieceTwist(i,corners[i],mFaceColors);
|
|
| 372 | 375 |
if( mCornerTwist[i]<0 ) return ERROR_CORNERS_CANNOT; |
| 373 | 376 |
} |
| 374 | 377 |
|
| 375 | 378 |
for(int i=0; i<4; i++) |
| 376 | 379 |
{
|
| 377 |
vertex_twist[i] = computePieceTwist(i,vertices[i],faces1);
|
|
| 380 |
vertex_twist[i] = computePieceTwist(i,vertices[i],mFaceColors);
|
|
| 378 | 381 |
if( vertex_twist[i]<0 ) return ERROR_VERTICES_CANNOT; |
| 379 | 382 |
} |
| 380 | 383 |
|
| ... | ... | |
| 429 | 432 |
|
| 430 | 433 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 431 | 434 |
|
| 432 |
private int getColorIndex6(int color)
|
|
| 435 |
private int getFaceIndex3(int face)
|
|
| 433 | 436 |
{
|
| 434 |
switch(color) |
|
| 437 |
switch(mFaceColors[face]) |
|
| 438 |
{
|
|
| 439 |
case 0: return R.string.color_green3; |
|
| 440 |
case 1: return R.string.color_yellow3; |
|
| 441 |
case 2: return R.string.color_blue3; |
|
| 442 |
case 3: return R.string.color_red3; |
|
| 443 |
} |
|
| 444 |
|
|
| 445 |
return -1; |
|
| 446 |
} |
|
| 447 |
|
|
| 448 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 449 |
|
|
| 450 |
private int getFaceIndex6(int face) |
|
| 451 |
{
|
|
| 452 |
switch(mFaceColors[face]) |
|
| 435 | 453 |
{
|
| 436 | 454 |
case 0: return R.string.color_green6; |
| 437 | 455 |
case 1: return R.string.color_yellow6; |
| ... | ... | |
| 476 | 494 |
|
| 477 | 495 |
private String edgeError(Resources res, int color0, int color1) |
| 478 | 496 |
{
|
| 479 |
int j0 = getColorIndex3(color0);
|
|
| 480 |
int j1 = getColorIndex6(color1);
|
|
| 497 |
int j0 = getFaceIndex3(color0);
|
|
| 498 |
int j1 = getFaceIndex6(color1);
|
|
| 481 | 499 |
|
| 482 | 500 |
String c0 = res.getString(j0); |
| 483 | 501 |
String c1 = res.getString(j1); |
| ... | ... | |
| 500 | 518 |
case ERROR_VERTEX_GYR_MISSING: return vertexError(res,3,1,0); |
| 501 | 519 |
case ERROR_VERTEX_GYB_MISSING: return vertexError(res,2,1,0); |
| 502 | 520 |
case ERROR_EDGE_RB_MISSING : return edgeError(res,3,2); |
| 503 |
case ERROR_EDGE_RY_MISSING : return edgeError(res,3,1);
|
|
| 504 |
case ERROR_EDGE_RG_MISSING : return edgeError(res,3,0);
|
|
| 505 |
case ERROR_EDGE_YB_MISSING : return edgeError(res,2,1);
|
|
| 506 |
case ERROR_EDGE_GB_MISSING : return edgeError(res,2,0);
|
|
| 521 |
case ERROR_EDGE_RY_MISSING : return edgeError(res,2,0);
|
|
| 522 |
case ERROR_EDGE_RG_MISSING : return edgeError(res,2,1);
|
|
| 523 |
case ERROR_EDGE_YB_MISSING : return edgeError(res,3,0);
|
|
| 524 |
case ERROR_EDGE_GB_MISSING : return edgeError(res,3,1);
|
|
| 507 | 525 |
case ERROR_EDGE_GY_MISSING : return edgeError(res,1,0); |
| 508 | 526 |
case ERROR_EDGE_TWISTED : return res.getString(R.string.solver_generic_edge_twist); |
| 509 | 527 |
case ERROR_CORNERS_CANNOT : return res.getString(R.string.solver_generic_corners_cannot); |
Also available in: Unified diff
Pyraminx Solver: correct detection of missing edge colors.