-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.m
52 lines (45 loc) · 1.87 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ENGR 132 Program Description
% This script is the main controller of the maze generation program.
% This uses the setup function to create an empty maze. Then, it uses the
% move function while there are no more nodes listed in the nodes list.
% At the very end, it uses the adjustEnd function to link the exit to the
% rest of the maze.
%
% Assignment Information
% Assignment: MATLAB Individual Project
% Author: Ryan Schwartz, schwar95@purdue.edu
% Team ID: 001-07
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INITIALIZATION ---
% Grabs user input for size and difficulty
% Constraints for size: Positive number 5 < s < 100
% Constraints for difficulty: 1 < d < 10
res = inputdlg({'Enter size of maze:', 'Enter difficulty of maze:'}, 'Input', 1);
size = str2num(res{1});
difficulty = str2num(res{2});
% Verify numbers are correct
while size > 100 || size <= 5 || difficulty < 1 || difficulty > 10
res = inputdlg({'Enter size of maze:', 'Enter difficulty of maze:'}, 'Incorrect Input', 1);
size = str2num(res{1});
difficulty = str2num(res{2});
end
%% CALCULATIONS ---
[maze, nodes, position, endPoint] = setup(size);
% Runs generation process until there are no more nodes left
while numel(nodes) > 0
[maze, position, nodes] = move(maze, position, nodes, difficulty);
dispMaze(maze);
end
maze = adjustEnd(maze, endPoint);
%% FORMATTED TEXT & FIGURE DISPLAYS ---
dispMaze(maze);
fprintf('Completed successfully\n');
clear
%% COMMAND WINDOW OUTPUTS ---
%% ACADEMIC INTEGRITY STATEMENT ---
% I/We have not used source code obtained from any other unauthorized
% source, either modified or unmodified. Neither have I/we provided
% access to my/our code to another. The project I/we am/are submitting
% is my/our own original work.
%