-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.m
65 lines (56 loc) · 2.28 KB
/
setup.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
52
53
54
55
56
57
58
59
60
61
62
63
64
function [maze, nodes, position, endPos] = setup(size)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ENGR 132 Program Description
% This function This function takes a size parameter and generates a nxn
% matrix of that size. Next, the function creates a border of 8's around
% the outside edges. It then randomly generates a start and end point
% (which will be returned at the end of the function). The start point
% will be located at some point along the bottom row (where it will
% replace one of the 8's). The end point will be located at some point
% along the top row (where it will replace one of the 8's). A 1 (path)
% will be generated directly above the start point, and a node will be
% created at that point. The function then returns the created maze, a
% list of nodes, and the start/end positions of the maze.
%
% Function Call
% function [maze, nodes, position, endPos] = setup(size)
%
% Input Arguments
% 1. size: User-defined maze size
%
% Output Arguments
% 1. maze: Blank maze template of size x size dimensions
% 2. nodes: Initial list of nodes
% 3. position: Initial position
% 4. endPos: Position of ending block
%
% Assignment Information
% Assignment: MATLAB Individual Project
% Author: Ryan Schwartz, [email protected]
% Team ID: 001-07
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INITIALIZATION ---
% Generate maze, create borders of 8s
maze = zeros(size);
maze(1, 1:end) = 8;
maze(1:end, 1) = 8;
maze(end, 1:end) = 8;
maze(1:end, end) = 8;
%% CALCULATIONS ---
% Generate random starting and ending points
position = point(size, randi([2 (size - 1)]));
maze = setMazePosition(maze, position, 3);
position = adjust(position, -1, 0);
maze = setMazePosition(maze, position, 1);
nodes(1, 1) = position.row;
nodes(2, 1) = position.col;
endPos = point(1, randi([2 (size - 1)]));
maze = setMazePosition(maze, endPos, 4);
%% FORMATTED TEXT & FIGURE DISPLAYS ---
%% 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.
%