From 17862fc8a29d5bbd5f0742af67964cb17947bd52 Mon Sep 17 00:00:00 2001 From: bionic85 <144353436+bionic85@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:19:40 +0100 Subject: [PATCH] snelle push --- PuzzlePlayer/Maze.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/PuzzlePlayer/Maze.cs b/PuzzlePlayer/Maze.cs index 7d0b0ef..de9e46f 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)); -- GitLab