public void RandomTest() { Random random = new Random(7777777); int repetitions = 20; TimeSpan timeout = TimeSpan.FromSeconds(1); int returnLength = 18; int requiredLength = 20; for (int repetition = 0; repetition < repetitions; repetition++) { Alg scramble = Alg.FromRandomMoves(random.Next(20, 30), random); CubieCube cube = CubieCube.FromAlg(scramble); Alg solution = TwoPhaseSolver.FindSolution(cube, timeout, returnLength, requiredLength); Console.WriteLine("\nScramble: " + scramble + "\nSolution: " + solution + "\nLength: " + solution.Length); Assert.IsTrue(solution.Length <= 20); CubieCube expected = CubieCube.CreateSolved(); CubieCube result = CubieCube.CreateSolved(); result.ApplyAlg(scramble); result.ApplyAlg(solution); Assert.AreEqual(expected, result); } }
public void CreateRandomTest() { Random random = new Random(7777777); int numIterations = 50; TimeSpan timeout = TimeSpan.FromSeconds(20); for (int iteration = 0; iteration < numIterations; iteration++) { CubieCube cube = CubieCube.CreateRandom(random); int cornerPermutation = Coordinates.GetCornerPermutation(cube); int edgePermutation = Coordinates.GetEdgePermutation(cube); bool cornerParity = Coordinates.CornerPermutationParity(cornerPermutation); bool edgeParity = Coordinates.EdgePermutationParity(edgePermutation); Assert.IsTrue(cornerParity == edgeParity); Assert.IsNotNull(TwoPhaseSolver.FindSolution(cube, timeout, 30, -1)); } }
public void StaticTest(string algString) { Alg scramble = Alg.FromString(algString); CubieCube cube = CubieCube.FromAlg(scramble); TimeSpan timeout = TimeSpan.FromSeconds(1); int returnLength = 0; int requiredLength = 20; Alg solution = TwoPhaseSolver.FindSolution(cube, timeout, returnLength, requiredLength); Console.WriteLine("Scramble: " + scramble + "\nSolution: " + solution + "\nLength: " + solution.Length); Assert.IsTrue(solution.Length <= 20); CubieCube expected = CubieCube.CreateSolved(); CubieCube result = CubieCube.CreateSolved(); result.ApplyAlg(scramble); result.ApplyAlg(solution); Assert.AreEqual(expected, result); }