예제 #1
0
        /// <summary>
        /// A public constructor for the maze class 
        /// </summary>
        /// <param name="matrixRows"> Number of rows in a maze matrix </param>
        /// <param name="matrixCols"> Number of columns in a maze matrix </param>
        public Maze(int matrixRows, int matrixCols)
        {
            if (matrixRows % 2 != 0 || matrixCols % 2 != 0)
                throw new ArgumentException("Public Maze constructor argument exception: Rows and columns cannot be odd numbers.");

            graphRows = matrixRows / 2;
            graphCols = matrixCols / 2;

            GridGraph graph = new GridGraph(matrixRows / 2, matrixCols / 2);
            GridGraph mazeInverted = graph.PrimsAlgorithm();
            Graph = mazeInverted.ComplementaryGraph();

            this.matrixRows = matrixRows - 1;
            this.matrixCols = matrixCols - 1;

            matrix = mazeInverted.CreateWallMatrix();
        }