Anonymous user
Maze generation: Difference between revisions
→{{header|Ada}}: Simplified way of detecting unvisited neighbours.
(→{{header|Ada}}: Simplified way of detecting unvisited neighbours.) |
|||
Line 65:
Row : Height_Type;
Column : Width_Type);
return Boolean;▼
procedure Move
Line 101 ⟶ 95:
Next_Direction : Directions;
Valid_Direction : Boolean;
Tested_Wall : array (Directions) of Boolean := (others => False);
begin
-- mark as visited
Maze (Row, Column).Visited := True;
-- continue as long as there are unvisited neighbours left
All_Tested := All_Tested and Tested_Wall (D);
-- all directions are either visited from here,
-- or previously visited, or invalid.
exit when All_Tested;
-- use random direction
Next_Direction := Random_Direction.Random (Dir_Generator);
Line 121 ⟶ 124:
end if;
end if;
Tested_Wall (Next_Direction) := True;
end loop;
end Depth_First_Algorithm;
▲ for Dir in Directions loop
▲ return True;
▲ end if;
▲ end loop;
procedure Initialize (Maze : in out Maze_Grid) is
|