CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.rubik.solver
Class Cube

java.lang.Object
  extended by ch.randelshofer.rubik.solver.Cube
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
KociembaCube

public class Cube
extends java.lang.Object
implements java.lang.Cloneable

A cube model containing basic cube definitions and cube operations. Applying a move maintains the proper cube permutation and orientation for each cubie. This class is designed to be subclassed in order to extend it to a specific type of cube useful for a particular solution method.

"x" denotes the chief facelets of cubicles. Cube faces not shown are symmetrical to the opposing face.

                              ____ ____ ____
                            /_x_ /_x_ /_x_ /|
                          /_x_ /_U_ /_x_ /| |
                        / x  / x  / x  /| |/|
                        ---- ---- ----  |/|x|
                       |    |    |    |/|R|/|
                        ---- ---- ---- x|/| |
                       |    | F  |    |/| |/
                        ---- ---- ----  |/
                       |    |    |    |/
                        ---- ---- ----
 
An edge cubie is sane if its chief facelet aligns with the chief facelet of its current cubicle, otherwise it is flipped (MetaMagical Themas - Hofstadter).

The orientation of a corner cubie can be determined by the number of 120 degree counter-clockwise twists required to align its chief facelet into a position that is parallel to the chief facelet of its home cubicle (August/September cube.lovers - Vanderschel/Saxe)

This class has been derived from cube.cpp and cube.h from the 'Kociemba Cube Solver 1.0' (KCube) (c) Greg Schmidt.

Version:
0.0 2000-07-01
Author:
Werner Randelshofer, Hausmatt 10, CH-6045 Immensee, Switzerland

Field Summary
static int ANTI_QUARK
           
static int B
           
static int B2
           
static int BD
           
static int BDR
           
static int BI
           
static int BL
           
static int BLD
           
static int BR
           
static int BRU
           
static int BU
           
static int BUL
           
protected  int[] cornerCubieOrientations
           
protected  int[] cornerCubiePermutations
          The cubies.
static int D
           
static int D2
           
static int DB
           
static int DBL
           
static int DF
           
static int DFR
           
static int DI
           
static int DL
           
static int DLF
           
static int DR
           
static int DRB
           
protected  int[] edgeCubieOrientations
           
protected  int[] edgeCubiePermutations
           
static int F
           
static int F2
           
static int FD
           
static int FDL
           
static int FI
           
static int FIRST_CORNER_CUBIE
           
static int FIRST_EDGE_CUBIE
           
static int FIRST_MIDDLE_SLICE_EDGE_CUBIE
           
static int FIRST_MOVE
           
static int FL
           
static int FLIPPED
           
static int FLU
           
static int FR
           
static int FRD
           
static int FU
           
static int FUR
           
static int INVALID_CUBIE
           
static int INVALID_MOVE
           
static int L
           
static int L2
           
static int LAST_CORNER_CUBIE
           
static int LAST_EDGE_CUBIE
           
static int LAST_MIDDLE_SLICE_EDGE_CUBIE
           
static int LAST_MOVE
           
static int LB
           
static int LBU
           
static int LD
           
static int LDB
           
static int LF
           
static int LFD
           
static int LI
           
static int LU
           
static int LUB
           
static int NO_QUARK
           
static int NOT_FLIPPED
           
static int NUMBER_OF_CLOCKWISE_QUARTER_TURN_MOVES
           
static int NUMBER_OF_CORNER_CUBIES
           
static int NUMBER_OF_EDGE_CUBIES
           
static int NUMBER_OF_MOVES
           
static int NUMBER_OF_TWISTS
           
static int QUARK
           
static int R
           
static int R2
           
static int RB
           
static int RBD
           
static int RD
           
static int RDF
           
static int RF
           
static int RFU
           
static int RI
           
static int RU
           
static int RUB
           
static int U
           
static int U2
           
static int UB
           
static int UBR
           
static int UF
           
