Example #1
0
        /// <summary>
        /// Generate a Maze
        /// </summary>
        /// <param name="width">Width of the maze</param>
        /// <param name="height">Height of the maze</param>
        /// <param name="innerMapType">The type which is used to store a map</param>
        /// <param name="seed">The seed that is used to generate a maze</param>
        /// <param name="pixelChangedCallback">When a pixel is changed you can define a callback here to for example draw the maze while its being generated, add null if you don't want this. Last 2 longs are for the current step and the total steps (can be used to calculate how far the maze is done being generated)</param>
        /// <returns>A maze</returns>
        public Maze Generate(int width, int height, InnerMapType innerMapType, int seed, Action <int, int, long, long> pixelChangedCallback)
        {
            Maze maze = new Maze(width, height, innerMapType);

            GoGenerate(maze.InnerMap, maze, new Random(seed), null);
            return(maze);
        }
Example #2
0
        public Maze(int width, int height, InnerMapType innerMapType)
        {
            switch (innerMapType)
            {
            case InnerMapType.BitArreintjeFast:
                innerMap = new BitArreintjeFastInnerMap(width, height);
                break;

            case InnerMapType.BooleanArray:
                innerMap = new BooleanInnerMap(width, height);
                break;

            case InnerMapType.DotNetBitArray:
                innerMap = new DotNetBitArrayInnerMap(width, height);
                break;

            case InnerMapType.BitArrayMappedOnHardDisk:
                innerMap = new BitArrayMappedOnHardDiskInnerMap(width, height);
                break;

            case InnerMapType.Hybrid:
                innerMap = new HybridInnerMap(width, height);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Generate a Maze
        /// </summary>
        /// <param name="width">Width of the maze</param>
        /// <param name="height">Height of the maze</param>
        /// <param name="innerMapType">The type which is used to store a map</param>
        /// <param name="seed">The seed that is used to generate a maze</param>
        /// <param name="pixelChangedCallback">When a pixel is changed you can define a callback here to for example draw the maze while its being generated, add null if you don't want this. Last 2 longs are for the current step and the total steps (can be used to calculate how far the maze is done being generated)</param>
        /// <returns>A maze</returns>
        public Maze Generate(int width, int height, InnerMapType innerMapType, int seed, Action<int, int, long, long> pixelChangedCallback)
        {
            var map = GoGenerate(new FastRandom(seed), width, height);

            InnerMap innerMap = new BooleanInnerMap(width, height, map);
            var maze = new Maze(innerMap);
            return maze;
        }
Example #4
0
        /// <summary>
        /// Generate a Maze
        /// </summary>
        /// <param name="width">Width of the maze</param>
        /// <param name="height">Height of the maze</param>
        /// <param name="innerMapType">The type which is used to store a map</param>
        /// <param name="seed">The seed that is used to generate a maze</param>
        /// <param name="pixelChangedCallback">When a pixel is changed you can define a callback here to for example draw the maze while its being generated, add null if you don't want this. Last 2 longs are for the current step and the total steps (can be used to calculate how far the maze is done being generated)</param>
        /// <returns>A maze</returns>
        public Maze Generate(int width, int height, InnerMapType innerMapType, int seed, Action <int, int, long, long> pixelChangedCallback)
        {
            var map = GoGenerate(new FastRandom(seed), width, height);

            InnerMap innerMap = new BooleanInnerMap(width, height, map);
            var      maze     = new Maze(innerMap);

            return(maze);
        }
        /// <summary>
        /// Generate a Maze
        /// </summary>
        /// <param name="width">Width of the maze</param>
        /// <param name="height">Height of the maze</param>
        /// <param name="innerMapType">The type which is used to store a map</param>
        /// <param name="seed">The seed that is used to generate a maze</param>
        /// <param name="pixelChangedCallback">When a pixel is changed you can define a callback here to for example draw the maze while its being generated, add null if you don't want this. Last 2 longs are for the current step and the total steps (can be used to calculate how far the maze is done being generated)</param>
        /// <returns>A maze</returns>
        public Maze Generate(int width, int height, InnerMapType innerMapType, int seed, Action<int, int, long, long> pixelChangedCallback)
        {
            if (pixelChangedCallback == null)
            {
                pixelChangedCallback = (x, y, z, u) => { };
            }

            Maze maze = new Maze(width, height, innerMapType);
            GoGenerate(maze.InnerMap, maze, new Random(seed), pixelChangedCallback);
            return maze;
        }
Example #6
0
        /// <summary>
        /// Generate a Maze
        /// </summary>
        /// <param name="width">Width of the maze</param>
        /// <param name="height">Height of the maze</param>
        /// <param name="innerMapType">The type which is used to store a map</param>
        /// <param name="pixelChangedCallback">When a pixel is changed you can define a callback here to for example draw the maze while its being generated, add null if you don't want this. Last 2 longs are for the current step and the total steps (can be used to calculate how far the maze is done being generated)</param>
        /// <returns>A maze</returns>
        public Maze Generate(int width, int height, InnerMapType innerMapType, Action <int, int, long, long> pixelChangedCallback)
        {
            if (pixelChangedCallback == null)
            {
                pixelChangedCallback = (x, y, z, u) => { };
            }

            Maze maze = new Maze(width, height, innerMapType);

            GoGenerate(maze.InnerMap, maze, new Random(), pixelChangedCallback);
            return(maze);
        }
Example #7
0
        private void GenerateMazeWithThisTypeAndShowTime(InnerMapType type, int size)
        {
            Stopwatch w = new Stopwatch ();
            w.Start ();

            AlgorithmBacktrack back = new AlgorithmBacktrack ();
            DebugMSG ("Generating maze of type: " + type + " of size: " + size);
            Maze maze = back.Generate (size, size, type, null);
            //var path = PathFinderDepthFirst.GoFind(new MazePoint(1, 1), new MazePoint(size - 3, size - 3), maze.InnerMap);
            //maze.SaveMazeAsBmpWithPath4bpp("maze.bmp", path);
            DebugMSG ("Ok done, time: " + w.Elapsed.TotalSeconds);
            DebugMSG ("");
        }
        private void GenerateMazeWithThisTypeAndShowTime(InnerMapType type, int size)
        {
            Stopwatch w = new Stopwatch();

            w.Start();

            AlgorithmBacktrack back = new AlgorithmBacktrack();

            DebugMSG("Generating maze of type: " + type + " of size: " + size);
            Maze maze = back.Generate(size, size, type, null);

            //var path = PathFinderDepthFirst.GoFind(new MazePoint(1, 1), new MazePoint(size - 3, size - 3), maze.InnerMap);
            //maze.SaveMazeAsBmpWithPath4bpp("maze.bmp", path);
            DebugMSG("Ok done, time: " + w.Elapsed.TotalSeconds);
            DebugMSG("");
        }
Example #9
0
 public Maze(int width, int height, InnerMapType innerMapType)
 {
     switch (innerMapType)
     {
         case InnerMapType.BitArreintjeFast:
             innerMap = new BitArreintjeFastInnerMap(width, height);
             break;
         case InnerMapType.BooleanArray:
             innerMap = new BooleanInnerMap(width, height);
             break;
         case InnerMapType.DotNetBitArray:
             innerMap = new DotNetBitArrayInnerMap(width, height);
             break;
         case InnerMapType.BitArrayMappedOnHardDisk:
             innerMap = new BitArrayMappedOnHardDiskInnerMap(width, height);
             break;
         case InnerMapType.Hybrid:
             innerMap = new HybridInnerMap(width, height);
             break;
         default:
             break;
     }
 }
Example #10
0
        internal static RowMap GetTempRowMap(string[] s, string columnName, RowMap tempRm = null)
        {
            int length = s.Length;

            if (tempRm == null)
            {
                tempRm = new RowMap {
                    ColumnMapsByPropertyName = new Dictionary <string, ColumnMap>()
                };
            }
            InnerMapType innerMapType   = InnerMapType.Internal;
            RowMap       internalRowMap = null;

            if (length > 2)
            {
                string[] strings = s.Skip(1).ToArray();
                RowMap   rm      = null;
                if (tempRm.ColumnMapsByPropertyName.ContainsKey(strings[0]))
                {
                    rm = tempRm.ColumnMapsByPropertyName[strings[0]].InternalRowMap;
                }
                internalRowMap = GetTempRowMap(strings, columnName, rm);
            }
            else
            {
                innerMapType = InnerMapType.None;
            }

            if (!tempRm.ColumnMapsByPropertyName.ContainsKey(s[1]))
            {
                tempRm.ColumnMapsByPropertyName.Add(s[1], new ColumnMap {
                    ColumnName = columnName, PropertyName = s[1], InnerType = innerMapType, InternalRowMap = internalRowMap
                });
            }
            return(tempRm);
        }
 /// <summary>
 /// Generate a Maze
 /// </summary>
 /// <param name="width">Width of the maze</param>
 /// <param name="height">Height of the maze</param>
 /// <param name="innerMapType">The type which is used to store a map</param>
 /// <param name="pixelChangedCallback">When a pixel is changed you can define a callback here to for example draw the maze while its being generated, add null if you don't want this. Last 2 longs are for the current step and the total steps (can be used to calculate how far the maze is done being generated)</param>
 /// <returns>A maze</returns>
 public Maze Generate(int width, int height, InnerMapType innerMapType, Action<int, int, long, long> pixelChangedCallback)
 {
     Maze maze = new Maze(width, height, innerMapType);
     GoGenerate(maze.InnerMap, maze, new Random(), null);
     return maze;
 }
Example #12
0
        private void GenerateMazeWithThisTypeAndShowTime(InnerMapType type, int size)
        {
            Stopwatch w = new Stopwatch();
            w.Start();

            AlgorithmBacktrack back = new AlgorithmBacktrack();
            DebugMSG("Generating maze of type: " + type + " of size: " + size);
            Maze maze = back.Generate(size, size, type, (x, y, cur, tot) =>
            {
                curXInMaze = x;
                curYInMaze = y;
                currentStepsToCalcPercentage = cur;
                totalStepsToCalcPercentage = tot;
            });
            //var path = PathFinderDepthFirstSmart.GoFind(new MazePoint(1, 1), new MazePoint(size - 3, size - 3), maze.InnerMap);
            //maze.SaveMazeAsBmpWithPath4bpp("maze.bmp", path);
            DebugMSG("Ok done, time: " + w.Elapsed.TotalSeconds);
            DebugMSG("");
        }