Procedural Generation of Three-Dimensional Game Levels with Interior Architecture
Total Page:16
File Type:pdf, Size:1020Kb
Procedural Generation of Three-Dimensional Game Levels with Interior Architecture by William Hamilton A thesis submitted to the Faculty of Graduate and Postdoctoral Affairs in partial fulfillment of the requirements for the degree of Master of Information Technology in Digital Media Carleton University Ottawa, Ontario Copyright © 2019 William Hamilton Abstract Procedural Content Generation can help game developers by automating the creation of content that is costly and tedious to develop by hand. We present a system to generate 3D game levels based on interior spaces such as buildings and dungeons. Our system generates individual rooms by using a shape grammar to recursively subdivide rectangular blocks. Multiple rooms can be joined to form a larger level layout. Our system searches for a good layout based on a fitness function specified by a human designer. We tested three search algorithms for this purpose and found that in almost all cases an evolutionary algorithm produced the best results. Once a level layout has been selected, architectural details are added to the layout by placing modular meshes such as columns and wall segments. The final level can be loaded in Unreal Engine 4, a widely used game engine. ii Preface Looking back on all I have done, I cannot help but feel like one who set out with a flimsy piece of chain and the naïve intention of subduing a terrible whirlwind. Far from capturing it, I was seized by its great force and borne hither and thither before at last being deposited far from where I began. All that I have managed to grasp seems like a thin wisp of cloud, insignificant compared to the mighty forms of darkly intimated heavenly beings I beheld in the clutches of the storm. I have striven in this thesis to diligently describe my thin wisp of cloud. Nonetheless, I hope it offers its readers some suggestion of the greater visions, though it be but a sketch of future possibilities. I would be remiss not to mention a few of the people who have helped me the most over the past two and a half years. This thesis could not possibly have been written without the guidance of my supervisor, Dr. Chris Joslin. For his unwavering confidence in me and his many insightful suggestions, I am deeply thankful. I always left his office feeling more optimistic and sure of my direction than I did when I walked in. I must also offer thanks to my friend Jon Newhall, for helping me edit several sections of my thesis and for sending me surprisingly good advice about academic writing. Jon helped motivate me to work on my thesis every week by introducing me to great board games and then refusing to play them with me unless I worked at least as many hours as I said I would. My brother Richard helped proofread my thesis and caught several subtle errors. Aside from this, he helped introduce me to the fascinating area of procedural level generation, and was always a joy to talk to about my research because of his sincere interest in the topic. My parents have been an unwavering source of support and encouragement not only over the past two and a half years but for the entire span of my existence. Finally, I must thank Kate, my constant companion and the love of my life. — Billy iii Table of Contents Abstract ........................................................................................................................................... ii Preface............................................................................................................................................ iii Table of Contents ........................................................................................................................... iv List of Figures ............................................................................................................................ vi List of Tables ............................................................................................................................ viii List of Algorithms .................................................................................................................... viii List of Abbreviations .................................................................................................................. ix 1 Introduction ............................................................................................................................. 1 1.1 Requirements .................................................................................................................... 3 1.2 Proposed Solution ............................................................................................................ 4 1.3 Contributions .................................................................................................................... 5 1.4 Organization ..................................................................................................................... 5 2 Background .............................................................................................................................. 6 2.1 Game Levels ..................................................................................................................... 6 2.1.1 Types of Game Levels .............................................................................................. 6 2.1.2 Level Representations ............................................................................................. 11 2.1.3 A Human Approach to Level Design...................................................................... 14 2.2 Formal Grammars .......................................................................................................... 15 2.2.1 Key Concepts .......................................................................................................... 15 2.2.2 Types of Grammars................................................................................................. 16 2.3 Evolutionary Algorithms ................................................................................................ 19 3 Related Work ......................................................................................................................... 21 3.1 Procedural Level Generation .......................................................................................... 21 3.1.1 Classic Methods ...................................................................................................... 22 3.1.2 Tree Extension ........................................................................................................ 24 3.1.3 Occupancy-Regulated Extension ............................................................................ 26 iv 3.1.4 Graph Grammars ..................................................................................................... 28 3.1.5 Caves with L-Systems............................................................................................. 35 3.1.6 Rhythm and Flow .................................................................................................... 35 3.1.7 Evolution of Maze-Like Levels .............................................................................. 38 3.1.8 Other Evolutionary Approaches ............................................................................. 40 3.1.9 Answer Set Programming ....................................................................................... 46 3.2 Computer-Generated Architecture ................................................................................. 48 3.2.1 L-Systems and Shape Grammars ............................................................................ 48 3.2.2 Interior Architecture Generation ............................................................................. 53 3.3 Summary of Novelty ...................................................................................................... 56 4 Methods ................................................................................................................................. 57 4.1 Overall Design................................................................................................................ 57 4.1.1 Building Architecture and Level Design ................................................................ 58 4.1.2 Resources Used ....................................................................................................... 60 4.1.3 Grid Measurements ................................................................................................. 61 4.2 Room Generation ........................................................................................................... 62 4.2.1 Shapes ..................................................................................................................... 62 4.2.2 Connectors .............................................................................................................. 64 4.2.3 Rules ....................................................................................................................... 66 4.2.4 Room Generation Algorithm .................................................................................. 67 4.2.5 Examples of Room Generation ............................................................................... 70 4.3 Level Layout .................................................................................................................. 73 4.3.1 The Level Region ...................................................................................................