Example #1
0
        /// <summary>
        /// Generate mazes until one is found that has a valid path between A and B
        /// </summary>
        /// <returns>The seed of the valid maze</returns>
        private int FindWorkingSeed()
        {
            var testMazeDrawer = new MazeDrawer(pbMaze);
            var testPathFinder = new DepthFirst(testMazeDrawer.Grid);
            var progress       = testPathFinder.GetPathTick();

            while (progress.PathPossible && !progress.PathFound)
            {
                progress = testPathFinder.GetPathTick();
            }

            return(progress.PathFound ? testMazeDrawer.Seed : 0);
        }
Example #2
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            int rows = 0, cols = 0;

            int.TryParse(AppSettings.Settings["rows"], out rows);
            int.TryParse(AppSettings.Settings["cols"], out cols);
            string mazeDisplayStr = new MazeDrawer().getMazeToStr(this.maze,
                                                                  6, true, rows, cols);

            return(string.Format("Maze - name: {0}\nmaze: {1}\n"
                                 + "start: {2}\nend: {3}",
                                 this.name, mazeDisplayStr, this.start, this.end));
        }
Example #3
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            int rows = 0, cols = 0;

            int.TryParse(AppSettings.Settings["rows"], out rows);
            int.TryParse(AppSettings.Settings["cols"], out cols);
            string solDisplay = new MazeDrawer().getMazeToStr(this.sol,
                                                              13, true, rows, cols);

            return(string.Format("Solution for Maze: {0}\n"
                                 + "solution is: {1}\n"
                                 + "start: {2}\nend: {3}",
                                 this.name, solDisplay, this.start, this.end));
        }
Example #4
0
 private void newMaze(long id, int mazeSize) => mazeDrawers[id] =
     new MazeDrawer(resolution, mazeSize)
 {
     emptyFrame     = Color.Gray,
     startBorder    = Color.YellowGreen,
     startSurface   = Color.YellowGreen,
     finishBorder   = Color.DeepPink,
     finishSurface  = Color.DeepPink,
     wallBorder     = Color.DarkGreen,
     wallSurface    = Color.LightGreen,
     ceilingBorder  = Color.SteelBlue,
     ceilingSurface = Color.LightSteelBlue,
     floorBorder    = Color.DarkBlue,
     floorSurface   = Color.Blue
 };
Example #5
0
        /// <summary>
        /// Set up a maze and initialise the algorithm variables
        /// </summary>
        private void InitialiseMaze()
        {
            _pathTimer.Stop();

            // Generate mazes until one if made that has a valid path between A and B
            var workingSeed = 0;

            while (workingSeed == 0)
            {
                workingSeed = FindWorkingSeed();
            }

            // Set/reset the algorithm settings and draw the maze
            _currentAlgorithm = -1;
            _mazeDrawer       = new MazeDrawer(pbMaze, workingSeed);
            _algorithms       = new AlgorithmBase[] { new Dijkstra(_mazeDrawer.Grid), new AStar(_mazeDrawer.Grid), new BreadthFirst(_mazeDrawer.Grid), new DepthFirst(_mazeDrawer.Grid) };
            Text = @"Path Finding " + _mazeDrawer.Seed;
            _mazeDrawer.Draw();
        }
Example #6
0
    private void DrawMazeWalls()
    {
        MazeDrawer mazeDrawer = new MazeDrawer(MazeData);

        mazeDrawer.DrawMaze();
    }