Revision 20931cf6
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/objects/RubikCube.java | ||
|---|---|---|
| 228 | 228 |
|
| 229 | 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 230 | 230 |
|
| 231 |
public String retString() |
|
| 231 |
public String retObjectString()
|
|
| 232 | 232 |
{
|
| 233 | 233 |
String ret="UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB"; |
| 234 | 234 |
/* |
| src/main/java/org/distorted/objects/RubikObject.java | ||
|---|---|---|
| 567 | 567 |
return mList; |
| 568 | 568 |
} |
| 569 | 569 |
|
| 570 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 571 |
|
|
| 572 |
public String retObjectString() |
|
| 573 |
{
|
|
| 574 |
return retString(); |
|
| 575 |
} |
|
| 576 |
|
|
| 577 | 570 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 578 | 571 |
|
| 579 | 572 |
abstract float getScreenRatio(); |
| ... | ... | |
| 581 | 574 |
abstract Static3D[] getCubitPositions(int size); |
| 582 | 575 |
abstract float[] getLegalQuats(); |
| 583 | 576 |
abstract int getNumFaces(); |
| 584 |
abstract String retString(); |
|
| 585 | 577 |
abstract MeshBase createCubitMesh(int cubit, int vertices); |
| 586 | 578 |
abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side); |
| 587 | 579 |
public abstract Static3D[] getRotationAxis(); |
| 588 | 580 |
public abstract int getBasicAngle(); |
| 589 | 581 |
public abstract float returnMultiplier(); |
| 590 | 582 |
public abstract float returnRotationFactor(float offset); |
| 583 |
public abstract String retObjectString(); |
|
| 591 | 584 |
} |
| src/main/java/org/distorted/objects/RubikObjectList.java | ||
|---|---|---|
| 25 | 25 |
import org.distorted.library.type.Static4D; |
| 26 | 26 |
import org.distorted.main.R; |
| 27 | 27 |
|
| 28 |
import java.lang.reflect.Field; |
|
| 29 |
|
|
| 28 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | 31 |
|
| 30 | 32 |
public enum RubikObjectList |
| ... | ... | |
| 36 | 38 |
{4 , R.drawable.cube4} ,
|
| 37 | 39 |
{5 , R.drawable.cube5}
|
| 38 | 40 |
}, |
| 41 |
RubikCube.class, |
|
| 39 | 42 |
new RubikCubeMovement() |
| 40 | 43 |
), |
| 41 | 44 |
|
| ... | ... | |
| 45 | 48 |
{4 , R.drawable.pyra4} ,
|
| 46 | 49 |
{5 , R.drawable.pyra5}
|
| 47 | 50 |
}, |
| 51 |
RubikPyraminx.class, |
|
| 48 | 52 |
new RubikPyraminxMovement() |
| 49 | 53 |
), |
| 50 | 54 |
; |
| ... | ... | |
| 53 | 57 |
public static final int MAX_SIZE; |
| 54 | 58 |
|
| 55 | 59 |
private final int[] mObjectSizes, mIconIDs; |
| 56 |
final RubikObjectMovement mObjectMovementClass; |
|
| 60 |
private final Class<? extends RubikObject> mObjectClass; |
|
| 61 |
private final RubikObjectMovement mObjectMovementClass; |
|
| 57 | 62 |
private static final RubikObjectList[] objects; |
| 58 | 63 |
private static int mNumAll; |
| 59 | 64 |
|
| ... | ... | |
| 213 | 218 |
|
| 214 | 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 215 | 220 |
|
| 216 |
RubikObjectList(int[][] info, RubikObjectMovement movement) |
|
| 221 |
public static int[] retFaceColors(RubikObjectList object) |
|
| 222 |
{
|
|
| 223 |
Field field; |
|
| 224 |
int[] faceColors=null; |
|
| 225 |
|
|
| 226 |
try |
|
| 227 |
{
|
|
| 228 |
field = object.mObjectClass.getDeclaredField("FACE_COLORS");
|
|
| 229 |
field.setAccessible(true); |
|
| 230 |
Object obj = field.get(null); |
|
| 231 |
faceColors = (int[]) obj; |
|
| 232 |
} |
|
| 233 |
catch(NoSuchFieldException ex) |
|
| 234 |
{
|
|
| 235 |
android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": no such field exception getting field: "+ex.getMessage());
|
|
| 236 |
} |
|
| 237 |
catch(IllegalAccessException ex) |
|
| 238 |
{
|
|
| 239 |
android.util.Log.e("RubikObjectList", object.mObjectClass.getSimpleName()+": illegal access exception getting field: "+ex.getMessage());
|
|
| 240 |
} |
|
| 241 |
|
|
| 242 |
return faceColors; |
|
| 243 |
} |
|
| 244 |
|
|
| 245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 246 |
|
|
| 247 |
RubikObjectList(int[][] info, Class<? extends RubikObject> object , RubikObjectMovement movement) |
|
| 217 | 248 |
{
|
| 218 | 249 |
int length = info.length; |
| 219 | 250 |
|
| ... | ... | |
| 226 | 257 |
mIconIDs[i] = info[i][1]; |
| 227 | 258 |
} |
| 228 | 259 |
|
| 260 |
mObjectClass = object; |
|
| 229 | 261 |
mObjectMovementClass = movement; |
| 230 | 262 |
} |
| 231 | 263 |
|
| src/main/java/org/distorted/objects/RubikPyraminx.java | ||
|---|---|---|
| 323 | 323 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 324 | 324 |
// TODO |
| 325 | 325 |
|
| 326 |
public String retString() |
|
| 326 |
public String retObjectString()
|
|
| 327 | 327 |
{
|
| 328 | 328 |
return ""; |
| 329 | 329 |
} |
| src/main/java/org/distorted/states/RubikStateSolver.java | ||
|---|---|---|
| 78 | 78 |
RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass(); |
| 79 | 79 |
play.setObjectAndSize(RubikObjectList.CUBE,3); |
| 80 | 80 |
|
| 81 |
int[] colors = RubikObjectList.retFaceColors(RubikObjectList.CUBE); |
|
| 82 |
|
|
| 83 |
if( colors != null ) |
|
| 84 |
{
|
|
| 85 |
int len = colors.length; |
|
| 86 |
|
|
| 87 |
android.util.Log.e("solver", "retColors len="+len+" first: "+colors[0]);
|
|
| 88 |
} |
|
| 89 |
else |
|
| 90 |
{
|
|
| 91 |
android.util.Log.e("solver", "retColors null");
|
|
| 92 |
} |
|
| 93 |
|
|
| 81 | 94 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
| 82 | 95 |
final float scale = metrics.density; |
| 83 | 96 |
|
Also available in: Unified diff
Progress making the Solver state more abstract.