static int UFL
           
static int UI
           
static int UL
           
static int ULB
           
static int UR
           
static int URF
           
 
Constructor Summary
Cube()
          Default constructor.
 
Method Summary
 void applyMove(int move)
          Apply move.
 void backToHome()
          Reset cube back to HOME position.
protected  void clockwiseTwist(int cornerCubie)
          Corner cubie twists.
 java.lang.Object clone()
          Clones the cube.
protected  void counterClockwiseTwist(int cornerCubie)
           
protected  void cycleFour(int[] vector, int first, int second, int third, int fourth)
          Cycle four vector elements.
 void dump()
          Dump cube state.
 boolean equals(Cube cube)
          Overloaded equality test method.
 boolean equals(java.lang.Object o)
          Overriden equality test method.
protected  void flip(int edgeCubie)
          Flip an edge cubie.
protected  void fourCycleCorner(int first, int second, int third, int fourth)
          Cycle four corner cubies.
protected  void fourCycleEdge(int first, int second, int third, int fourth)
          Cycle four edge cubies.
 int hashCode()
          Overriden hashCode method.
static int inverseOfMove(int move)
          Get inverse of move.
protected  void moveB()
           
protected  void moveB2()
           
protected  void moveBI()
           
protected  void moveD()
           
protected  void moveD2()
           
protected  void moveDI()
           
protected  void moveF()
           
protected  void moveF2()
           
protected  void moveFI()
           
protected  void moveL()
           
protected  void moveL2()
           
protected  void moveLI()
           
static int moveNameToMove(java.lang.String moveName)
          Get the move from the move name.
protected  void moveR()
           
protected  void moveR2()
           
protected  void moveRI()
           
protected  void moveU()
           
protected  void moveU2()
           
protected  void moveUI()
           
static java.lang.String nameOfMove(int move)
          Get the name of a move.
static int opposingFace(int move)
          Get opposite face of a move.
