public void Test_RotateBottomFaceAnticlockwise_DoesNotThrowAnException() { // Act RubixCube target = new RubixCube(); target.RotateBottomFaceAnticlockwise(); }
public void Test_RotateLeftFaceToFrontFace_DoesNotThrowAnException() { // Act RubixCube target = new RubixCube(); target.RotateLeftFaceToFrontFace(); }
public void Test_RotateRightFaceClockwise_DoesNotThrowAnException() { // Act RubixCube target = new RubixCube(); target.RotateRightFaceClockwise(); }
public void Test_Constructor_GenerateCorrectNumberOfCubesWith3Faces() { // Act RubixCube target = new RubixCube(); // Assert target.CubesWith3Faces.Count().Should().Be(RubixCube.NumebrOfCubesWith3Faces); }
public void Test_Constructor_GeneratesCorrectNumberOfCubesWith2FacesForEachCubeWith3Faces() { // Act RubixCube target = new RubixCube(); // Assert target.CubesWith3Faces.All(cube => cube.CubesWith2Faces.Count() == CubeWith3Faces.NumberOfCubesWith2Faces); }
public void RubixCubeSolver_SolvesRandomRubixCube() { var cube = new RubixCube(); cube.Randomise(); var solver = new RubixCubeSolver(cube); solver.Solve(); Assert.AreEqual(_solvedCube, cube.Cube); }
public RubixCubeBottomFaceRotation(RubixCube cube, RubixCubeBottomFace newBottomFace) { this.newBottomFace = newBottomFace; oldFrontFace = cube.FrontFace; newFrontFace = oldFrontFace.Clone(); oldLeftFace = cube.LeftFace; newLeftFace = oldLeftFace.Clone(); oldRightFace = cube.RightFace; newRightFace = oldRightFace.Clone(); oldBackFace = cube.BackFace; newBackFace = oldBackFace.Clone(); UpdateFaces(); RemoveOldCubes(); AddNewCubes(); }
public void ReorganiseMiddleEdges_FormsTheYellowCross_GivenOnlyTheCentreBlock() { var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Orange, Colour.Green, null, Colour.White, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Red, null, null, Colour.Blue, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Orange, null, Colour.Blue, Colour.White, null) } }, { { new Block(Colour.Red, null, Colour.Green, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Orange, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Red, null, null, Colour.Blue, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Orange, null, Colour.Blue, null, null) } }, { { new Block(Colour.Orange, null, Colour.Blue, null, null, Colour.Yellow), new Block(null, null, Colour.Yellow, null, null, Colour.Green), new Block(null, Colour.Yellow, Colour.Red, null, null, Colour.Blue) }, { new Block(Colour.Yellow, null, null, null, null, Colour.Blue), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Yellow, null, null, null, Colour.Red) }, { new Block(Colour.Yellow, null, null, Colour.Orange, null, Colour.Green), new Block(null, null, null, Colour.Yellow, null, Colour.Orange), new Block(null, Colour.Green, null, Colour.Yellow, null, Colour.Red) } } }); var solver = new ThirdLayerSolver(cube); solver.Solve(); Assert.That(_solvedCube, Is.EquivalentTo(cube.Cube)); }
public void ReorganiseMiddleEdges_CorrectlyPositionsTheMiddleEdges_GivenThreeIncorrectlyPositionedMiddleEdges() { var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Orange, Colour.Green, null, Colour.White, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Red, null, null, Colour.Blue, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Orange, null, Colour.Blue, Colour.White, null) } }, { { new Block(Colour.Red, null, Colour.Green, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Orange, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Red, null, null, Colour.Blue, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Orange, null, Colour.Blue, null, null) } }, { { new Block(Colour.Green, null, Colour.Orange, null, null, Colour.Yellow), new Block(null, null, Colour.Green, null, null, Colour.Yellow), new Block(null, Colour.Red, Colour.Blue, null, null, Colour.Yellow) }, { new Block(Colour.Blue, null, null, null, null, Colour.Yellow), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Red, null, null, null, Colour.Yellow) }, { new Block(Colour.Green, null, null, Colour.Red, null, Colour.Yellow), new Block(null, null, null, Colour.Orange, null, Colour.Yellow), new Block(null, Colour.Orange, null, Colour.Blue, null, Colour.Yellow) } } }); var solver = new ThirdLayerSolver(cube); solver.Solve(); Assert.That(_solvedCube, Is.EquivalentTo(cube.Cube)); }
public void CorrectCornerOrientation_ThrowsException_GivenCubeWithOneIncorrectCorner() { var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Orange, Colour.Green, null, Colour.White, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Red, null, null, Colour.Blue, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Orange, null, Colour.Blue, Colour.White, null) } }, { { new Block(Colour.Red, null, Colour.Green, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Orange, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Red, null, null, Colour.Blue, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Orange, null, Colour.Blue, null, null) } }, { { new Block(Colour.Green, null, Colour.Yellow, null, null, Colour.Red), new Block(null, null, Colour.Green, null, null, Colour.Yellow), new Block(null, Colour.Orange, Colour.Green, null, null, Colour.Yellow) }, { new Block(Colour.Red, null, null, null, null, Colour.Yellow), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Orange, null, null, null, Colour.Yellow) }, { new Block(Colour.Red, null, null, Colour.Blue, null, Colour.Yellow), new Block(null, null, null, Colour.Blue, null, Colour.Yellow), new Block(null, Colour.Orange, null, Colour.Blue, null, Colour.Yellow) } } }); var solver = new ThirdLayerSolver(cube); var ex = Assert.Throws <Exception>(solver.Solve); Assert.That(ex.Message, Is.EqualTo("Something is wrong with the Rubix Cube layout - it should not be possible to have only one incorrect corner block.")); }
public void SolveSecondLayer_IsCorrect_GivenSwitchableMiddleEdges() { var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Orange, Colour.Green, null, Colour.White, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Red, null, null, Colour.Blue, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Orange, null, Colour.Blue, Colour.White, null) } }, { { new Block(Colour.Red, null, Colour.Green, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Orange, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Red, null, null, Colour.Yellow, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Green, null, Colour.Yellow, null, null) } }, { { new Block(Colour.Orange, null, Colour.Blue, null, null, Colour.Yellow), new Block(null, null, Colour.Blue, null, null, Colour.Red), new Block(null, Colour.Blue, Colour.Yellow, null, null, Colour.Red) }, { new Block(Colour.Yellow, null, null, null, null, Colour.Orange), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Blue, null, null, null, Colour.Yellow) }, { new Block(Colour.Green, null, null, Colour.Red, null, Colour.Yellow), new Block(null, null, null, Colour.Orange, null, Colour.Blue), new Block(null, Colour.Orange, null, Colour.Yellow, null, Colour.Green) } } }); var solver = new SecondLayerSolver(cube); solver.Solve(); var thirdLayerSolver = new ThirdLayerSolver(cube); thirdLayerSolver.Solve(); Assert.That(_solvedCube, Is.EquivalentTo(cube.Cube)); }
public SecondLayerSolver(RubixCube cube) { _cube = cube; }
public RubixCubeSolver(RubixCube cube) { _cube = cube; }
public void FirstLayerSolver_CorrectlySolvesCorners_GivenCornerBetweenWrongSidesOnFront() { var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Blue, Colour.White, null, Colour.Red, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Orange, null, null, Colour.Green, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Yellow, null, Colour.Orange, Colour.Green, null) } }, { { new Block(Colour.Yellow, null, Colour.Orange, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Yellow, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Green, null, null, Colour.Orange, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Yellow, null, Colour.Red, null, null) } }, { { new Block(Colour.Green, null, Colour.Yellow, null, null, Colour.Red), new Block(null, null, Colour.Yellow, null, null, Colour.Blue), new Block(null, Colour.Orange, Colour.Blue, null, null, Colour.White) }, { new Block(Colour.Blue, null, null, null, null, Colour.Red), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Orange, null, null, null, Colour.Blue) }, { new Block(Colour.Yellow, null, null, Colour.Blue, null, Colour.Orange), new Block(null, null, null, Colour.Red, null, Colour.Green), new Block(null, Colour.Yellow, null, Colour.Blue, null, Colour.Red) } } }); var solver = new FirstLayerSolver(cube); solver.Solve(); Assert.That(RubixCubeStatusEvaluator.FirstLayerIsSolved(cube), Is.True); }
public void Setup() { cube = new RubixCube(); }
public void rubixCubeTest() { var r = new RubixCube(); Func <string, int> parse = int.Parse; var cube = @"[[0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0]]"; var actual = "[[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,5,5,5,0,0,0,0,0,0],[5,5,4,1,1,1,6,2,2,3,3,3],[5,5,4,1,1,1,6,2,2,3,3,3],[5,5,4,1,1,1,6,2,2,3,3,3],[0,0,0,2,2,2,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "U0"))); cube = @"[[0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0]]"; actual = "[[0,0,0,6,6,1,0,0,0,0,0,0],[0,0,0,6,6,1,0,0,0,0,0,0],[0,0,0,6,6,1,0,0,0,0,0,0],[5,5,5,1,1,4,2,2,2,6,3,3],[6,3,3,5,5,5,1,1,4,2,2,2],[5,5,5,1,1,4,2,2,2,6,3,3],[0,0,0,4,4,3,0,0,0,0,0,0],[0,0,0,4,4,3,0,0,0,0,0,0],[0,0,0,4,4,3,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "R0 F1"))); cube = @"[[0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0]]"; actual = "[[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,6,6,6,0,0,0,0,0,0],[1,1,1,2,2,2,3,3,3,5,5,5],[1,1,1,2,2,2,3,3,3,5,5,5],[3,3,3,5,5,5,1,1,1,2,2,2],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "Fi1 F0 B0"))); cube = @"[[0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,2,6,0,0,0,0,0,0], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,6,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0]]"; actual = "[[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,6,6,2,0,0,0,0,0,0],[0,0,0,6,6,6,0,0,0,0,0,0],[3,3,3,5,5,5,1,1,1,2,2,2],[5,5,5,1,1,1,6,2,2,3,3,3],[5,5,5,1,1,1,2,2,2,3,3,3],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "F2"))); cube = @"[[0,0,0,2,6,4,0,0,0,0,0,0], [0,0,0,6,3,5,0,0,0,0,0,0], [0,0,0,5,2,5,0,0,0,0,0,0], [1,5,4,1,4,1,6,4,3,2,1,6], [5,6,2,6,2,2,1,4,3,4,5,3], [3,6,1,2,5,2,6,3,6,5,4,4], [0,0,0,4,1,3,0,0,0,0,0,0], [0,0,0,3,1,2,0,0,0,0,0,0], [0,0,0,5,1,3,0,0,0,0,0,0]]"; actual = "[[0,0,0,1,1,5,0,0,0,0,0,0],[0,0,0,4,1,3,0,0,0,0,0,0],[0,0,0,4,2,2,0,0,0,0,0,0],[5,2,3,2,6,3,6,6,3,4,4,6],[1,4,6,5,2,4,3,6,5,1,5,2],[1,2,2,1,6,3,6,4,1,4,3,4],[0,0,0,6,1,5,0,0,0,0,0,0],[0,0,0,3,3,5,0,0,0,0,0,0],[0,0,0,2,5,5,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "F2 F2 R0 U1 D2 U2 L0 U2 U1 U0 U2 B1 B0 F2 F2 D2 F1 U0 L0"))); cube = @"[[0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [0,0,0,6,6,6,0,0,0,0,0,0], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [5,5,5,1,1,1,2,2,2,3,3,3], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0], [0,0,0,4,4,4,0,0,0,0,0,0]]"; actual = "[[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,6,6,6,0,0,0,0,0,0],[0,0,0,6,6,6,0,0,0,0,0,0],[5,5,5,1,1,1,2,2,2,3,3,3],[5,5,5,1,1,1,2,2,2,3,3,3],[5,5,5,1,1,1,2,2,2,3,3,3],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0],[0,0,0,4,4,4,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "U0 Ri0 Ui0 R0 U0 Ri0 Ui0 R0 U0 Ri0 Ui0 R0 U0 Ri0 Ui0 R0 U0 Ri0 Ui0 R0 U0 Ri0 Ui0 R0"))); cube = @"[[0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0], [5,5,5,5,5,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3], [5,5,5,5,5,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3], [5,5,5,5,5,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3], [5,5,5,5,5,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3], [5,5,5,5,5,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3], [0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0]]"; actual = "[[0,0,0,0,0,4,5,5,5,4,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,4,2,2,2,4,0,0,0,0,0,0,0,0,0,0],[3,3,3,3,1,5,6,6,6,2,1,1,1,1,3,2,6,6,6,5],[3,5,5,5,1,5,1,1,1,2,1,2,2,2,3,2,3,3,3,5],[3,5,5,5,1,5,1,1,1,2,1,2,2,2,3,2,3,3,3,5],[3,5,5,5,1,5,1,1,1,2,1,2,2,2,3,2,3,3,3,5],[3,1,1,1,1,5,4,4,4,2,1,3,3,3,3,2,4,4,4,5],[0,0,0,0,0,6,5,5,5,6,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,6,2,2,2,6,0,0,0,0,0,0,0,0,0,0]]"; Assert.AreEqual(actual, Util.JaggedArrayToString(r.rubixCube(Util.ParseJaggedArray(cube, parse), "Ri0 Li0 Fi0 Bi0 Ui0 Di0"))); }
public void CorrectCornerOrientation_SolvesCube_GivenCubeWithFourIncorrectCorners() { var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Orange, Colour.Green, null, Colour.White, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Red, null, null, Colour.Blue, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Orange, null, Colour.Blue, Colour.White, null) } }, { { new Block(Colour.Red, null, Colour.Green, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Orange, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Red, null, null, Colour.Blue, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Orange, null, Colour.Blue, null, null) } }, { { new Block(Colour.Green, null, Colour.Yellow, null, null, Colour.Red), new Block(null, null, Colour.Green, null, null, Colour.Yellow), new Block(null, Colour.Green, Colour.Yellow, null, null, Colour.Orange) }, { new Block(Colour.Red, null, null, null, null, Colour.Yellow), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Orange, null, null, null, Colour.Yellow) }, { new Block(Colour.Blue, null, null, Colour.Yellow, null, Colour.Red), new Block(null, null, null, Colour.Blue, null, Colour.Yellow), new Block(null, Colour.Blue, null, Colour.Yellow, null, Colour.Orange) } } }); var solver = new ThirdLayerSolver(cube); solver.Solve(); Assert.That(_solvedCube, Is.EquivalentTo(cube.Cube)); }
public void ReorganiseCorners_ThrowsException_GivenTwoCorrectlyPositionedCorners() { // There is no way to logically test 3 correctly positioned corners since it is impossible for all but one piece to be correct. // Two correct pieces is not possible for a valid rubix cube but it kind of makes sense that it might theoretically be possible // without looking at the actual mathematics. var cube = new RubixCube(new[, , ] { { { new Block(Colour.Red, null, Colour.Green, null, Colour.White, null), new Block(null, null, Colour.Green, null, Colour.White, null), new Block(null, Colour.Orange, Colour.Green, null, Colour.White, null) }, { new Block(Colour.Red, null, null, null, Colour.White, null), new Block(null, null, null, null, Colour.White, null), new Block(null, Colour.Orange, null, null, Colour.White, null) }, { new Block(Colour.Red, null, null, Colour.Blue, Colour.White, null), new Block(null, null, null, Colour.Blue, Colour.White, null), new Block(null, Colour.Orange, null, Colour.Blue, Colour.White, null) } }, { { new Block(Colour.Red, null, Colour.Green, null, null, null), new Block(null, null, Colour.Green, null, null, null), new Block(null, Colour.Orange, Colour.Green, null, null, null) }, { new Block(Colour.Red, null, null, null, null, null), new Block(null, null, null, null, null, null), new Block(null, Colour.Orange, null, null, null, null) }, { new Block(Colour.Red, null, null, Colour.Blue, null, null), new Block(null, null, null, Colour.Blue, null, null), new Block(null, Colour.Orange, null, Colour.Blue, null, null) } }, { { new Block(Colour.Green, null, Colour.Yellow, null, null, Colour.Orange), new Block(null, null, Colour.Green, null, null, Colour.Yellow), new Block(null, Colour.Green, Colour.Yellow, null, null, Colour.Red) }, { new Block(Colour.Red, null, null, null, null, Colour.Yellow), new Block(null, null, null, null, null, Colour.Yellow), new Block(null, Colour.Orange, null, null, null, Colour.Yellow) }, { new Block(Colour.Blue, null, null, Colour.Yellow, null, Colour.Red), new Block(null, null, null, Colour.Blue, null, Colour.Yellow), new Block(null, Colour.Blue, null, Colour.Yellow, null, Colour.Orange) } } }); var solver = new ThirdLayerSolver(cube); var ex = Assert.Throws <Exception>(solver.Solve); Assert.That(ex.Message, Is.EqualTo("Something has gone wrong. There can only be 0, 3 or 4 incorrect blocks at this stage.")); }
public ThirdLayerSolver(RubixCube cube) { _cube = cube; }
public FirstLayerSolver(RubixCube cube) { _cube = cube; }