Full Text 02
Full Text 02
Full Text 02
June 2018
Albin Karlsson
The authors declare that they are the sole authors of this thesis and that they have not used
any sources other than those listed in the bibliography and identified as references. They further
declare that they have not submitted this thesis at any other institution to obtain a degree.
Contact Information:
Albin Karlsson
E-mail: alkf14@student.bth.se
University advisor:
M.Sc Diego Navarro
Department of Creative Technologies
I would like to thank my supervisor, M. Sc Diego Navarro for his clear, to-the-point,
actionable advice. Without him, this thesis would probably be a mess. I would also
like to thank my fellow students sitting in the computer lab for being such good
company, they helped making the weeks of writing and coding a blast.
iii
Contents
Abstract i
Acknowledgments iii
1 Introduction 1
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Research Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Thesis Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Background 5
2.1 Theoretical Background . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1 Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2 Spanning Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3 Weighted Graph . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.4 Greedy Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.5 Procedural Content Generation . . . . . . . . . . . . . . . . . 6
2.1.6 Perfect Maze . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.7 Randomized Prim’s Algorithm . . . . . . . . . . . . . . . . . . 7
2.1.8 Recursive Backtracker / Depth-First-Search Algorithm . . . . 8
2.1.9 Recursive Division Algorithm . . . . . . . . . . . . . . . . . . 8
2.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 Method 13
3.1 Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Implementation Details . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 DFS Solver and Completion Time . . . . . . . . . . . . . . . . . . . . 14
3.4 Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 Path Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.6 Corridor Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.7 Experiment Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4 Results 17
4.1 Maze Appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Completion Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3 Path Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.4 Corridor Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.5 Branch Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
v
5 Analysis and Discussion 29
5.1 Completion Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.2 Branches, Path Length, and Corridors Effect On Completion Time . . 31
5.2.1 Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.2.2 Path Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.2.3 Corridors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
B Code Examples 41
B.1 Recursive Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
B.2 Recursive Backtracker Code . . . . . . . . . . . . . . . . . . . . . . . 43
B.3 Recursive Division Code . . . . . . . . . . . . . . . . . . . . . . . . . 45
B.4 Randomized Prim’s Algorithm Code . . . . . . . . . . . . . . . . . . 46
B.5 Depth-first-search Algorithm Code . . . . . . . . . . . . . . . . . . . 49
vi
Chapter 1
Introduction
Computer games are one of the fastest growing mediums today, with a large amount
of players spending many hours immersed in digital worlds filled with novel content.
So far handcrafted content has been able to keep up with the rising production costs
and expectations of players, but if costs and expectations keeps rising it may become
unsustainable1 . Procedural Content Generation (PCG) holds the potential to fix this.
PCG can aid developers with creating more novel content, faster, while saving man-
hours. It typically does this by either automatically generating content to directly
be used by the player, or as a creative aid for developers who ultimately chooses the
generated content to be used. The challenge with PCG is defining the parameters
by which content is generated that satisfies both developers and players(Shaker,
Togelius, & Nelson, 2016). One specific usage of PCG is the generation of mazes.
Mazes are useful for both level design and game design as a piece of content that
can simultaneously be used as a "physical" element of a level, and a puzzle for
the player. They are well-suited for PCG since the end result is relatively easy to
express algorithmically: a start point, an end point, and a series of puzzling sprawling
interconnected paths between them. Some examples of games featuring mazes are
the classic Pac-man, and roguelikes such as Hauberk2 , a game developed by Bob
Nystrom3 , the author of Game Programming Patterns4 .
1.1 Motivation
Game Designers want to craft a good difficulty curve for their players. If they want
mazes in their game, and if it turns out that different maze algorithms generate mazes
of different complexity, the designer would want to know which maze algorithm fits
the difficulty curve best. When a designer is short on time, like when producing
prototypes, it is useful to know the complexity level of mazes to quickly be able to
pick a suitably complex maze algorithm.
Previous research made by Kim et. al (Kim & Crawfis, 2015) proposed a frame-
work for a maze generation tool that could perhaps be improved by incorporating the
1
Steve Thodore, Why have video game budgets skyrocketed in recent years?,
https://www.quora.com/Why-have-video-game-budgets-skyrocketed-in-recent-years (accessed
11-04-2018)
2
Bob Nystrom, Hauberk, https://github.com/munificent/hauberk (accessed 31-05-2018)
3
Bob Nystrom, Rooms and Mazes: A Procedural Dungeon Generator,
http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/ (accessed 31-05-2018)
4
Robert (Bob) Nystrom, Game Programming Patterns, http://gameprogrammingpatterns.com/
(accessed 31-05-2018)
1
2 Chapter 1. Introduction
presents the tools used for the implementation, explains what is measured, and
presents the experiment procedure. Results presents and explains the gathered data,
and exposes patterns discovered in the data. Analysis and Discussion discusses the
gathered data and patterns found in it. Conclusions and Future work uses some of
the found patterns to answer RQ1 and RQ2, and gives suggestions to keep exploring
the field of PCG Maze research. Appendix A presents pseudo-code for the maze
generation algorithms. Appendix B presents code used in the implementation used
in this study.
Chapter 2
Background
This chapter will provide the theoretical background needed for the maze algorithms,
as well as present related work in this field.
2.1.1 Graph
The graph is one of the pillars of graph theory. A graph consists of a vertex set, an
edge set, and a mapping function called relation of incidence. This function states
that each edge has two vertices. Another graph-attribute is connectivity which is
used to distinguish between connected and disconnected graphs. In a connected
graph all vertices are connected, which means that there is a path (unbroken chain
of edges) between all pairs of vertices(Foltin, 2008). Graphs are visualized in Figure
2.1.
Graph Illustration
(a) (b)
Figure 2.1: Red dots are vertices, black lines are edges. (a) displays a disconnected
graph, where vertex 1 is not connected to the other vertices (i.e a broken chain). (b)
displays a connected graph, where all vertices are connected by an unbroken chain
of edges.
5
6 Chapter 2. Background
Both RecDiv and Prims are graph based maze algorithms. Essentially graph based
algorithms create mazes by constructing a spanning tree.
Kim et. al (Kim & Crawfis, 2015) proposed a search-based framework for gener-
ating perfect mazes, with the purpose of giving the designer a tool for finding the
"best" perfect maze, where "best" is up to the subjective opinion of the designer to
decide. What drives a search-based system is a fitness function. A fitness function
takes a set of user-determined variables as input, and then outputs a fitness num-
ber. The fitness function is run through a search-space (a list of sample content)
where it samples fitness variables, and then the sample that outputs the highest
fitness-number "wins", and it gets selected as output content.
They used several variables as inputs to the evaluation function. Of note is that
they had defined several types of dead-ends, and useful concepts such as decision cell
that refers to cells with more than two passages connected to it, which might also be
conceptualized as "branches". The variables used in the proposed framework were:
Metrics Per Spanning Tree:
• Number of cells
• Number of edges
• Percentage of junctions
• Percentage of crossroads
It is somewhat unclear how an edge is recorded, however one could make the
assumption that it is the number of nodes in each edge of the grid. A junction is
decision-cell with three paths connected to it, which means it has just one wall, while
a crossroad is a decision-cell with four paths connected to it, meaning it has no walls.
The percentage of junctions and crossroads is relative to the total number of nodes
in the grid.
Metrics per solution path:
2.2. Related Work 11
• Percentage of dead-ends
• Percentage of alcoves
• Perfect maze.
• Two dimensional.
The algorithms will generate mazes of different resolutions; 16x16, 32x32, 64x64,
128x128, 256x256. Those resolutions are chosen to see how an exponential increase in
maze size affects the overall results of the test. Initial testing showed that resolutions
exponentially higher than 256x256 were not possible due to memory limitations.
This implementation allocated the resources for the algorithms in the RAM memory,
and when trying resolutions higher than 256x256 (specifically tested 512x512), the
memory offered by the testing machine (16 GB) was not enough. The resolutions
are symmetrical in both axis to remove its ability to affect testing results.
13
14 Chapter 3. Method
3D models where the maze has walls, on the traversed path, and on the solving path.
It is visualized in 3D because of author preference and familiarity. The game engine
Unity (version 2017.4.1f1) 1 is used as the development environment since it offers a
convenient way to spawn 3D-models from code, and good integration with C#. No
visualizations of the mazes are generated for the main test in order to avoid making
the visualization a potential factor that could affect the final results.
The code written for this thesis is written in C# 2 since it is an interpreted script-
ing language with no compile times, which helps improve implementation speed. The
IDE used for writing the code was Microsoft Visual Studio Professional 2017. The
3D-models used for the 3D visualization of the maze were produced using Autodesk
Maya 2017.
take into account some other aspects of "human" pathfinding, such as an imperfect
memory, or cognitive biases about which path gets chosen. Despite this, DFS should
suffice for the purposes of this thesis.
The completion time statistic will be recorded as the time it takes for the DFS
Solver to find a path to the end of the maze. Specifically it is the time between the
start of the execution of the solver, and the point where the end of the maze has
been reached. If instead the final time is calculated as the time between the start
of the execution, and the end of the execution, the resulting completion time could
increase significantly. This would be the case if the DFS was recursive, since then
it would have to go back up in the recursive tree until the "root" function call is
reached, where each function return would take additional time. However ever since
the DFS implementation was re-factored to no longer be recursive this is no longer
the case, making this saving of completion time somewhat redundant.
Delta-time will be recorded in milliseconds.
The source code for the depth-first solver can be found in Appendix B.5.
3.4 Branches
A branch is defined by the number of neighboring path-nodes, where the maximum
amount of branches is determined by the number of allowed path neighbors. In a grid
where only orthogonal paths are allowed, a branch can at max have 4 neighbours,
whereas if vertical paths are allowed a branch can have at max 8 neighbors. However
the minimum amount of neighbours for a branch to be considered a branch is always
1. The grid used in this thesis only allows orthogonal paths, so a branch can only
have 4 neighbours. Branches will be recorded per maze-node of a generated maze,
which means that the total number of branches will be the same as the total number
of nodes in the maze which is the same as the maze resolution (ex. 16x16 = 256).
Examples of branches are found in Figure 3.1. Branches as defined here are similar
to the "decision cells" used by Kim et. al (Kim & Crawfis, 2015). They define a
decision cell as "A cell in which there are more than two passages connected to it.",
which would make the 3 and 4 branches decision cells. However they do not explicitly
measure 2-branches/paths, and they do not measure dead ends in the same way as
1-branches, since they also measure the path leading up to the dead end.
Definition of Branches
Results
All data tables presented are part of the same data set, which have been split up
into the three component parts; path length, corridor distribution, and branch dis-
tribution. Each will be presented separately, and is an average of the raw data from
100 tests per resolution per maze algorithm.
Figures 4.1a, 4.1b , and 4.1c shows representative solutions obtained by the different
maze algorithms. Several things stand out when observing the maze solutions:
• The maze walls of RecDivs look orderly, like squares stacked next to each other.
This is an effect of the recursive nature of the algorithm, since it does actually
divide the maze grid into several "boxes".
• RecBacks solution path covers much of the maze, it is also the maze algorithm
with the longest solving path. Its solution path is more winding compared to
the other algorithms.
• Prims solution path almost goes straight to the goal, it is also the maze algo-
rithms with the shortest solving path.
17
18 Chapter 4. Results
(a) (b)
(c)
Figure 4.1: 32x32 mazes generated by the algorithms. (a) displays a maze generated
by RecBack, (b) shows a maze generated by RecDiv, (c) illustrates a maze generated
by Prims. Green nodes are part of the solution path, while red nodes are paths that
lead to dead ends. Bottom left is the start/entrance of the maze solver, top right is
the goal/exit.
11.5
6000 25.5
70
3 759 7000712
26.5 Corridor (%)
Percent (%)
5 90
25 52 Length
Length Corridor
Corridor (%)
(%)
Percent (%)
(%)(%)
11 60 58 3.56 26
5000 0.6
2.5 6 80
3.5
milliseconds
4 0.7
Percent (%)
24.5
50 57 11.5
6000 25.5
Percent
10.5 70 759
556 3
Percent (%)
4000
3 2
40
24 3511 25
Percent (%)
16x16 Percent
Percent (%)
(%)(%)
0.530 55 5000 0.6
60
6
58
210 2.5
milliseconds
23.5
1.5 454 4
milliseconds
milliseconds
Maze
yMaze
Maze Type
Ty TypeTime
Type
Solving SolvingTime
Solving Time 24.5
50 57
Percent
3000 20 2.5
10.5 556
9.5 0.423
1 353 RecBack
R RecBack
Maze Type Solving3.98
RecBack 26.11
Time 297.30
40003 2
40
24
Percent (%)
1
16x16 Percent
10 52 RecBack RecDiv
RecDiv 1,347.47 15.24
2.97 71.50
0.530 55
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
2000 22.5 RecDiv
R 2210 23.5
1.5 454
milliseconds
0 0.50 251 Maze
yMaze
Maze Type
Ty TypeTime
Type
Solving SolvingTime
Solving Time
Prims
RecDivPrims 9.17
86.73 42.49 3000
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
Prims
P 1.99 20
0.3 0 150 23 353 RecBack
Maze Type Solving3.98 26.11
Time 297.30
64x64
RecBack
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
16x16
32x32
64x64
64x64128x128
128x128256x256
16x16
16x16 32x32
32x32 64x64
128x128
256x256
16x16
64x64
128x128
256x256
32x32
1000 49
Prims 41.47 9.5
1.51 0.410
1
52
R
RecBack
RecBack RecDiv
RecDiv 1,347.47 15.24
2.97 71.50
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
22.5 R
RecDiv
16x16
32x32
64x64
128x128
256x256
16x16 16x16
32x32
64x64
128x128
128x128256x256
16x16
32x32
64x64
32x32128x128
256x256
048
RecDiv RecBack Prims
20000 0.50 251
Prims
RecDivPrims 9.17
86.73 42.49
0.2
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
P
Prims 1.99
0 0.3 0
16x16
32x32
64x64
256x256
128x128
256x256
16x16
32x32
64x64
128x128
256x256
150
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
1
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
16x16
32x32
64x64
64x64128x128
128x128256x256
256x256 16x16
16x16 32x32
32x32 64x64
128x128
256x256
16x16
64x64
128x128
256x256
32x32
RecDiv RecBack Prims Prims 41.47
RecDiv RecDiv RecBack RecBack Prims Prims 1000 49
16x16
32x32
64x64
128x128
256x256
32x32
64x64
256x256
16x16
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16 16x16
32x32
64x64
128x128
128x128256x256
16x16
32x32
64x64
32x32128x128
256x256
0.1 RecDiv RecBack Prims 0.5 048
0.2 RecDiv RecBack Prims
0
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
RecDiv RecBack Prims
RecDiv
RecDiv RecBack
RecBack Prims
Prims RecDiv RecDiv RecBack RecBack Prims Prims
16x16
32x32
64x64
128x128
32x32
64x64
256x256
128x128
256x256
16x16
64x64
256x256
0 0 0.1 RecDiv RecBack Prims
16x16
RecursiveDivision 16x16
RecursiveBacktracker Prims 16x16 32x32 RecDiv
32x32
RecBack
32x32
Prims
RecDiv RecBack Prims
0
RecursiveDivision RecursiveBacktracker Prims RecursiveDivision RecursiveBacktracker Prims
16x16
RecursiveDivision 16x16
RecursiveBacktracker Prims 16x16
(a) (b)
32x32 Completion Time 32x32
4 Length Completion
Corridor (%) Time
4 Length
Overview
Corridor (%) Overview 2of
3 Length
64x64 Completion
Corridor(%)
Completion(%) Time
Time
2of Completion Time
3 Length Corridor(%)
(%) 12.5 4 Branches (%)
Branches
12.5 64x64
4 Branches Completion
(%)
Branches Time 4 26.5 128x128
16x16 Completion
Corridor (%) Time
6 Length Completion Time
4
7000712
26.5
90
16x16 Completion
6 Length Corridor (%) Time 7000712
25
90
26 52 Length
Length Corridor
Corridor (%)
(%)
3.5300 80
3.5
3.56 25 26 52 Length
Length Corridor
Corridor (%)
(%) 6 0.7
11.5
6000 25.5 3 759
Percent (%)
70 759 3511 25
Percent (%)
(%)(%)
3 60
Percent (%)
3511 58
25 50004 20
250 0.6 6
Percent (%)
(%)(%)
2.5
milliseconds
60 58
milliseconds
5000 24.5
50 57
4 20 0.6 6
Percent
2.5 2.5
milliseconds
milliseconds
24.5
50 57 10.5 556
Percent
2.5
10.5 40003 2
40
24
Percent (%)
16x16 Percent
556 0.530
milliseconds
40003 2
40
24 55
Percent (%)
200
16x16 Percent
0.530 2210 15
milliseconds
55 23.5
1.5 454
milliseconds
Maze Type
Ty Maze
yMaze TypeTime
Type
Solving SolvingTime
Solving Time
2210 15 23.5
1.5 454 3000
milliseconds
Maze
yMaze TypeTime
Type SolvingTime
Solving Time 20
3000 20
Maze Type
Ty Solving
9.5
1 0.423
1 353 R
RecBack RecBack
Maze Type Solving3.98
RecBack 26.11
Time 297.30
9.5 0.423
1 353 R
RecBack RecBack
Maze Type Solving3.98
RecBack 26.11
Time 297.30 1.5150 10 52 RecBack RecDiv
RecDiv 1,347.47 15.24
2.97 71.50
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
1.51 10 52 RecBack RecDiv
RecDiv 1,347.47 15.24
2.97 71.50
20000 10
22.5
0.50 251 RecDiv
R
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
0.50 251 Prims
P 1.99
0 10 1 0.3 0 150
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
Prims 9.17
16x16
32x32
32x32 64x64
64x64128x128
128x128256x256
256x256 16x16
16x16 32x32
32x32 64x64
128x128
256x256
16x16
64x64
128x128
256x256
32x32
RecDivPrims 86.73 42.49
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
Prims
P 1.99 Prims 41.47
1 0.3 0 150 1000
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
16x16
32x32
64x64
64x64128x128
128x128256x256
256x256 16x16
16x16 32x32
32x32 64x64
128x128
256x256
16x16
128x128
256x256
32x32
64x64
49
Prims 41.47 100
16x16
32x32
64x64
128x128
256x256
16x16 16x16
32x32
64x64
128x128
128x128256x256
16x16
32x32
64x64
32x32128x128
256x256
1000 49 048
0.5 RecDiv RecBack Prims
16x16
32x32
64x64
128x128
256x256
16x16 16x16
32x32
64x64
128x128
128x128256x256
16x16
32x32
64x64
32x32128x128
256x256
048 0 5 0.2
16x16
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
0.5 0.2 RecDiv RecBack Prims RecDiv RecBack Prims
0 5
64x64
16x16
32x32
128x128
256x256
16x16
32x32
64x64
128x128
256x256
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
32x32
64x64
128x128
128x128
256x256
32x32
64x64
256x256
16x16
64x64
256x256
RecDiv RecBack Prims
RecDiv RecDiv RecBack RecBack Prims Prims 0 50 0.1
16x16
32x32
64x64
128x128
32x32
64x64
256x256
16x16
64x64
128x128
256x256
256x256
(c) (d)
32x32)Comf( p%etion)Time
4)Length)Corridor)
12.5
l vervieO)ow )Comf
256x256)Comf
64x64)Comf
4)Branches) ( %
2)Branches) p(etion)Time
3)Length)Corridor) (%% petion)Time
petion)Time
4
000
712
26.5 128x128)Comf
16x16)Comf petion)Time
6)Length)Corridor)petion)Time
( %
7000
90
5300
6
25 26
80
3.5 5)Length)Corridor)
2)Length)Corridor) (( %
%
11.5
000 0.7
25.5
70
6000
16x16 Percent) ( % %
3 759
3511
Percent) ( %
Percent ( %
25
Percent) (
60 58
000
4 20
250 0.6
2.5
24.5
6
57
50
5000
5
10.5 556
Percent) ( %
2
mippiseconds
000
3 40
24
0.530
piseconds
55
200
2210 15 4000
23.5
1.5 454
piseconds
Maze Type
Ty Maze
yMaze TypeTime
Type
Solving Solving
Solving Time
Time
000 20
353 RecBack
Maze Type Solving3.98 26.11
Time 297.30
9.5
1
5150 0.423
1
10 52
R
RecBack RecBack
3000 RecBack RecDiv
RecDiv 1,347.47 15.24
2.97 71.50
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
Prims
P 1.99
1 0.3 0 150
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
16x16
32x32
64x64
64x64128x128
128x128256x256
256x256 16x16
32x32
32x32 64x64
128x128
256x256
16x16
64x64
128x128
256x256
32x32
mip
Prims 41.47
000
100 2000 49
16x16
32x32
64x64
128x128
256x256
16x16 16x16
32x32
64x64
128x128
128x128256x256
16x16
32x32
64x64
32x32128x128
256x256
048
5 0.2 RecDiv RecBack Prims
0 5
16x16
32x32
16x16
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
1000RecDiv RecDiv
RecDiv RecBack
RecBack
RecBack Prims
Prims
Prims
16x16
32x32
64x64
128x128
256x256
32x32
64x64
256x256
16x16
64x64
128x128
256x256
(e)
Figure 4.2: Y axis is expressed in milliseconds, signifying the time it took for the
solver to find the goal. X axis shows grid resolutions for each maze algorithm.
20 Chapter 4. Results
11.5
6000 25.5
70 759
5 3
Percent (%)
25
Percent (%)
(%)(%)
11 60 58
5000 2.5 6
milliseconds
4 24.5
50 57
Percent
10.5 556
4000
3 242
40 Percent (%)
16x16 Percent
55
30
210 23.5
1.5 454
3000 20
23 353
9.5
1 1
10 52
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
2000 22.5
0.50 251
0
16x16
32x32
16x16
32x32
64x64
128x128
256x256
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
150
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
64x64128x128
128x128256x256
64x64128x128
256x256
128x128
256x256
16x16
32x32
32x32 64x64
256x256 16x16
16x16 32x32
32x32 64x64
16x16
64x64
32x32
1000 0
49
16x16
32x32
64x64
128x128
256x256
16x16 16x16
32x32
64x64
128x128
128x128256x256
16x16
32x32
64x64
32x32128x128
256x256
048
RecDiv RecBack Prims
0
16x16
16x16
32x32
64x64
128x128
256x256
128x128
256x256
256x256
16x16
32x32
64x64
16x16
32x32
64x64
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
RecDiv RecBack Prims
RecDiv RecDiv RecBack RecBack Prims Prims
16x16
32x32
128x128
256x256
128x128
64x64
256x256
32x32
64x64
16x16
64x64
256x256
RecDiv RecBack Prims
RecDiv
RecDiv RecBack
RecBack Prims
Prims
Figure 4.3: Y axis is expressed in milliseconds, signifying the time it took for the
solver to find the goal. X axis shows grid resolutions for each maze algorithm.
Completion Time
Maze Type Resolution Completion Time (ms)
RecDiv 16x16 0.59
RecBack 16x16 0.51
Prims 16x16 0.47
RecDiv 32x32 2.38
RecBack 32x32 3.46
Prims 32x32 1.52
RecDiv 64x64 12.26
RecBack 64x64 22.14
Prims 64x64 7.18
RecDiv 128x128 56.26
RecBack 128x128 271.18
Prims 128x128 33.32
RecDiv 256x256 362.14
RecBack 256x256 6,440.04
Prims 256x256 164.85
Path Length
Maze Type Resolution Completion Time (ms) Solving Path (%) Solving Path Nodes Traversed Nodes
RecDiv 16x16 0.59 BB.a0 k9.1P 1k5.BB
Recr mcs 16x16 0.51 61.5a 105.96 14P.0a
7 3i2 8 16x16 0.k4 P1.aB BP.90 150.69
RecDiv BPxBP P.Ba PB.1B 146.Pa 46P.Pa
Recr mcs BPxBP B.k6 55.0k k5P.40 aPP.k6
7 3i2 8 BPxBP 1.5P 1k.B9 100.1a 696.k1
RecDiv 6kx6k 1P.P6 16.0P kaP.0a B,009.PP
Recr mcs 6kx6k PP.1k k9.B5 1,6PP.5P B,Pa4.65
7 3i2 8 6kx6k 4.1a a.k0 PB6.9P P,aP0.46
RecDiv 1Pax1Pa 56.P6 11.04 1,Pk5.4P 11,Pka.40
Recr mcs 1Pax1Pa P41.1a B9.66 5,555.16 1k,004.64
7 3i2 8 1Pax1Pa BB.BP k.54 51P.BP 11,P09.aP
RecDiv P56xP56 B6P.1k 4.Pk B,196.90 kk,1kP.16
Recr mcs P56xP56 6,kk0.0k B6.05 1a,BBP.aa 50,a59.61
7 3i2 8 P56xP56 16k.a5 P.k9 1,06B.1a kP,6B9.56
Table 4.2: An overview of the average path length data, sorted by resolution. Com-
pletion time is in milliseconds. Solving Path (%) is Solving Path Nodes divided by
Traversed Nodes, which is the proportion of Traversed Nodes that is solving path nodes.
Solving path nodes is the number of nodes that is part of the completion path. Tra-
versed nodes is the total number of nodes "walked" or "traversed" by the DFS solver,
including nodes that were not part of the completion path.
Table 4.2 contains both Solving Path Nodes, and Traversed Nodes. In Figure 4.1b
the sum of the green nodes is the Solving Path Nodes, while the Traversed nodes
is the sum of both the red and green nodes combined. Table 4.2 shows that at
higher resolutions, the RecBack has significantly higher completion time than the
other algorithms. RecBack also has the highest amount of traversed nodes and
solving path nodes, meanwhile Prims has the lowest completion times, and the lowest
amount of solving path nodes and traversed nodes. RecDiv comes in between Prims
and RecBack in all fields, being statistically closer to Prims than RecBack.
Figure 4.4 shows that Solving Path (%) decrease in a linear manner when reso-
lutions are increased.
22 Chapter 4. Results
Solving
Solving Path Nodes ChangePath
per(%)
Resolution Increase
70
450 Prims Completion Time Increase
RecBack
RecDiv Completion
Completion Time Time Increase
Increase
60
400 600 4 32x32
Length Completion
Corridor (%) Time
2500
700
12.5
Overview 4 3 Length
64x64
Branches 2of
256x256 Completion
Corridor Completion
Completion
(%)
Branches (%)(%) Time
Time Time
350
50 500
128x128 Completion Time
4 16x16 Completion Time
(%)(%)
600
20007000712
26.5 6 Length Corridor (%)
300 7000
90
40 400 500Solving 25
Resolution 3.5
26 52(%)
Length
Length Corridor
4 Length Corridor
(%)
Corridor (%) 5 (%)
Percent (%)
Percent
Maze Type
300
6 Time 802 Length Corridor (%) 3 Length Corridor
3.5
(ms) Length Corridor (%) 6 Length Co
0.7
milliseconds Percent (%)
Percent (%)
Percent (%)
RecDi cv s4, s4 3
Rec. 11
559 267s25
60 7B36 7B 7B6s1 1x36aa B7640 1a160s s260s 1xB63B 76a1
Percent (%)
(%)(%)
200 58
5000 4 cv20 0.6
250 2.5 6 x7
milliseconds
Rec. 59
150 1B, 1B k2.5
P5r10.5
m B610
2 556s7
34B6 7a671 327623 B36Bx 1xa632 s26a1 102610 3617
milliseconds
4000 3 40
24
1B, 1B 200
Percent (%)
128x128 Percent
0.5
milliseconds
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
0 - 32x32 22.5 32x32 - 64x64 64x64 -
Rec. 128x128
59 128x128
B6xa - 256x256
16x16
32x32
16x16
32x32
64x64
16x16
64x64
64x64
32x32
256x256
256x256 128x128
16x16 256x256
128x128
64x64 256x256
k P5r m 43, 43
2000 0 10 16x16a6 0.5
-s0 0 251 7B60a B36
59k2x-k128x128
P5m
r m ss6 74
x6 7643
32x32 32x32 -64x64
64x64 64x64
Rec. P 5r128x128 046128x128
a1 3B6 3xsa-256x256
256x256
16x16
32x32
16x16
32x32
64x64
128x128
256 256x256
64x64
x64 128x128
256x256
16x16
32x32
64x64
128x128
256x256
0 16x16 -
0.3 32x32 32x32 - k P64x64
5r m - s6 128x128
xx -
1 150
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
64x64128x128
128x128256x256
128x128
256x256
128x128
256x256
16x16
32x32
32x32 64x64
16x16
16x16 32x32
32x32 64x64
16x16
64x64
32x32
32x32
64x64
128x128
256x256
x16 16x16
32x32
64x64
128x128
128256x256
16x16
32x32
64x64
x32128x128
x64256x256
048
k P5r m sB0, sB0 0.5 0.2
116 1B RecDiv 7B6x3 RecBack B36B0 ss633 Prims 767x
0 5 14B6
64x64
16x16
16x16
32x32
128x128
256x256
128x128
16x16
32x32
64x64
32x32
64x64
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
x32
x64
x32
256
x16
Figure 4.4: Y axis is expressed in percentile units, that signify the proportion of
Traversed Nodes that is Solving Path Nodes (values taken from Table 4.3). X axis
shows grid resolutions for each maze algorithm.
4.4. Corridor Distribution 23
Corridor Distribution
Maze Type Resolution Completion Time (ms) 2 Length Corridor (%) 3 Length Corridor (%) 4 Length Corridor (%) 5 Length Corridor (%) 6 Length Corridor (%)
RecDiv 16x16 0.59 5B.95 ak.a5 10.k5 k.P9 1.51
Recr mcs 16x16 0.51 5a.1P a5.64 10.41 5.BP a.91
7 3i2 8 16x16 0.kB 51.40 ak.a0 11.40 5.B5 P.aB
RecDiv PaxPa a.P4 5B.5P ak.a9 10.BP k.P5 1.6a
Recr mcs PaxPa P.k6 5a.5a a5.9P 11.5k 5.14 a.54
7 3i2 8 PaxPa 1.5a 5a.5a ak.19 11.5P 5.BP a.4a
RecDiv 6kx6k 1a.a6 5B.61 ak.kP 10.56 k.a5 1.Ba
Recr mcs 6kx6k aa.1k 5a.4B a6.1k 11.5a 5.1k a.Pa
7 3i2 8 6kx6k B.14 5a.4B ak.09 11.56 5.6k a.4a
RecDiv 1a4x1a4 56.a6 5B.61 ak.kP 10.6k k.19 1.B1
Recr mcs 1a4x1a4 aB1.14 5P.1P a6.a6 11.k6 5.0k a.aa
7 3i2 8 1a4x1a4 PP.Pa 5a.9k ak.a4 11.kk 5.59 a.B4
RecDiv a56xa56 P6a.1k 5B.6P ak.k0 10.65 k.14 1.Ba
Recr mcs a56xa56 6,kk0.0k 5P.aP a6.a1 11.kB 5.05 a.a1
7 3i2 8 a56xa56 16k.45 5P.0a ak.aP 11.k9 5.56 a.Bk
Table 4.4: An overview of the corridor distribution data, sorted by resolution. Com-
pletion time expressed in milliseconds. The Corridor (%) columns each signify the
proportion of corridors in the entire maze that is of that length.
There are corridor lengths higher than length 6 presented in this section, but the
appearance of such corridors was a rare occurrence, therefore those were left out
of the presented data. Table 4.4 shows that the corridor distribution of each maze
algorithm does not differ much per resolution change. However there is a slight
difference in corridor distribution between the algorithms.
Observing Figures 4.5a, 4.5b, 4.5c, 4.5d, and 4.5e resulted in Table 4.5, which
compares the corridor lengths of each algorithm to each other. Those comparisons
exposes these patterns:
• Prims, the algorithm with the fastest completion time has the fewest 2 and 3
length paths, but the highest proportion of 4, 5 and 6 length paths.
• RecDiv with the intermediate completion time has the highest proportion of
2 length paths, intermediate proportion of 3 length paths, and the lowest pro-
portion of 4, 5 and 6 length paths.
• RecBack, with the slowest completion time has the lowest proportion of 2 length
paths, highest of 3 length paths, but a intermediate proportion of 4, 5 and 6
length paths.
24 Chapter 4. Results
4.5
48
49
50
51
52
53
54
55
56
57
58
59
0
1
3
4
5
6
10L5
11L5
12L5
9L5
210
11
712
32x32
16x16 16x16
16x16 RecDei vBak P
RecDei vBak P 64x64
RecDiv
32x32 32x32
22L5
23L5
24
24L5
25
26
26L5
23
25L5
10
0
20
30
40
50
60
70
80
90
32x32
128x128
64x64 RecDei vBak P 64x64
16x16
64x64
RecDiv
16x16
256x256
geDC)o
48
49
50
51
52
53
54
55
56
57
58
59
128x128 128x128
32x32
128x128
32x32
16 16x16
256x256 256x256
64x64
256x256
64x64
geDC)o
32 32x32
16x16
128x128
16x16 16x16
128x128
64 64x64
4Br 3B
32x32
RecBack
16x16 256x256
32x32
32x32
cmtei
Percent (%) 256x256
(c)
(a)
16x16 Percent
28 128x128
Percent
(%)(%)
64x64
i Ds2B
16x16
64x64
64x64
vs
32x32
22.5
23.5
26.5
23
24
24.5
25
26
25.5
1.5
2.5
3.5
0
1
2
3
16x16
10
0.50
20
30
40
50
60
70
80
90
4.5. Branch Distribution
RecBack
32x32
enB
256x256
geDr mDd
56
ak
r cm
32x32
128x128 128x128
64x64 Percent (%) 128x128
32x32
16x1616x16
64x64
1
6
16x16 16x16
RecDiv
16
2 Length Corridor (%)
RecDiv
048
49
50
251
52
353
454
55
556
57
58
759
4Btei vs B( %cc)h%cBak P
64x64
256x256 256x256
128x128
32x32
128x128 256x256
64x64
32x32
32x32
geDr mDd
16x16 32 32x32
16x16 16x16
B( i%cc)h%cB
128x128
16x16
16x16
256x256
64x64 64x64
256x256 128x128
32x32 64x64 64x64
RecDiv
64
RecDiv
Prims
PDs enBakakP P
RecDiv
32x32 256x256
32x32 32x32
16x16
128x128
128x128 16x16 32x32
256x256
64x64128x128 28 128x128
64x64 16x16
64x64 64x64
Prims
64x64
Rc). n
256x256
32x32
256x256
256x25632x32 16x16
256x256
2Btei vs B( %cc)h%cBak P
128x128 56
128x128 32x32
128x128 128x128
16x16
64x64
64x64 128x128
32x32
4 Branches
16x16
3 Length
Branch Distribution
256x256 16x16 16
RecBack
RecBack
256x256 64x64
256x256 256x256
Rc) n
32x32
128x128 256x256
64x64
(%)
128x128
32x32
32x32
16x16 32
(e)
16x16 128x128
52 Length
64x64
256x256
256x256
64x64
2 Branches
32x32
.5
24
23
.5
.5
25
26
.5
.5
32x32 64x64
RecBack
10
0
20
30
40
50
60
70
80
90
RecBack
32x32 32x32
RecBack
128x128
128x128 16x16
16x16
Corridor(%)
128x128
64x64 64x64 Percent (%) Percent (%)
16x16
64x64
(%)
6
RecDiv
k
048
49
150
251
52
353
454
55
556
57
58
759
256x256
256x256 32x32
32x32
22.5
23.5
24
24.5
25
26
26.5
23
25.5
256x256
10
0
20
30
40
50
60
70
80
90
Length Corridor
128x128
128x128 128x128
32x32
128x128
16x16
64x64 16x16 32x32
16x16
64x64 16x16 Percent (%)
Prims
16x16 16x16
Corridor (%)
Prims
16x16
(%)
256x256
256x256 256x256
64x64
256x256
48
49
50
51
52
53
54
55
56
57
58
59
32x32
128x128 32x32 64x64
RecDiv
32x32
128x128
32x32 RecDiv
32x32 32x32
16x16 16x16
128x128
16x16 32x32
16x16 64x64128x128 16x16
64x6464x64
256x256 64x64
Prims
256x256
64x64 RecDiv 64x64
Prims
RecDiv 256x256
32x32 64x64
Prims
32x32 32x32
RecDiv
32x32
RecDiv
128x128
128x128 128x128 128x128
64x64 16x16
64x6464x64 128x128
64x64 256x256 256x256 16x16 64x64
RecBack
RecBack
256x256
256x256 256x256 256x256
128x128 32x32
128x128
128x128 256x256
128x128 16x16 32x32 8x128
16x16
64x64
256x256
256x256 16x16
32x32 64x64 6x256
RecBack
32x32
RecBack
32x32
128x128
16x16 32x32
(d)
(b)
16x16
64x64128x128 16x16
64x64 64x64
2 Branches
RecBack
256x256
32x32 64x64
RecBack
32x32
RecBack
256x256
henLtg Corridor
32x32
RecBack
128x128
128x128 128x128
Corridor(%)
16x16
64x64 128x128
64x64
Prims
16x16
Corridor (%)
(%)
64x64
Prims
(%)
256x256
256x256 256x256
32x32
128x128 256x256
128x128
32x32 8x128
16x16
16x16 16x16
64x64
256x256 16x16
Prims
2 Length Corridor (%)
256x256
64x64 6x256
Prims
32x32
32x32 32x32
128x128 32x32
128x128 16x16
64x64
64x64 64x64
of corridors in the maze. X axis shows grid resolutions for each maze algorithm.
Prims
256x256
Prims
Prims
64x64
Prims
256x256 32x32
128x128
128x128 128x128
128x128
Observing figures 4.6a, 4.6b, 4.6c, 4.6d, while comparing the maze algorithms to each
25
• RecBack, with the highest completion time, has the highest distribution of
2-branches, but the lowest distribution of every other branch type, with 4-
branches close to 0% distribution.
• Prims is the opposite to RecBack, with the lowest completion time, lowest
distribution of 2-branches, and the highest distribution of all of the other branch
types.
• RecDiv, with medium completion time has medium distribution across all
branch types.
Maze Type Resolution Completion Time (ms) 1 Branches (%) 2 Branches (%) 3 Branches (%) 4 Branches (%)
RecDiv 16x16 0.59 Ba.69 kP.0r B1.6k B.6r
Recmsc4 16x16 0.51 10.a0 a9.k9 9.a1 0.11
7 3i2 8 16x16 0.ka r k.a1 r 6.P0 Br .0k 5.k5
RecDiv r Bxr B B.r P Ba.r P kP.1P B1.a1 B.ak
Recmsc4 r Bxr B r .k6 10.r B a9.a0 9.Pr 0.15
7 3i2 8 r Bxr B 1.5B r 5.11 r 5.P0 Br .B9 5.P1
RecDiv 6kx6k 1B.B6 Ba.k0 kP.0r B1.aP B.aP
Recmsc4 6kx6k BB.1k 10.06 P0.0P 9.a0 0.16
7 3i2 8 6kx6k a.1P r 5.k6 r 5.19 Br .r 0 6.06
RecDiv 1BPx1BP 56.B6 Ba.r k kP.06 B1.P5 B.ak
Recmsc4 1BPx1BP Ba1.1P 10.0B P0.15 9.65 0.1P
7 3i2 8 1BPx1BP r r .r B r 5.59 r k.95 Br .r k 6.1B
RecDiv B56xB56 r 6B.1k Ba.r 9 ka.9P B1.P6 B.a6
Recmsc4 B56xB56 6,kk0.0k 9.9a P0.Bk 9.61 0.1P
7 3i2 8 B56xB56 16k.P5 r 5.aB r k.a6 Br .r r 6.19
Table 4.6: An overview of the branch distribution data, sorted by resolution. Com-
pletion time in milliseconds. Each Branches (%) column signifies the proportion of
nodes with that number of branches. Note that the sum of all branch columns in one
row is 100, since the sum of all branches is 100% of the branches. Further note that
the total number of branches is equal to the total number of nodes in the maze (which
is the same as the resolution of the maze), since each node has branches.
4.5. Branch Distribution 27
Branches Comparison
60
25
50
20
40
15
30
10 20
5 10
0 0
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
64x64
128x128
256x256
32x32
(a) (b)
5 25
Percent (%)
Percent (%)
Percent (%)
60 58
15 4 24.5
50 57
3 40
24 56
Percent (%)
10 55
30
23.5
2 54
5 20
23 53
1 10 52
22.5
0 0 0 51
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
50
2534253
62462
64x64
13413
62462
1284128
13413
1284128
2534253
13413
62462
1284128
2534253
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
64x64
128x128
32x32
3x43x
3x43x
3x43x
49
48
16x16
32x32
64x64
28x128
56x256
16x16
32x32
64x64
28x128
56x256
16x16
32x32
(c) (d)
Figure 4.6: The compared branch type is stated in each sub-figure. Y axis is expressed
in percentile units, signifying the proportion of all branches that are of the stated type.
X axis shows grid resolutions for each maze algorithm.
Chapter 5
Analysis and Discussion
This chapter will present, explain, and argue for and against patterns found in the
results of each data set in turn.
29
30 Chapter 5. Analysis and Discussion
2008) measured the average completion time of maze resolutions similar to the 16x16,
32x32, and 64x64 resolutions used in this thesis. His completion time increase seem
to approximately coincide with the ones found between resolutions 16x16, 32x32, and
64x64 found in Figure 5.2 (however his increase is smaller, and less even). However it
should be noted that his resolutions are not the same as in this thesis, and the solving
time he gathered was that of humans, not a DFS. No other contributions measuring
the completion time of mazes of differing resolutions has been found. which makes
answering the completion time increase difference the task of future research.
While observing Table 4.1, of note is that the difference in complexity seems to
get smaller as maze resolutions get lower. This might occur since as the maze grid
gets smaller, the number of possible maze variations inside that grid gets smaller, and
therefore outputs of the algorithms seem more and more similar. So the difference
in complexity between the maze algorithms seems to be directly proportional to the
resolution of the maze grid.
ze Type Solving
6 Time (ms)
300 802 Length Corridor (%) 3 Length Corridor (%) 4 Length Corridor (%) 5 Length
3.5
0.7
milliseconds Percent (%)
11.5
6000 25.5
c. 59 s4, s4 267x70 7a6x7 B36B7 s2637
300 6000 3 759
Percent (%)
Percent (%)
60 58
50004 20 0.6
250 2.5 6
milliseconds
200 24.5
50 57
16x16 Percent (%)
c. 59 1B, 1B 2.5
10.5 5000
B610 7a671 B36Bx s26a1
2 556
milliseconds
40003 40
24
Percent (%)
0.5
milliseconds
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
12832128
16x16
2000 - 32x32 22.5 32x32
251 - 64x64 64x64Rec.
128x128 128x128
B6xa - 256x256
m 43, 43 0 10 a6s0 0.50 7B60a B362x r m ss674
5r m 59k Pk5rP5m
k PRec. xxa1 3B6x6
046 3xsa
8x128
6x256
16x16
32x32
8x128
6x256
16x16
32x32
64x64
64x64
16x16
s6
1 0.3 150
4x64
6x16
2x32
4x64
6x16
2x32
6x16
2x32
4x64
x128
x256
x128
x256
8x128
6x256
8x128
6x256
66x16
22x32
44x64
66x16
22x32
44x64
66x16
Prims Completion
RecBack Completion Time Increase
Time Increase
600 4 32x32
Length Completion
Corridor (%) Time
2500
12.5
Overview 3 Length
64x64
4 Branches of
256x256 Completion
CorridorCompletion
Completion
(%)
2 Branches (%)(%) Time
Time Ti
500
2000
4
7000712
26.5 128x128 16x16 Completion
Completion
6 Length Corridor (%) Time
Time
7000
90
400 3.5 25 26 52(%)
Length
Length Corridor
4 Length Corridor
(%)
Corridor (%) 5 (%)
( )
Resolution Solving
6 Time (ms)
300 80
3.52 Length Corridor (%) 3 Length Corridor Length Corrid
0.7
milliseconds Percent (%)
Percent (%)
1500
11.5
6000 25.5
s4, s4 267x70 7a6x7 B36B7 s2637
300 6000 3 759
Percent (%)
s4, s4 3511 267s
Percent (%) 25 7B6s1 B7640 s260s
Percent (%)
60 58
5000
25020 0.6 2.5 6
milliseconds
s4, s4 263a 7s602 B36B2 ss602
1000 4
milliseconds
200 24.5
50 57
Percent (%)
0.5
milliseconds
1B, 1B 1634 55 7B67B B76x1 ss673
100
200
500 2 21015 4000 30
23.5
1.5 454
milliseconds
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
0
2000 - 32x32 22.5 32x32
251 - 64x64 64x64 -
Rec. 128x128
59 128x128
B6xa - 256x256
43, 43 0 10 a6s0 0.50 7B60a B36 2xk P5
r m ss674
Rec. 5
9k P5r m 128x128sa
046a1 3B6x6
3x
16x16
32x32
16x16
32x32
64x64
128x128
256x256
64x64
128x128
256x256
16x16
32x32
64x64
16x160.3
- 32x32 50 32x32 - 64x64 k P64x64
5r m - 128x128 s6xx - 256x256
1
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
28x128
56x256
28x128
56x256
16x16
32x32
64x64
16x16
32x32
64x64
16x16
32x32
sB0, sB0 746B4 0 1 7a64s k P5r B36
m 31 3s63a s2643
sB0, sB0
1000
100 2000
Bas6 s0 49 716s1 B46 B4 ss634
x16
x32
4x64
128
256
x16
x32
4x64
128
256
x16
x32
048
sB0 sB0 05 0 1B
11 2 RecDiv 7B x3 RecBack B3 B0 ss 33 Prims
1500
11.5
6000 25.5
s4, s4 26 7x70 7a6x7 B36B7 s2637
300 400 5 6000 3 759
Percent (%)
Percent (%)
11 60 58
50004 20 0.6
250 2.5 6
milliseconds
1B, 1B 2.5
10.5 5000
B610 56 7a671 B36Bx s26a1
2 5
milliseconds
40003 40
24
1B, 1B 200
Percent (%)
0.5
milliseconds
s6 7B 7B67B sxMaze
B36Maze
Maze Type TypeTime
Type
Solving Solving
Solving ss6Time
71
Time
100
3000 20
43, 43 sB6B423 353 7a64s Maze B36 31RecDi
Type
RecDi cvcv 16
Solving Time B46
s26 12ss
74
Bxa6
0
43, 43 1.5
9.5
1 0.4
BB6s310
1
52 7B60a
RecDi cv
B46cv
x0
s3Rec.59 59 s813a63a ss6 7B
0
0 150 - 32x323000 RecDi Rec. s76
as672B3
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
2000 22.5 32x32
251 - 64x64 64x64Rec.
- 128x128
59 128x128
B6xa - 256x256
43, 43 0 10 16x16a6 0.5
-s0 0 7B60a B36
59k2x-k128x128
P5m
r m ss674
x6
32x32 32x32 -64x64
64x64 64x64
Rec. P 5r128x128 046 128x128
a1 3B63xsa
- -256x256
256x256
16x16
32x32
16x16
32x32
64x64
128x128
256x256
64x64
128x128
256x256
16x16
32x32
64x64
16x16 -
0.3 32x32 32x32 - k P64x64
5
r m - s6128x128
xx
1 150
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
56x256
28x128
56x256
28x128
28x128
56x256
28x128
56x256
28x128
56x256
16x16
32x32
64x64
16x16
32x32
64x64
16x16
64 64
32x32
x32
x64
128
256
x16
x32
x64
128
256
x16
x32
x64
0
05 0 2 R Di48 R B k Pi
Maze Type Completion Time (ms) Maze Type Completion Time (ms)
RecBack 1,347.47 RecBack 297.30
RecDiv 86.73 RecDiv 71.50
Prims 41.47 Prims 42.49
(a) (b)
Maze Type Completion Time (ms) Maze Type Completion Time (ms)
RecBack 26.11 RecBack 3.98
RecDiv 15.24 RecDiv 2.97
Prims 9.17 Prims 1.99
(c) (d)
Table 5.1: Completion time expressed in milliseconds. (a) Presents the average
completion time between all resolutions for each maze algorithm. (b) Presents the
average completion time between the resolutions 16x16, 32x32, 64x64 and 128x128,
for each maze algorithm. (c) Presents the average completion time between the
resolutions 16x16, 32x32 and 64x64, for each maze algorithm. (d) Presents the
average completion time between the resolutions 16x16 and 32x32, for each maze
algorithm.
5.2. Branches, Path Length, and Corridors Effect On Completion Time 33
5.2.1 Branches
Branch distribution patterns found in Table 4.7 indicate that completion time is
directly proportional to the amount of 2-branches. A high distribution of 2-branches
leads to a lower distribution of all other branch types, which in turn hypothetically
would reduce the number of possible paths to the goal, making finding the solution
path harder.
Figures 4.1c and 4.1a illustrates this hypothesis. Figure 4.1c which illustrates a
maze generated by Prims, has a solving path that goes almost straight between start
and finish. Prims as the algorithm with the least amount of 2 branches, and the
highest amount of all other branch types, makes it the most interconnected maze,
which makes direct paths to any point in the maze more likely to occur.
Figure 4.1a is the opposite, with the highest proportion of 2-branches, and the
lowest proportion of all other branch types, making it the least interconnected maze.
Because of its low interconnectivity, it’s solution path winds through the maze, cov-
ering a large portion of the maze grid.
What stands out in Table 4.2 is the completion time of RecBack on resolution
256x256. The other solving path nodes are much smaller. This difference might
look so large as to indicate an error in the test, but looking at Figure 4.3 and 5.4
show that the increase of solving path length has remained relatively even, which
indicates that results had a low variation in the test. By observing the path length
data in Table 4.2, one can discern a pattern that seems to indicate that a lower
amount of solving path nodes and traversed nodes, leads to lower completion times.
This is unsurprising, since traversing nodes is what takes time for a solver searching
for the exit.
Mazes with relatively short solution paths seem to get solved faster. Perhaps
if one thinks of the solution path as "the minimum amount of nodes to traverse
to solve the maze". Solvers traversing mazes with short solution paths would then
at minimum traverse fewer nodes than solvers traversing mazes with long solution
paths.
Kozlova et. al (Kozlova et al., 2015) measured path lengths of the same maze
algorithms as in this thesis. They also found RecBack to have the longest average
path length, Prims to have the shortest average path length, and RecDiv to have
intermediate path length. They used a non-uniform grid of resolution 16x12 for
their maze algorithms, of a lower resolution that in this thesis (lowest 16x16), so the
results, even if similar overall, are not perfectly correlated. But still it is unlikely
that it is by accident that the size orders are the same.
34 Chapter 5. Analysis and Discussion
Percent (%)
Maze Type 6 Time (ms)
300 802 Length Corridor (%) 3 Length Corridor
3.5 Length Corridor (%) 6 Length C
0.7
Percent (%)
RecDi cv s4, s4 311 267s 25 7B6s1 B7640 s260s 76a1
Percent (%)
Percent (%)
60 58
200 5000250 20 0.6 2.5 6
milliseconds
k P5r m s4, s4 300 4 26 3a 7s602 B36B2 ss602 76a7
milliseconds
200 1000 24.550 57
milliseconds
4000 3 40
24
1B, 1B 200
Percent (%)
0.530
milliseconds
RecDi cv 16 34 55 7B67B B76x1 ss673 76s0
100
100 1B, 1B 500 2 200
10
15 4000
23.5
1.5 454
milliseconds
k P5r m 2 s6 7B 7B67B B36sxMaze
Maze Type
Type
Maze Type Solving Time Solving
Solving ss6Time
71
Time 76a1
100
3000 20
Rec. 59 43, 43
0 9.5
1
sB6B4
0.4 231 353 7a64s Maze
RecDi B3631RecDi
cvType
RecDi cvcv 16
Solving Time
x0 Bxa6B46
s26 12ss
74 36B7
50
RecDi cv 43, 43 1.5 BB6s3 10 52 7B60a B46Rec.
s3Rec.59 59 s813a63a ss6 7B
s76
72B3 76s3
00 150 3000 -RecDi59 cv as6
256x256
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
2000 - 32x32 22.5 32x32
251 - 64x64 64x64Rec. 128x128 128x128
B6xa - 256x256
k P5r m 43, 43 0 10 a6 0.5
s0 0 7B60a B362x
-k128x128
P5m
r m ss674 7643
16x16 -- 32x32
32x32 32x32--64x64
64x64 5r64x64
k PRec.m 59k-P 5r128x128 046 3B6x6
128x128
a1 3xsa
- -256x256
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
0 16x16
0.3 32x32 64x64 s6128x128
xx
1 150
64x64
16x16
32x32
64x64
16x16
32x32
16x16
32x32
64x64
128x128
256x256
128x128
256x256
128x128
256x256
16x16
32x32
64x64
64x64128x128
128x128256x256
256x256 16x16
16x16 32x32
32x32 64x64
64x64128x128
256x256
16x16
64x64
128x128
256x256
32x32
Rec. 59 sB0, sB0 746 B4 0 7a64s B36
k P5r m 31 3s63a s2643 36sx
RecDi cv 16x16
sB0, sB0
1000
- 100 2000 49
32x32Bas6s0 32x32 - 64x64 716s1 64x64 B46B4 - 128x128 ss634128x128 - 256x256 7623
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
x128256x256
16x16
32x32
64x64
2x32128x128
256x256
048
k P5r m sB0, sB0 0.5 0.2
116 1B RecDiv 7B6x3 RecBack B36B0 ss633 Prims 767x
0 5 14B6
16x16
32x32
128x128
256x256
16x16
32x32
64x64
128x128
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
256x256
16x16
32x32
64x64
128x128
Rec. 59 B74, B74 1000
s3
RecDiv RecDiv
RecDiv
7a641
RecBack RecBack
RecDiv
B3632 RecBack
Prims RecBack
s2647
Prims
Prims36s0
Prims
x128
x256
6x16
2x32
4x64
x256
6x16
2x32
4x64
6x16
4x64
RecDi cv B74, B74 50 0 48332623 716B1 B46Bs ss63a 7627
k P5r m B74, B74
0.1
s43607 RecDiv
7162B B36B1 RecBack ss63x Prims
7674
0 32 32 32 32 32 32
5.2.3 Corridors
It is hard to draw a conclusion around corridor distribution’s effect on completion
time, since the differences in corridor length in Table 4.4 is at most around 3%, and
at least below 1%. It is hard to make the case that a higher proportion of long
corridors lead to faster completion times, because there is no clear opposite that says
what makes for slower completion times.
Chapter 6
Conclusions and Future Work
In this chapter, conclusions that can be drawn from the tests are stated and presented
as answers to the research questions.
This study has attempted to provide level designers, developers, and game de-
signers with information to evaluate and understand what makes some mazes more
complex than others. To do this a software implementation was developed to per-
form tests on three different maze generation algorithms across five different maze
resolutions, which gathered their solving path length, traversed nodes, corridor dis-
tribution, branch distribution, and completion time data.
RQ1: What is the difference in complexity between the maze generation algorithms
recursive backtracker (RecBack), randomized Prim’s algorithm (Prims), and recur-
sive division (RecDiv), in terms of completion time, when solved using a depth-first-
search (DFS) algorithm?
Answer: Overall RecBack is more complex than RecDiv which is more complex than
Prims which is the least complex. Maze resolution is directly proportional to com-
plexity. This means that in low resolutions, the differences in complexity between
the algorithms are less pronounced than at higher resolutions. The complexity of
RedDiv is more similar to Prims than RecBack.
RQ2: What connection is there between completion time/complexity, and the distri-
bution of branching paths, distribution of corridors, and length of the path traversed
by DFS?
Answer:
It has in the end been observed that using solving-time as an absolute metric
for complexity might not be beneficial since it heavily favors mazes with the longest
35
36 Chapter 6. Conclusions and Future Work
solution-paths. The observation is that the "most complex maze" would be a maze
where every node in the grid is part of the solution path, which might not be ideal
for gameplay scenarios. However it could perhaps still be useful as part of a fitness-
function to be used to craft mazes similarly to what Kim et. al did (Kim & Crawfis,
2015).
References
Ashlock, D., Lee, C., & McGuinness, C. (2011, September). Search-Based Proce-
dural Generation of Maze-Like Levels. IEEE Transactions on Computational
Intelligence and AI in Games, 3 (3), 260–273. Retrieved 2018-04-11TZ, from
http://ieeexplore.ieee.org/document/5742785/ doi: 10.1109/TCIAIG
.2011.2138707
Bae, C.-M., Kim, E., Lee, J., Kim, K.-J., & Na, J.-C. (2015). Genera-
tion of an arbitrary shaped large maze by assembling mazes. In 2015
IEEE Conference on Computational Intelligence and Games, CIG 2015
- Proceedings (pp. 538–539). Retrieved from https://www.scopus.com/
inward/record.uri?eid=2-s2.0-84964443933&doi=10.1109%2fCIG.2015
.7317901&partnerID=40&md5=e95c8a5bcfed6808a0062ca6fb30c048 doi:
10.1109/CIG.2015.7317901
Buck, J. (2011, December). Maze Generation: Recursive Division. Re-
trieved 2018-04-04TZ, from http://weblog.jamisbuck.org/2011/1/12/maze
-generation-recursive-division-algorithm
Buck, J., & Carter, J. (2015). Mazes for programmers: code your own twisty little
passages. Dallas, Texas: The Pragmatic Bookshelf. (OCLC: ocn919295242)
E. Black, P. (2003). weighted graph. Retrieved from https://www.nist.gov/dads/
HTML/weightedGraph.html
E. Black, P. (2005). greedy algorithm. Retrieved 2018-04-09, from https://www
.nist.gov/dads/HTML/greedyalgo.html
E. Black, P. (2014). minimum spanning tree. Retrieved from https://www.nist
.gov/dads/HTML/minimumSpanningTree.html
E. Black, P. (2017, August). cycle. Retrieved from https://www.nist.gov/dads/
HTML/cycle.html
Foltin, M. (2008, August). Automated Maze Generation and Human Interaction.
Masaryk University, Faculty of Informatics, 83. Retrieved 2018-04-05, from
https://is.muni.cz/th/143508/fi_m/thesis.pdf
Gross, J. L., & Yellen, J. (1999). Graph theory and its applications. Boca Raton,
Fla: CRC Press.
Gross, J. L., Yellen, J., & Zhang, P. (Eds.). (2014). Handbook of graph theory (Second
edition ed.). Boca Raton: CRC Press, Taylor & Francis Group.
Joshi, V. (2017, September). Deep Dive Through A Graph: DFS Traver-
sal. Retrieved 2018-04-10TZ, from https://medium.com/basecs/deep-dive
-through-a-graph-dfs-traversal-8177df5d0f13
Kim, P. H., & Crawfis, R. (2015, July). The quest for the perfect perfect-maze. In
(pp. 65–72). IEEE. Retrieved 2018-04-05TZ, from http://ieeexplore.ieee
.org/document/7272964/ doi: 10.1109/CGames.2015.7272964
Kozlova, A., Brown, J. A., & Reading, E. (2015, August). Examination of
representational expression in maze generation algorithms. In (pp. 532–
533). IEEE. Retrieved 2018-04-04TZ, from http://ieeexplore.ieee.org/
document/7317902/ doi: 10.1109/CIG.2015.7317902
Prim, R. C. (1957, November). Shortest Connection Networks And Some Gener-
alizations. Bell System Technical Journal , 36 (6), 1389–1401. Retrieved 2018-
38 Chapter 6. Conclusions and Future Work
1. Choose a random cell within the maze grid (given by its width and height) and
design it as a start cell.
3. Mark cells around the start cell as frontier, i.e. add them to frontierCells set.
39
40 Appendix A. Maze Generation Algorithms
1. Design a randomly chosen cell as the current cell and add it to the stack.
(a) randomly choose one of them and design it as the next cell
(b) add next cell to the stack
(c) create path between current cell and next cell
(d) mark next cell as the current cell
3. ELSE pop a cell from the stack and design it as the current cell
2. Bisect the field with a wall, either horizontally or vertically. Add a single
passage through the wall.
41
42 Appendix B. Code Examples
void main ()
{
const int numNodes ;
Node nodeNetwork [ numNodes ];
B.2. Recursive Backtracker Code 43
shuffleDirections ( directionList ) ;
break ;
}
}
}
int dx = horizontal ? 1 : 0;
int dz = horizontal ? 0 : 1;
int nx = X ;
int nz = Z ;
recursiveDivision ( nx , nz , w , h ,
chooseOrientation (w , h )) ;
nx = horizontal ? X : wx + 1;
nz = horizontal ? wz + 1 : Z ;
// Add directions
List < IntVector2 > directionList = new
List < IntVector2 >() ;
// initializing list of directions
directionList . Add ( NORTHDir ) ;
directionList . Add ( SOUTHDir ) ;
directionList . Add ( WESTDir ) ;
directionList . Add ( EASTDir ) ;
shuffleDirections ( lDirectionCheck ) ;
break ;
}
52 Appendix B. Code Examples
}
}
}
}
return new solverBack ( false , 0) ;
}
Faculty of Computing, Blekinge Institute of Technology, 371 79 Karlskrona, Sweden