예제 #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);

            this.solver = new Solver(new Mazes.Point(x,y-1), new Mazes.Point(x2,y2-1), this.PeekBlock);
            while (solver.state < 8)
            {
                solver.SolveStep();
            }

            foreach (Mazes.Point sp in solver.solution)
            {
                DrawWire(sp);
            }

            TShock.Players[plr].SendMessage(String.Format("Solve complete."), Color.LimeGreen);
            ResetSection();
        }
예제 #2
0
파일: Form1.cs 프로젝트: radishes/MazeGUI
        private void buttonSolveMaze_Click(object sender, EventArgs e)
        {
            if (mazeBmp == null)
            {
                MessageBoxError("No maze to solve! Create a maze first.");
                return;
            }
            if (createInProgress)
            {
                MessageBoxError("Maze creation is currently in progress. Only completed or paused mazes may be solved.");
                return;
            }

            int sx, sy, ex, ey;
            try
            {
                sx = int.Parse(tbStartX.Text);
                sy = int.Parse(tbStartY.Text);
                ex = int.Parse(tbEndX.Text);
                ey = int.Parse(tbEndY.Text);
            }
            catch
            {
                MessageBoxError("One or more of the parameters is not a valid number. Check your parameters and try again.");
                return;
            }

            if (sx < 0 || sx > mazeBmp.Width || sy < 0 || sy > mazeBmp.Height
                || ex < 0 || ex > mazeBmp.Width || ey < 0 || ey > mazeBmp.Height)
            {
                MessageBoxError("One or more of the parameters is outside of the maze boundaries. Check your parameters and try again.");
                return;
            }

            Mazes.Point p1 = new Mazes.Point(sx, sy);
            Mazes.Point p2 = new Mazes.Point(ex, ey);

            solver = new Solver(p1, p2, this.PeekPixel);

            solveInProgress = true;
            timer1.Start();
        }