Beispiel #1
0
        public override void Execute()
        {
            // assumes x,y and x2,y2 have been normalized so that x,y is top-left
            Tools.PrepareUndo(x, y, x2, y2, plr);

            switch (algorithm)
            {
                case 0:
                    TShock.Players[plr].SendMessage(String.Format("0: Recursive Backtracker maze creation initiated!"), Color.Green);
                    this.maze = new Mazes.Maze(new Mazes.Point(x, y), new Mazes.Point(x2 - x, y2 - y), new Mazes.Point(TShock.Players[plr].TileX, TShock.Players[plr].TileY),
                        tunnelWidth, wallWidth, algorithm, 0, this.PeekBlock, this.NukeTiles);
                    //RecursiveBacktracker();
                    break;
                case 1:
                    // TShock.Players[plr].SendMessage(String.Format("1: Growing Tree maze creation initiated!"), Color.Green);
                    //  GrowingTree();
                    break;
                default:
                    TShock.Players[plr].SendMessage(String.Format("Invalid algorithm specified."), Color.Red);
                    break;
            }
            MazeState ms = new MazeState();
            while (ms.status < 8)
            {
                ms = maze.Step();
            }



            TShock.Players[plr].SendMessage(String.Format("Maze creation complete."), Color.LimeGreen);
            ResetSection();

        } //Execute()
Beispiel #2
0
 public MazeTestCase(string name, Action<Robot, int, int> solve)
     : base(name)
 {
     maze = new Maze("mazes\\" + name + ".txt");
     cellSize = 200 / Math.Max(maze.Size.Width, maze.Size.Height);
     this.solve = solve;
 }
Beispiel #3
0
        private void buttonCreateMaze_Click(object sender, EventArgs e)
        {
            int wd, ht, tunnel, wall, sx, sy, algo, variant;

            try
            {
                wd      = int.Parse(tbMazeWidth.Text);
                ht      = int.Parse(tbMazeHeight.Text);
                tunnel  = int.Parse(tbTunnelWidth.Text);
                wall    = int.Parse(tbWallWidth.Text);
                sx      = int.Parse(tbStartX.Text);
                sy      = int.Parse(tbStartY.Text);
                algo    = comboAlgorithm.SelectedIndex;
                variant = comboVariant.SelectedIndex;
            }
            catch
            {
                return;
            }
            if (ht <= 0 || ht > 10000 || wd <= 0 || wd > 10000 ||
                tunnel <= 0 || tunnel > 2000 || wall <= 0 || wall > 2000 ||
                sx < 0 || sx > wd || sy < 0 || sy > ht)
            {
                return;
            }

            if (solver != null)
            {
                solver.exploredPoints.Clear();
            }
            mazeBmp = new Bitmap(wd, ht);
            mazePanel.Invalidate();
            this.prevCell = new Mazes.Point(-1, -1);
            SetRect(new Rect(0, 0, mazeBmp.Width, mazeBmp.Height), wallColor);
            this.maze = new Mazes.Maze(new Mazes.Point(0, 0), new Mazes.Point(wd, ht), new Mazes.Point(sx, sy),
                                       tunnel, wall, algo, variant, this.PeekPixel, this.SetRect);
            createInProgress = true;
            timer1.Start();
        }
Beispiel #4
0
 public Robot(Maze maze)
 {
     this.maze = maze;
     path.Add(maze.Robot);
 }
Beispiel #5
0
 public Robot(Maze maze)
 {
     this.maze = maze;
     path.Add(maze.Robot);
 }
Beispiel #6
0
 /// <summary>
 /// Base class for all solutions which all contain a name, a solution string,
 /// a start and end, and a way to solve it which must be implemented
 /// </summary>
 /// <param name="maze"></param>
 public virtual void Solve(Maze maze)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
        private void buttonCreateMaze_Click(object sender, EventArgs e)
        {
            int wd, ht, tunnel, wall, sx, sy, algo, variant;
            try
            {
                wd = int.Parse(tbMazeWidth.Text);
                ht = int.Parse(tbMazeHeight.Text);
                tunnel = int.Parse(tbTunnelWidth.Text);
                wall = int.Parse(tbWallWidth.Text);
                sx = int.Parse(tbStartX.Text);
                sy = int.Parse(tbStartY.Text);
                algo = comboAlgorithm.SelectedIndex;
                variant = comboVariant.SelectedIndex;
            }
            catch
            {
                return;
            }
            if (ht <= 0 || ht > 10000 || wd <= 0 || wd > 10000
                 || tunnel <= 0 || tunnel > 2000 || wall <= 0 || wall > 2000
                 || sx < 0 || sx > wd || sy < 0 || sy > ht )
                return;

            if (solver != null)
                solver.exploredPoints.Clear();
            mazeBmp = new Bitmap(wd, ht);
            mazePanel.Invalidate();
            this.prevCell = new Mazes.Point(-1, -1);
            SetRect(new Rect(0,0, mazeBmp.Width, mazeBmp.Height), wallColor);
            this.maze = new Mazes.Maze(new Mazes.Point(0, 0), new Mazes.Point(wd, ht), new Mazes.Point(sx, sy),
                        tunnel, wall, algo, variant, this.PeekPixel, this.SetRect);
            createInProgress = true;
            timer1.Start();
        }