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(); }
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(); }