public PuzzleSlide(int depth) { puzzle = new List <Block>(); puzzle.Add(new Block()); // Start with 4 blocks AddBlock(); AddBlock(); AddBlock(); AddBlock(); PuzzleSlideSolver solve = new PuzzleSlideSolver(); int steps = 0; while (steps != depth) { steps = solve.Solve(puzzle, depth); if (steps < depth) { AddBlock(); } if (steps > depth) { RemoveBlock(); } } }
public PuzzleSlide(int depth) { puzzle = new List <Block>(); puzzle.Add(new Block()); random = new Random(); // Start with 4 blocks AddBlock(); AddBlock(); AddBlock(); AddBlock(); PuzzleSlideSolver solve = new PuzzleSlideSolver(); while (moves != depth) { //Console.WriteLine("Solving:"); //foreach (string s in FormatOutput(puzzle)) //{ // Console.WriteLine(s); //} try { moves = solve.Solve(puzzle, depth); } catch (Exception) { moves = depth + 1; } //Console.WriteLine("Solver: " + steps); if (moves < depth && moves < 7) { if (puzzle.Count > 8) { RemoveBlock(); RemoveBlock(); RemoveBlock(); } AddBlock(); } else if (moves > depth) { RemoveBlock(); } else { return; } } }