static int quarterTurnToHalfTurnMove(int move)
          Turns a quarter turn move to a half turn move (e.g.
 void setState(int[] cornerPermutation, int[] cornerOrientation, int[] edgePermutation, int[] edgeOrientation)
          Set state from permutation and orientation vectors
static Move symbolOfMove(int move)
          Get the ScriptParser twist from a move.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UF

public static final int UF
See Also:
Constant Field Values

UL

public static final int UL
See Also:
Constant Field Values

UB

public static final int UB
See Also:
Constant Field Values

UR

public static final int UR
See Also:
Constant Field Values

FU

public static final int FU
See Also:
Constant Field Values

LU

public static final int LU
See Also:
Constant Field Values

BU

public static final int BU
See Also:
Constant Field Values

RU

public static final int RU
See Also:
Constant Field Values

DF

public static final int DF
See Also:
Constant Field Values

DL

public static final int DL
See Also:
Constant Field Values

DB

public static final int DB
See Also:
Constant Field Values

DR

public static final int DR
See Also:
Constant Field Values

FD

public static final int FD
See Also:
Constant Field Values

LD

public static final int LD
See Also:
Constant Field Values

BD

public static final int BD
See Also:
Constant Field Values

RD

public static final int RD
See Also:
Constant Field Values

RF

public static final int RF
See Also:
Constant Field Values

FL

public static final int FL
See Also:
Constant Field Values

LB

public static final int LB
See Also:
Constant Field Values

BR

public static final int BR
See Also:
Constant Field Values

FR

public static final int FR
See Also:
Constant Field Values

LF

public static final int LF
See Also:
Constant Field Values

BL

public static final int BL
See Also:
Constant Field Values

RB

public static final int RB
See Also:
Constant Field Values

FIRST_EDGE_CUBIE

public static final int FIRST_EDGE_CUBIE
See Also:
Constant Field Values

LAST_EDGE_CUBIE

public static final int LAST_EDGE_CUBIE
See Also:
Constant Field Values

FIRST_MIDDLE_SLICE_EDGE_CUBIE

public static final int FIRST_MIDDLE_SLICE_EDGE_CUBIE
See Also:
Constant Field Values

LAST_MIDDLE_SLICE_EDGE_CUBIE

public static final int LAST_MIDDLE_SLICE_EDGE_CUBIE
See Also:
Constant Field Values

NUMBER_OF_EDGE_CUBIES

public static final int NUMBER_OF_EDGE_CUBIES
See Also:
Constant Field Values

URF

public static final int URF
See Also:
Constant Field Values

UFL

public static final int UFL
See Also:
Constant Field Values

ULB

public static final int ULB
See Also:
Constant Field Values

UBR

public static final int UBR
See Also:
Constant Field Values

RFU

public static final int RFU
See Also:
Constant Field Values

FLU

public static final int FLU
See Also:
Constant Field Values

LBU

public static final int LBU
See Also:
Constant Field Values

BRU

public static final int BRU
See Also:
Constant Field Values

FUR

public static final int FUR
See Also:
Constant Field Values

LUB

public static final int LUB
See Also:
Constant Field Values

BUL

public static final int BUL
See Also:
Constant Field Values

RUB

public static final int RUB
See Also:
Constant Field Values

DFR

public static final int DFR
See Also:
Constant Field Values

DLF

public static final int DLF
See Also:
Constant Field Values

DBL

public static final int DBL
See Also:
Constant Field Values

DRB

public static final int DRB
See Also:
Constant Field Values

FRD

public static final int FRD
See Also:
Constant Field Values

LFD

public static final int LFD
See Also:
Constant Field Values

BLD

public static final int BLD
See Also:
Constant Field Values

RBD

public static final int RBD
See Also:
Constant Field Values

RDF

public static final int RDF
See Also:
Constant Field Values

FDL

public static final int FDL
See Also:
Constant Field Values

LDB

public static final int LDB
See Also:
Constant Field Values

BDR

public static final int BDR
See Also:
Constant Field Values

FIRST_CORNER_CUBIE

public static final int FIRST_CORNER_CUBIE
See Also:
Constant Field Values

LAST_CORNER_CUBIE

public static final int LAST_CORNER_CUBIE
See Also:
Constant Field Values

NUMBER_OF_CORNER_CUBIES

public static final int NUMBER_OF_CORNER_CUBIES
See Also:
Constant Field Values

INVALID_CUBIE

public static final int INVALID_CUBIE
See Also:
Constant Field Values

NO_QUARK

public static final int NO_QUARK
See Also:
Constant Field Values

QUARK

public static final int QUARK
See Also:
Constant Field Values

ANTI_QUARK

public static final int ANTI_QUARK
See Also:
Constant Field Values

NUMBER_OF_TWISTS

public static final int NUMBER_OF_TWISTS
See Also:
Constant Field Values

NOT_FLIPPED

public static final int NOT_FLIPPED
See Also:
Constant Field Values

FLIPPED

public static final int FLIPPED
See Also:
Constant Field Values

R

public static final int R
See Also:
Constant Field Values

L

public static final int L
See Also:
Constant Field Values

U

public static final int U
See Also:
Constant Field Values

D

public static final int D
See Also:
Constant Field Values

F

public static final int F
See Also:
Constant Field Values

B

public static final int B
See Also:
Constant Field Values

RI

public static final int RI
See Also:
Constant Field Values

LI

public static final int LI
See Also:
Constant Field Values

UI

public static final int UI
See Also:
Constant Field Values

DI

public static final int DI
See Also:
Constant Field Values

FI

public static final int FI
See Also:
Constant Field Values

BI

public static final int BI
See Also:
Constant Field Values

R2

public static final int R2
See Also:
Constant Field Values

L2

public static final int L2
See Also:
Constant Field Values

U2

public static final int U2
See Also:
Constant Field Values

D2

public static final int D2
See Also:
Constant Field Values

F2

public static final int F2
See Also:
Constant Field Values

B2

public static final int B2
See Also:
Constant Field Values

FIRST_MOVE

public static final int FIRST_MOVE
See Also:
Constant Field Values

LAST_MOVE

public static final int LAST_MOVE
See Also:
Constant Field Values

NUMBER_OF_CLOCKWISE_QUARTER_TURN_MOVES

public static final int NUMBER_OF_CLOCKWISE_QUARTER_TURN_MOVES
See Also:
Constant Field Values

NUMBER_OF_MOVES

public static final int NUMBER_OF_MOVES
See Also:
Constant Field Values

INVALID_MOVE

public static final int INVALID_MOVE
See Also:
Constant Field Values

cornerCubiePermutations

protected int[] cornerCubiePermutations
The cubies.


cornerCubieOrientations

protected int[] cornerCubieOrientations

edgeCubiePermutations

protected int[] edgeCubiePermutations

edgeCubieOrientations

protected int[] edgeCubieOrientations
Constructor Detail

Cube

public Cube()
Default constructor.

Method Detail

equals

public boolean equals(java.lang.Object o)
Overriden equality test method.

Overrides:
equals in class java.lang.Object

equals

public boolean equals(Cube cube)
Overloaded equality test method.


hashCode

public int hashCode()
Overriden hashCode method.

Overrides:
hashCode in class java.lang.Object

backToHome

public void backToHome()
Reset cube back to HOME position.


setState

public void setState(int[] cornerPermutation,
                     int[] cornerOrientation,
                     int[] edgePermutation,
                     int[] edgeOrientation)
Set state from permutation and orientation vectors


applyMove

public void applyMove(int move)
Apply move.


inverseOfMove

public static int inverseOfMove(int move)
Get inverse of move.


quarterTurnToHalfTurnMove

public static int quarterTurnToHalfTurnMove(int move)
Turns a quarter turn move to a half turn move (e.g. R and Ri become R2).


opposingFace

public static int opposingFace(int move)
Get opposite face of a move.


nameOfMove

public static java.lang.String nameOfMove(int move)
Get the name of a move.


moveNameToMove

public static int moveNameToMove(java.lang.String moveName)
Get the move from the move name.


symbolOfMove

public static Move symbolOfMove(int move)
Get the ScriptParser twist from a move.

See Also:
ScriptParser

dump

public void dump()
Dump cube state.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

moveR

protected void moveR()

moveL

protected void moveL()

moveU

protected void moveU()

moveD

protected void moveD()

moveF

protected void moveF()

moveB

protected void moveB()

moveRI

protected void moveRI()

moveLI

protected void moveLI()

moveUI

protected void moveUI()

moveDI

protected void moveDI()

moveFI

protected void moveFI()

moveBI

protected void moveBI()

moveR2

protected void moveR2()

moveL2

protected void moveL2()

moveU2

protected void moveU2()

moveD2

protected void moveD2()

moveF2

protected void moveF2()

moveB2

protected void moveB2()

fourCycleEdge

protected void fourCycleEdge(int first,
                             int second,
                             int third,
                             int fourth)
Cycle four edge cubies.


fourCycleCorner

protected void fourCycleCorner(int first,
                               int second,
                               int third,
                               int fourth)
Cycle four corner cubies.


cycleFour

protected void cycleFour(int[] vector,
                         int first,
                         int second,
                         int third,
                         int fourth)
Cycle four vector elements.


flip

protected void flip(int edgeCubie)
Flip an edge cubie.


clockwiseTwist

protected void clockwiseTwist(int cornerCubie)
Corner cubie twists.


counterClockwiseTwist

protected void counterClockwiseTwist(int cornerCubie)

clone

public java.lang.Object clone()
Clones the cube.

Overrides:
clone in class java.lang.Object

(c) Werner Randelshofer.
All rights reserved.