public bool Equals(Cube cube) { return( LeftFace.Equals(cube.LeftFace) && RightFace.Equals(cube.RightFace) && FrontFace.Equals(cube.FrontFace) && RearFace.Equals(cube.RearFace) && UpperFace.Equals(cube.UpperFace) && BottomFace.Equals(cube.BottomFace) ); }
public Cube Copy() { return(new Cube { LeftFace = LeftFace.Copy(), RightFace = RightFace.Copy(), FrontFace = FrontFace.Copy(), RearFace = RearFace.Copy(), UpperFace = UpperFace.Copy(), BottomFace = BottomFace.Copy() }); }
public void Init() { //initial values, no state given FrontFace.Init(CubeValue.Front); BackFace.Init(CubeValue.Back); UpFace.Init(CubeValue.Up); DownFace.Init(CubeValue.Down); LeftFace.Init(CubeValue.Left); RightFace.Init(CubeValue.Right); return; }
private void Validate() { RubixCubeFaceValidationResult validation = new RubixCubeFaceValidationResult(); FrontFace.Validate(validation); TopFace.Validate(validation); LeftFace.Validate(validation); RightFace.Validate(validation); BottomFace.Validate(validation); BackFace.Validate(validation); ValidateIdenticalCubes(validation); validation.FinishValidation(); }
public void RotateBottomFaceToFrontFace() { RubixCubeFrontFace newFrontFace = BottomFace.MoveToFront(); RubixCubeTopFace newTopFace = FrontFace.MoveToTop(); RubixCubeLeftFace newLeftFace = LeftFace.RotateClockwise(); RubixCubeRightFace newRightFace = RightFace.RotateClockwise(); RubixCubeBottomFace newBottomFace = BackFace.MoveToBottom(); RubixCubeBackFace newBackFace = TopFace.MoveToBack(); FrontFace = newFrontFace; TopFace = newTopFace; LeftFace = newLeftFace; RightFace = newRightFace; BottomFace = newBottomFace; BackFace = newBackFace; Validate(); }
public void RotateLeftFaceAnticlockwise() { RotateLeftFace(LeftFace.RotateAnticlockwise()); }
public void RotateLeftFaceClockwise() { RotateLeftFace(LeftFace.RotateClockwise()); }
public void DoMove(CubeMove move) { int i, j; CubeFace endFace = null; CubeValue planeValue = CubeValue.None; int z = Math.Abs(move.Level - faceMax); switch (move.Plane) { case CubePlane.X: //save before move if (move.Level == 0) { endFace = LeftFace; } else if (move.Level == faceMax) { endFace = RightFace; } for (i = 0; i < cubeSize; i++) { j = Math.Abs(i - faceMax); planeValue = FrontFace.GetFaceValue(move.Level, i); //do plane move if (move.Direction == CubeMoveDirection.Right) { FrontFace.SetFaceValue(move.Level, i, UpFace.GetFaceValue(move.Level, i)); UpFace.SetFaceValue(move.Level, i, BackFace.GetFaceValue(move.Level, j)); BackFace.SetFaceValue(move.Level, j, DownFace.GetFaceValue(move.Level, j)); DownFace.SetFaceValue(move.Level, j, planeValue); } else { FrontFace.SetFaceValue(move.Level, i, DownFace.GetFaceValue(move.Level, j)); DownFace.SetFaceValue(move.Level, j, BackFace.GetFaceValue(move.Level, j)); BackFace.SetFaceValue(move.Level, j, UpFace.GetFaceValue(move.Level, i)); UpFace.SetFaceValue(move.Level, i, planeValue); } //do face move maybe DoFaceMove(endFace, move.Direction, i, j); } break; case CubePlane.Y: //save before move if (move.Level == 0) { endFace = FrontFace; } else if (move.Level == faceMax) { endFace = BackFace; } for (i = 0; i < cubeSize; i++) { j = Math.Abs(i - faceMax); planeValue = LeftFace.GetFaceValue(z, i); //do plane move if (move.Direction == CubeMoveDirection.Right) { LeftFace.SetFaceValue(z, i, DownFace.GetFaceValue(j, move.Level)); DownFace.SetFaceValue(j, move.Level, RightFace.GetFaceValue(z, j)); RightFace.SetFaceValue(z, j, UpFace.GetFaceValue(i, move.Level)); UpFace.SetFaceValue(i, move.Level, planeValue); } else { LeftFace.SetFaceValue(z, i, UpFace.GetFaceValue(i, move.Level)); UpFace.SetFaceValue(i, move.Level, RightFace.GetFaceValue(z, j)); RightFace.SetFaceValue(z, j, DownFace.GetFaceValue(j, move.Level)); DownFace.SetFaceValue(j, move.Level, planeValue); } //do face move maybe DoFaceMove(endFace, move.Direction, i, j); } break; case CubePlane.Z: //save before move if (move.Level == 0) { endFace = DownFace; } else if (move.Level == faceMax) { endFace = UpFace; } for (i = 0; i < cubeSize; i++) { j = Math.Abs(i - faceMax); planeValue = FrontFace.GetFaceValue(i, move.Level); //do plane move if (move.Direction == CubeMoveDirection.Right) { FrontFace.SetFaceValue(i, move.Level, RightFace.GetFaceValue(j, move.Level)); RightFace.SetFaceValue(j, move.Level, BackFace.GetFaceValue(j, move.Level)); BackFace.SetFaceValue(j, move.Level, LeftFace.GetFaceValue(i, move.Level)); LeftFace.SetFaceValue(i, move.Level, planeValue); } else { FrontFace.SetFaceValue(i, move.Level, LeftFace.GetFaceValue(i, move.Level)); LeftFace.SetFaceValue(i, move.Level, BackFace.GetFaceValue(j, move.Level)); BackFace.SetFaceValue(j, move.Level, RightFace.GetFaceValue(j, move.Level)); RightFace.SetFaceValue(j, move.Level, planeValue); } //do face move maybe DoFaceMove(endFace, move.Direction, i, j); } break; } }