PROCEDURE SolveMaze(VAR maze: Maze;
width, height: MazeSize;
startx, starty: MazeIndex);
TYPE
Direction = (east, south, west, north);
Delta = [-1..1];
VAR
dx, dy: ARRAY Direction OF Delta;
x, y: MazeIndex;
direction: Direction;
BEGIN (* SolveMaze *)
(* Initialisierung von dx und dy *)
direction := MIN(Direction); x := startx; y := starty;
REPEAT
maze[x, y] := walk;
IF stepwise THEN
WriteMaze(maze, width, height);
IF query & ~Weiter() THEN
RETURN
END;
END;
direction := Find(x, y, direction);
INC(x, dx[direction]); INC(y, dy[direction]);
UNTIL Exit(x, y);
maze[x, y] := walk;
END SolveMaze;
|