diff --git a/PuzzlePlayer/Maze.cs b/PuzzlePlayer/Maze.cs index 7d0b0efd251708c4487b84dbc9c1e62eff5085c0..de9e46ff48a95827b7cf1618c47c4d6b3247213f 100644 --- a/PuzzlePlayer/Maze.cs +++ b/PuzzlePlayer/Maze.cs @@ -1,14 +1,8 @@ using System; -using System.Buffers.Binary; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; -using System.Linq; -using System.Security.Policy; -using System.Text; -using System.Threading.Tasks; -using System.Xml.XPath; -using static System.Runtime.InteropServices.JavaScript.JSType; + namespace PuzzlePlayer_Namespace { @@ -44,9 +38,7 @@ namespace PuzzlePlayer_Namespace public Maze(int size = 6) { // init all 2D array's - boardState = GetClearBoard(size); - mazeState = GetClearBoard(size); - visitedCells = GetClearBoard(size); + Reset(size); /* // example thingy (DELETE LATER) @@ -64,6 +56,13 @@ namespace PuzzlePlayer_Namespace */ } + private void Reset(int size) + { + boardState = GetClearBoard(size); + mazeState = GetClearBoard(size); + visitedCells = GetClearBoard(size); + } + // two funcions to go from number to walls and back private int getNumberFromWalls((bool top, bool right, bool bottom, bool left) cell) { @@ -144,8 +143,8 @@ namespace PuzzlePlayer_Namespace // https://en.wikipedia.org/wiki/Maze_generation_algorithm#Randomized_depth-first_search public override void Generate() { - // clear visitedCells - visitedCells = GetClearBoard(mazeState.GetLength(0)); + //clear the board and all 2D array's + Reset(mazeState.GetLength(0)); Random rnd = new Random(); int x = rnd.Next(mazeState.GetLength(0));