Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Maze   maze       = new Maze();
            string path       = Directory.GetCurrentDirectory();
            bool   isDebug    = false;
            bool   shouldView = false;

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed <Options>(o =>
            {
                maze.Width  = o.Width;
                maze.Height = o.Height;
                maze.Noise  = o.Noise;

                if (o.Path != null)
                {
                    path = o.Path;
                }

                isDebug    = o.Debug;
                shouldView = o.View;
            });

            if (isDebug)
            {
                Console.WriteLine("Generating Maze");
            }

            bool[,] map = maze.Generate(isDebug);

            Bitmap bmp = new Bitmap(maze.Width, maze.Height);

            for (int y = 0; y < maze.Height; y++)
            {
                for (int x = 0; x < maze.Width; x++)
                {
                    bmp.SetPixel(x, y, map[y, x] ? Color.White : Color.Black);
                }
            }

            string img = Path.Combine(path, "maze-" + maze.Height + "_" + maze.Width + ".png");

            bmp.Save(img, System.Drawing.Imaging.ImageFormat.Png);

            if (isDebug)
            {
                Console.WriteLine("Generation Complete");
                Console.Read();
            }

            if (shouldView)
            {
                ProcessStartInfo psi = new ProcessStartInfo
                {
                    FileName        = img,
                    UseShellExecute = true
                };
                Process.Start(psi);
            }
        }
Ejemplo n.º 2
0
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Maze m = e.Argument as Maze;

            time     = m.Generate(ref bw);
            e.Result = m;
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            for (int x = 0; x < 1; x++)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                Maze maze = new Maze();

                maze.Generate(10, 10, 100);
                sw.Stop();
                Console.WriteLine(sw.ElapsedMilliseconds);

                sw.Restart();
                Picture mazeDrawer = new Picture();
                mazeDrawer.Draw(maze);
                sw.Stop();
                Console.WriteLine(sw.ElapsedMilliseconds);
            }
        }
Ejemplo n.º 4
0
 static void Main(string[] args)
 {
     var maze = new Maze(10,10);
     maze.Generate();
 }