Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is...

34
Procedural Generation of Roguelike Levels COMP4560 Alexander Gellel [email protected]

Transcript of Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is...

Page 1: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

Procedural Generation of Roguelike Levels

COMP4560

Alexander Gellel

[email protected]

Page 2: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

1

Table of Contents Acknowledgements....................................................................................................................................................................2Abstract...........................................................................................................................................................................................3

1.Introduction...........................................................................................................................................41.1GenerativeScope.................................................................................................................................................................4

2.Context/ExistingWorks-LiteratureReview..............................................................................52.1WhyisthereaninterestinPCG?..................................................................................................................................52.2ConceptualDistinctions....................................................................................................................................................52.3ContentRepresentation...................................................................................................................................................62.4VariedGenerativeApproaches......................................................................................................................................72.5QualityofProcedurallyGeneratedContent..........................................................................................................132.6LiteratureReviewConclusion....................................................................................................................................13

3.Design....................................................................................................................................................143.1Dungeonsasachoiceofleveltype............................................................................................................................143.2ContextFreeGrammars................................................................................................................................................143.3CellularAutomatainspiredbehaviour....................................................................................................................153.4Assessinglevelquality...................................................................................................................................................173.5Implementation.................................................................................................................................................................18

4.ResultsandDiscussion....................................................................................................................194.1InitialObservations.........................................................................................................................................................194.2Testing...................................................................................................................................................................................214.3.Discussion...........................................................................................................................................................................23

5.Conclusion...........................................................................................................................................256.References...........................................................................................................................................267.Appendix:.............................................................................................................................................287.1Glossary................................................................................................................................................................................287.2ListofFiguresandTables.............................................................................................................................................297.3ProjectFiles........................................................................................................................................................................307.4ExperimentalandTestingDetails.............................................................................................................................317.5Readme.................................................................................................................................................................................317.6StudyContract...................................................................................................................................................................31

Page 3: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

2

Acknowledgements Thanks to Penny Kyburz, for enabling me to explore problems in a field that I find fascinating within my love for Video Games, and for helping me find a direction to take this interest.

Page 4: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

3

Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video Game Industry as a means of creating infinitely fresh and varied content. An examination of existing approaches in formal research is conducted, and this paper offers an approach to level generation for Roguelike Dungeon style levels based on those findings. A generator of simple dungeon style levels is constructed and examined for its ability to create level layouts that are always playable; utilising a hybrid technique combining the usage of Context Free Grammars and behaviour imitating the nature of a Cellular Automaton in order to generate a description of levels and their physical space respectively. The generator proves successful at consistently generating dungeon layouts that maintained completability at all times with sufficient variation, when accounting for occasional but infrequent need for corrective actions. This work emphasises the relative ease at which this behaviour produces successful results suggests that there is a lot of value in hybrid approaches to automated level design, and proposes a new heuristic by which to assess dungeon style level content. Key Terms - Procedural Content Generation (PCG), Context Free Grammars, Game Design, Dungeons, Roguelike

Page 5: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

4

1. Introduction Procedural Content Generation (PCG) is the generation of data via algorithmic means, instead of manual input. Easy to use and consistent PCG methodologies make for a powerful means for a Game Developer to create games that are continually replayable and enjoyable. PCG is not a new concept to the field of game design, the classic Dungeon Crawler Rogue (Michael Toy and Glenn Wichman, 1980) is remembered fondly for its simple randomly generated maps and core gameplay loop that has the player reset back to the start on the event of their failure. Rogue has its legacy in the form of the ‘Roguelike’ (sometimes ‘Roguelite’) genre of games, a genre loosely defined by use of randomised levels and permanent player death. The Roguelike genre is an interesting one, forming much of the basis for PCG in commercial games due to its reliance on every play session being a fresh one, but the vast majority of Roguelike games come from independent developers and studios instead of large production companies. The genre has even been explored as a training ground for AI [16] as it serves as an ever-changing environment. This work intends to investigate methods of Procedural Generation in existing research and produce its own prototype level generator for a non-specific Roguelike Dungeon Crawler based on these findings, with an additional goal of ease and flexibility of use in its methods.

1.1 Generative Scope This Project is only concerned with creating an effective and easily usable Dungeon layout generator, and does not take particular attention to detail the contents of the rooms it creates, assuming that they would be pre-existing assets or be constructed by separate existing methods. The main focus is levels for use in the context of a Roguelike Dungeon Crawler game based on no specific, however much of the design traits for such Dungeons, notably the approach to Key/Lock pairs and overall structure will be based more around the style of classic adventure game Legend of Zelda (Nintendo, 1980) as this best exemplifies the kind of structural rules that make dungeons an interesting content type to generate. It will not feature more complex mechanics and gameplay systems, as these are game specific and do not contribute to the task of generic level generation in their own right. A common approach to dungeon level generation is to place a few separate rooms and “drill” tunnels between them [28], this approach seeks to create a more cohesive cluster of spaces. Produced Work:

1. A review and analysis into different approaches to PCG 2. A simple Mission description generator based on context free grammars 3. A level space generator with varying non-deterministic rules. 4. A heuristic by which to assess Dungeon style video game levels.

Page 6: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

5

2. Context/Existing Works - Literature Review

2.1 Why is there an interest in PCG? Controllable Randomness is a desirable trait to Game Designers for a number of reasons. It is common to evaluate games by their amount of content and replayability without becoming boring to a player. However, for the most part, quality game content has to be constructed by designers and developers, which is both difficult and time consuming. Procedural Content Generation offers two primary gains to the field of Game Design. The first is a potential for nearly infinite content and variation for each play session. Extremely high profile games of recent years such as Minecraft (Mojang, 2011) with its Procedurally Generated worlds and Fortnite Battle Royale (Epic Games, 2017) with its random distribution of weapons for players to pick up have shown that randomness and frequent variation in game content are valuable traits for a game’s longevity and success. The second is to create wholly unique experiences for a game, when more of the game is about interaction with systems created by the game, rather than by the designer, players can come out with their own personal stories of what happened when they played a game when compared with how others played it. This concept comes under ‘Emergence’ which is not discussed in depth in this paper, but is another notable value that PCG can provide to the industry of game design when more and more of a game’s systems can vary from play session to play session. Emergent gameplay and emergent narrative refer to an idea of interaction between systems and a player leading to complex and unique situations beyond the design of those mechanics [27]. Game content with high degrees of randomness and variation often provides a strong basis for these unique experiences, as a playthrough can be defined by a lucky interaction between player and game. Togelius et al [5] claim that “the field of procedural content generation (PCG) covers a wide set of problems and methods that are of high interest to both game developers and academic researchers”. Whilst this may be true, the scope of formal research into methods of Procedural Content Generation is somewhat limited, and the released games that utilise such content for the most part do not publish their methods or source code outright. Procedural Generation does not only apply to maps, levels and reward distribution however. It has applications in the rendering of detail in natural looking environments; SpeedTree [21] for instance is a means of procedurally generating natural looking trees with a natural variation, and is used in many existing games. Some of the techniques reviewed in this project are not specifically those used in level and map generation, but were examined for their general application and what value they can provide as a means of content generation.

2.2 Conceptual Distinctions Togelius et al [11] define numerous distinctions that are useful as a means of defining kinds of Generation. The first of these is ‘Online’ and ‘Offline’ Generation. The former describes a generator capable of acting near immediately in real-time, making it important that the method is predictably fast and acts with sufficiently consistent quality. The latter is more useful as an assistive tool for designers, and has much less of a concern with predictability. Togelius et al [11] define two core approaches to PCG, “Constructive” and “Generate and Test”. A generative approach is entirely dependant on its methods and rules to generate both without failure, and to ensure that the resulting output will be of sufficient quality.

Page 7: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

6

Conversely, a Generate and Test approach is built in two parts, one method which generates content, and another which evaluates it based on some relevant criteria. If sufficient criteria are not met, the content is disposed of and the generator is called once again until something more suitable is found. They also take this definition a step further and create a separate definition of a “Search-Based” approach, one that generates a large population of content and evaluates it by some heuristic to find a good or best desired instance. These are visualised in Figure 1.

Figure 1: Togelius et al’s definitions of the 3 main approaches to PCG [11]

The distinctions between such approaches are valuable as they can effectively define all technical approaches investigated later in this paper. However, they also claim that hybridization of approaches to suit specific problems will likely be valuable going forwards. Togelius et al continue to define two kinds of content that can be generated. ‘Necessary’ and ‘Optional’. What is important to take away from this definition is that all Necessary content must always work perfectly without fail, where as optional content can be less strictly functional or optimal. The requirements for this will vary heavily with individual game design, but it’s an important factor when considering how a level generator is to function.

2.3 Content Representation The final categories discussed by Togelius et al [11] is the separation of how much information a generator is given to start with. The first of these is ‘Seeds’ and ‘Parameter Vectors’. A generator offered only a Pseudo-Random-Number Generator (PRNG) Seed relies entirely on its generative rules to construct interesting variation, where as more information offered allows for higher degrees of configuration from players and designers, and also opens up more possible analytical techniques such as utilising machine learning to find optimal balances of settings, as will be looked at later. The distinction between a ‘Stochastic’ and ‘Deterministic’ generation method is a little bit more nebulous, but asks whether or not given identical starting data will lead to some given algorithm generating identical output results. Deterministic methods allow for a form of compression, for example a level need only be

Page 8: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

7

saved as its seed if it can be guaranteed that a generation method can always unpack such a seed into the same resulting level. Dormans [7] defines two separate components to Level PCG. One is the physical ‘space’ in which represents the actual existing layout of a level, and the other is the ‘mission’ which describes the sequence of tasks a player must complete in order to successfully complete the level. These two pieces of a level are mapped to one another but otherwise exist wholly distinct.

2.4 Varied Generative Approaches Numerous approaches have been utilised in regards to the Procedural Generation of Video Game content in both research and commercial games. As most game developers do not publish their own methods as source code, their exact implementation is difficult to examine; however in the somewhat limited academic scope of PCG there still exists a broad spectrum of Computer Science techniques explored for what value they can provide.

2.4.1 Markov Chains Snodgrass and Ontañón [2] utilised Markov Chains and Random Markov Fields to generate levels in classic 2D Sidescrollers, including Kid Icarus (Nintendo, 1986) and Loderunner (Doug Smith, 1983), but most notably Super Mario Brothers (Nintendo, 1985). They tested a variety of Markov models for generating these levels, most of which being variations of Multi-Dimensional models. It is important to note that this experiment was conducted specifically to observe the method’s handling of the statistical properties of these levels, and has no encoded domain specific knowledge of the kind of features necessary for its output to function correctly.

Figure 2: Snodgrass and Ontañón, success rates with Markov Chain generation [2]

Snodgrass and Ontañón [2] observe that these Mutli-Dimensional Markov Chains create aesthetically pleasing levels, sampling in only a fraction of a second, giving such an approach suitability for use as an online form of generation. However the exceptionally low success rates for the Loderunner and Kid Icarus, as well as a failure to achieve total playability for all levels for Super Mario Brothers, as shown in Figure 2, suggests that such models aren’t sufficient as a means of generation of platformer type levels on their own, due the model having an inability to encode specific knowledge about the rules of the game that allow it to be playable.

Page 9: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

8

2.4.2 Cellular Automata Cellular Automata describe a model of cells with a finite set of states not too dissimilar from video game level design. Johnson et al [4] used Cellular Automata to create infinite and natural looking caves spaces. They compare their method to a purely random one and note that the Automaton approach produces very natural looking spaces where a purely random one does not. Figure 3 depicts two of their generated patterns.

Figure 3: Johnson et al’s Caves [4]

They note success with generation time being very fast, with both their random model and Automaton model able to generate such formations in less than a millisecond each, making such methods highly suitable for online types of generation. However, these offer only spaces carved out without structure or purpose, and would require additional methods to define meaningful content.

2.4.3 Grammars Generative Grammars have been explored in the PCG space for a few uses. A linguistic based model consisting of a set of terminal and non-terminal symbols, they can recursively expand themselves into something much larger. Traditionally in Computer Science, these techniques are used in code parsers to validate syntactical correctness. What they offer to the field of PCG is a means of structured recursive generation with strict rules to define what is and isn’t possible. This makes it highly suitable for generating an intended sequence of necessary actions for a player to take, such as the “missions” described above in 2.3. Doran et al [6] take the idea of using grammars further, using Generative Grammar Models to generate quests in the style of existing MMOs. The authors identify that the substitution nature of grammatical structures allow for easy pseudo-random selection of components (e.g Characters to talk to, locations to visit, items to find). Their set of generation rules is represented in Figure 4.

Page 10: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

9

Figure 4: Doran et al’s MMO quest rules [6]

For similar purposes, Dormans [7,8] proposes two models of Generative Grammars as an approach to both Missions and Spaces. These are also later mapped to player experience models [17]. The authors give an example of an extremely simple grammar that defines the structure of a basic Legend of Zelda (Nintendo, 1986) style dungeon:

1. Dungeon -> Obstacle + treasure 2. Obstacle -> key + Obstacle + lock + Obstacle 3. Obstacle -> monster + Obstacle 4. Obstacle -> room

Here, Capital first letters denote non-terminal symbols, where lower case denotes terminal. In their work they used Graph Grammars to generate branching substructures of optional content, as well as somewhat linear key lock pairs and some more scatted multi-piece keys required to bypass single locks. It was then mapped to a space using Shape Grammars, preserving the structure of the original graph as a physical level. The primary strength of grammars as a generative method is that they offer rigid structure with a natural hierarchy that is easily enforced, and that Terminal components can easily be substituted in for the important features of a target game. This is important for level generation that requires any kind of intended sequence or has properties not easily represented by a simple statistical pattern. Dormans’ model of Mission and Space is particularly effective, as it offers a means of structuring content in a way that other methods discussed do not.

2.4.4 Machine Learning Techniques Machine learning techniques offer an interesting approach to level generation. Like the Markov chains, these are heavily reliant on statistical properties found within datasets of existing manually designed game levels. Summerville and Mateas [15] used machine learning techniques to generate levels in The Legend of Zelda: A Link to the Past (Nintendo, 1991). They first placed a fixed number of rooms based on the learning of Bayesian Network capturing various high level features; and then populate those rooms by taking two samples from a dataset and interpolating them. The authors note that this process does not guarantee

Page 11: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

10

the generation of completely playable rooms in and of itself, in which case it must be discarded, but also that properties held by either source room will necessary be maintained in the combination process. More recently, Torrado et al [26] used conditional Generative Adversarial Networks to create simple single room content for the Legend of Zelda, targeting a single Lock/Key pair and basic enemy distribution. They note while GANs have had much success in generating simple content such as images they tend to fail to capture the structural rules that underlie a well designed game level, and this result was demonstrated in only achieving at most a 58% playability rate with a training set of 45 levels, which is unsuitable for a generative method and even somewhat unreliable for a Search-based one without a much larger dataset. The biggest weakness of all Machine Learning models for PCG is this lack of readily available datasets for most existing games or kinds of game content. If a game designer wished to use such an approach in their own game, they would first have to create a large amount of valid levels to begin with before they could implement a Machine Learning based generator. Summerville et al discuss in their broader look at Machine Learning in PCG [13] that Games are Multi-Modal systems that are not as easily analysed as other domains such as images due their nature as interacting systems and more intricate underlying patterns at both the high level and details. Machine Learning however has other uses beyond the level generation itself. If an existing content generator is available, Machine learning techniques can be used to configure the settings such as size and difficulty. Roberts and Chen [14] constructed a proof of concept level generator for Quake (id Software, 1996) that could adjust its parameters based on a set of 122 features provided by output logs, and this was evaluated against existing models of player profiles (a concept discussed in Section 2.4.6). This allows a game to adjust its difficulty and content types as it begins to learn what a player performs best at or enjoys.

2.4.5 Evolutionary Algorithms A growing field within the study of PCG is the use of Evolutionary Algorithms, a class of Optimisation algorithm dependent on higher level metaheuristics. Although often considered a subset of AI and Machine learning, it is distinct enough here to separate it from the above category. Frade et al [23] used evolutionary methods to model 3D terrains, with the intent of preserving low slopes that allow players to effectively move within a space. They devise a fitness function that assesses the edge length of raised sections of a landscape, designed to be minimised such that maps generate with more interesting and complex spaces rather than simple large formations. The authors found success in generating varied terrains with large lowly sloped spaces suitable for both player traversal and feature placement, however with no focus intended on realism some of these can look chaotic and unnatural as a result. Togelius et al [12] explored a model of Multi-Objective evolutionary functions. They note specifically that like price vs features in car shopping, some elements of good content naturally conflict will naturally with each other, and thus such evaluation functions need to be meticulously crafted to maximise these features. These experiments were carried out on strategy game maps, and made use fitness functions looking for density of resources and the distances between player bases, as well as factors such as existence of chokepoints to be discarded. The optimisation of these maps was then carried out by use of Multi-Objective Evolutionary Algorithms, recombining and selecting from a random population of maps to find ones deemed optimal by their properties. They found that some properties, such as base

Page 12: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

11

distances, were directly at odds with making interesting maps, as the optimal solution is to remove all terrain in between, or that maximising resource distance from bases led to high clustering of resources Furthermore, in a Search-Based approach, Evolutionary Algorithms can be utilised as a means of selection of appropriate levels from the population. Ashlock et al [10] explore this idea using a Tournament Selection method to identify the best maze-like levels generated based on a set of 4 Fitness functions they defined, which are computed by simple Dynamic Programming methods. The performance of the population did indeed increase with the generations, and the mazes evaluated on the different fitness functions generated in notably varied ways. Similarly, Valtchanov and Brown [19] observed similar results when their Evolution of dungeon levels with multiple regions hit a local optimum that to some regions only generating as their starting room. Ostensibly, with the appropriate domain specific fitness functions Genetic Algorithms provide a powerful means of selecting good levels from a Search-based population, but it is not a flawless solution. Evolutionary Algorithms offer a lot of promise in the field of PCG, as they handle broad random populations and naturally reach solutions deemed optimal by their attached fitness functions. This however is also their biggest drawback, they need a clearly defined fitness function (or set of functions) against which content can be evaluated, which requires quantifying good game design into a set of objective rules, which not only vary by game but may struggle to capture the essence of an intended experience when abstracted to such a degree.

2.4.6 Profiling Once existing generative methods are available, they can quite effectively be configured against models of player preferences. Yannakakis and Togelius [3] have investigated the use of player profiling to model preferential experiences and configure level parameters to those models. In their work, a player’s experience can be modelled both directly and theoretically in a variety of ways, proposing that such a system could be utilised for real-time adjustments to the quality of game content to personalise a game experience. These methods are promising but require existing generation systems to handle the core process, which can then be configured by such profiles.

Page 13: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

12

2.4.7 Direct Comparison

Table 1: Techniques and PCG Technique Generative Strengths Generative Weaknesses

Markov Chains and Random Markov fields [2]

Fast speed, aesthetically varied, outputs resemble statistically similar distributions of components.

Reliant on statistical properties on a local scale, fails to see long term dependency Needs active repair utilising domain knowledge

Cellular Automata [4]

Fast, simple. Low cost. Convincingly ‘natural’ environments

Unstructured, Chaotic. Lacks overarching control or long term understanding.

Grammars [6, 7, 8, 17]

Structural rules allow for lots of control. Definable Terminal elements allow for easy substitution and enforcing of important features

Rules aren’t versatile without manual changes.

Machine Learning [13, 14, 15, 26]

High variety, capable of capturing statistical patterns of “real” levels. Bayes Networks can recognise higher level features.

Often needs “repair” of unplayable sections. Requires extensive data-set, suitable for existing games not new ones. Game content has underlying rules that statistical analysis tends not to capture,

Evolutionary/Genetic Algorithms [10, 12, 19, 23]

Naturally finds optimal solutions, high variation as a product of recombination.

Highly dependant on meaningful fitness functions to separate good from bad. Can get stuck in local optima.

Player Experience Models [3, 14, 17]

Configurable to player interests or in response to player evaluations

Dependant on existing configurable generation methods.

Table 1 draws a side by side comparison of the offerings and limitations provided by the different techniques discussed in the Sections above. Many approaches have strengths that oppose the weaknesses of others, which would suggest that a hybrid approach could effectively cover the weaknesses in one method with the strengths of another. The Machine Learning family of approaches are strong in their performance, but are dependent on access to strong datasets and meaningful evaluation functions that may not always be available, making them unsuitable for PCG systems being built from the ground up.

Page 14: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

13

2.5 Quality of Procedurally Generated Content. Like with any form of data, there is a need to evaluate and process content generated by these tools. This is especially true for generators utilising any kind of Search-Based approach as discussed above. As all games have their own rules and restrictions, as well as many subjective quantifiers of quality for generated content, the only truly shared evaluation factor for generated levels is whether or not they are physically completable or playable. Generative approaches that rely entirely on their rules to always provide playable content without fail are less exposed to this need for evaluation. For example, a simple 2D side-scrolling level in Super Mario Brothers must not feature any jumps that can not be made. In their use of various Markov Chain models [2], Snodgrass and Ontañón achieved as high as 90.4% completability for a set of 1000 levels generated within Super Mario Brothers, but unless this value is 100% a level generator must always be prepared to discard or actively repair it. The simplest approach is of course to have human players playtest such levels, but this only helps a designer verify an overall consistency of quality in their approach, rather than help a generator assess its own content actively, as would be needed in any Search-Based methodologies. Summerville and Mateas [15] proposed an interesting method of comparing their levels based on their likelihood with a Bayesian Information Criterion in comparison to a set of human authored levels, but as discussed with the Machine Learning techniques above this is only useful when one has an existing dataset with which to compare against, and thus of no use to a Game Designer trying to build a level generator for their new game. Some Authors like Ashlock et al [10] devise unique fitness functions against which to measure the ‘interestingness’ of generated content based on various factors, but these are usually bespoke to the specific content produced and lack little universal application to content generators. Many researchers within the field specifically lament the lack of universal measures by which to compare the quality of levels generated by PCG, noting that it is in itself an open research question. Modelling the processes of content generation more formally within a framework as done by Amato and Moscato [9] could also help lead to a more universal system of designing content generation, however most game creators will likely adhere to their own unique designs dependent on a game’s needs.

2.6 Literature Review Conclusion In this section, we have examined various approaches taken to Procedural Content Generation in game design research, and how these can be evaluated, defined and analysed. Each of these have limitations on the kinds of level content they can produce to sufficient quality or the requirements needed in order to be able to produce it. This project intends to create a prototype simple level generator utilising a combination of the structural rules and design option potential provided by Generative Grammars, but the simplicity and speed of Cellular Automata style behaviour in order to map it to a physical space, as based on the strengths of each method described above and then also to define a unique evaluation metric suited to the types of level it generates.

Page 15: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

14

3. Design This project intends to hybridise two of the approaches to PCG discussed in Section 2 to produce a simple but easily controllable Dungeon-style level generator, with a primary focus on the distribution of necessary content and consistency in performance.

3.1 Dungeons as a choice of level type The level style chosen for this generator is that of a classic 2D Top-Down Dungeon, inspired by the Roguelike genre but functionally more akin to The Legend of Zelda discussed prior. Dungeons make for one of the most interesting test bases for level generation because they possess a couple of interesting properties. The first is that they are neither linear nor open world; that is to say they are not a single path of necessary obstacles, but they also do not simply exist as a single open space for a player to wander freely about, with no rules or intended direction. Typical dungeons offer a definite path to completion, but finding that path often requires exploration from the player, which poses an interesting challenge for level designers as they must both impose structural rules controlling where a player may and may not go at given times, but equally must produce spaces within those levels that are open ended enough that a player’s spacial awareness and navigational memory is tested. This tends to be achieved by Lock and Key pairs, or an equivalent system disguised by other means (for example a player may require a specific item to break down a wall, or need an upgrade that allows them to traverse some kind of perilous terrain). Such conditionally passable obstacles break the level into Subsections, where a player must often explore the level, solve puzzles or fight enemies until they find a Key that allows them to pass through to another section. As such, for a level to be playable, all Keys (or their equivalent) must be reachable before their intended locks, and their generation as pairs is deemed necessary content. This Generator will focus on producing levels with intent to ensuring that such subsections are controlled and completable. The second property is that as a data they are easily represented. In this instance, we look again to the older Legend of Zelda style of Dungeons, or even the levels of the roguelike The Binding of Issac (Edmumd McMillen, 2011) which consist of a grid of equally sized, distinct, adjacent rooms. Grids are typically an ideal representation of data because they’re very easy to define. The rooms each possess their own content, and a set of open or closed doors that allow movement to connected rooms, and some of these doors will be locked, requiring a key to progress. These rooms can also be of pre-existing types, allowing them to be conjoined and arranged independently of their content, making it suitable for designers constructing levels in which they already have designed specific content.

3.2 Context Free Grammars The first of the techniques selected will be the use Generative Grammars to define a “Mission” much like those described by Dormans [7,8]. In this instance, the grammar rules will only be recursively generating a single string for their output, used to describe a rough flow and intended order of room types that a player will visit. The grammar rules will enforce the generation rules such that it generates as intended on all occasions, however this process is also very fast and can be used rapidly to treat this as a Search-Based problem. In the context of Dungeon Style levels, these top level rules easily enforce any necessary structure that may be otherwise overlooked by the space generation methods. For instance,

Page 16: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

15

starting all generation with a rule defining a start and end point, and filling the content between it recursively:

Dungeon -> start + Content + end Or to enforce higher level rules, such as a forced minimum number of rooms, or even to ensure that a set of important rooms occurs in sequence:

Dungeon -> start + room + room + importantroom1 + Content + importantroom2 + end In addition, this approach to rules also forces all Keys to generate in appropriate pairs with a Lock such that no Lock exists without a corresponding Key, whilst also ensuring that every Key appears before a Lock in all circumstances. This is achieved by only defining rules that can generate keys in such a way that this order is maintained. In this context keys are universal to any lock rather than bound to a specific lock, so by recursively generating a new Lock-Key pair within another one, the new lock does not directly impede the progress on reaching the original one that generated first. As such, there is always going to be one or more Keys before any Lock with a simple definition.

Content -> Content + key + Content + lock + Content Content -> room

These Terminal values can be easily substituted, for instance a key lock pair could be replaced with a game specific item, for example a jetpack and a bottomless pit to cross. All that matters here is that the Lock component is considered to be impassable without the appropriate key. No particular generative rule set is emphasised in this paper as the intent is for this generator to configurable to the needs of a generic game, but a single rule set will be used in most situations for consistency. Defined below is a simple recursive grammar designed to output similar but varied descriptions for the space generator.

1. Dungeon -> start + room + Content + room + end 2. Content -> Content key Content lock Content 3. Content-> room Content 4. Content-> enemy room 5. Content -> room 6. Content-> Content Content

3.3 Cellular Automata inspired behaviour To generate the physical spaces of which the Mission describes, behaviour based on Cellular Automata is ideal, as it offers both speed and a decently natural feeling distribution of its constituent parts. Such Automata produce somewhat chaotic but natural spaces, but lack in structure and order, making it difficult for a designer to apply any intended content within it, which the strict rules of the Grammar system from 3.2 can provide. Furthermore, our dungeons exist as a grid, which in this case can naturally be modelled as cells without additional alteration. The approach taken in this work is inspired by Cellular Automata, but formally speaking it is not one due to the use of non-determinism, and information being provided beyond the scope a cell’s immediate neighbourhood.

Page 17: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

16

The Generator is given the Mission Description in the form of a single string, as generated by the Grammar described in 3.2, however such an approach also allows a designer (or even a player) to submit a custom string to the Generator should they wish for even more control. We want to encode as little higher level understanding of the structure into the actual space generation as possible, to keep it generic. This string controls the size and the overall distribution of content within the level, independent of the actions it takes. The “lock” symbol will be the defining feature separating subsections of the level from each other; these subsections will be depicted as different colours for clarity’s sake. The Generator is able to place each room individually, one at a time and in the order described by the initial string, following simple but pseudo-randomised rules. Two main variants of the rules were devised; in both a single room at any given time is considered the current active cell, and it will always attempt to move to an empty cell to place the next room. The first rule is more true the automatic nature, the program is given the location of its start room, and it then selects a pseudo-random room from its immediate neighbourhood that is a valid move and then moves to it to place the next room, which is marked as the type of the current symbol in the mission. It maintains no further knowledge of the entire board in this process. This process is repeated for each symbol in the mission description until it reaches the End room, or until the program is incapable of making a move, as shown in Figure 5. This simpler method will serve as a baseline of completability to compare to the others.

Figure 5: Rendition of the simplest generation having no valid options With the second rule, the generator attains knowledge beyond the single active cell. For any given subsection of the map as separated by the Lock, the generator evaluates its surroundings and picks the first random valid direction branching off from the room that is closest to that section’s average centre point as it can reach, based on Manhattan distance. This will henceforth be referred to as a subsection search, an example of which is shown in Figure 6, and it will allow the space to appear as though it’s growing around a natural cluster rather than tracing a line while leaving a trail. Then two uses of this search rule are proposed; in one instance the generation will use this rule at all times, a persistent subsection search and the other it will use the normal randomly selected neighbour, and only resort to this subsection search when it hits a dead end that it can no longer advance from, subsection search on halt. One final rule is added to allow the generator to overwrite its current location should no possible moves exist even after this addition, in order to force an end by replacing unimportant rooms. This is a generative equivalent to repairing, acting as a failsafe to ensure completability above all else, as the central attribute of successful level generation. A flag will marked during generation to indicate if this has occurred.

Page 18: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

17

Figure 6: Rendition of the generation options for the same map as Figure 5, but with the

subsection search rules Once the full Topology is generated, the Generator will go back and iterate over all the rooms and open pseudo-randomly selected doors between rooms of the same subsection colour based on an arbitrary probability it is given. This allows the subsections to open up for exploration without having to encode in higher level patterns, as well as provide a means to force totally open or totally constrained subsections at the extremes.

3.4 Assessing level quality As no universal measures for quality of Video Game levels exists, a bespoke evaluation heuristic has been devised for comparing the approximate ‘interestingness’ of the generated content, for both differentiating the rules from 3.3 but also for potential use in a Search-based design. In the case of a Dungeon style level, we want a way to identify the semi-linearity property defined in 3.1, to evaluate levels for being both structured and encouraging exploration at the same time.

Figure 7: Left - Rendition of an ‘interesting’ path, Right - a not ‘interesting’ one in the same

section layout Defined here are two paths through a dungeon, the first being the Critical Path, that is the shortest path required to complete the level, by attaining all keys and taking them to all locks to reach the End. The second path, which we shall call the Spine, details this same path however it does not factor in the journey required to find any of the keys. That is to say it is the critical path consisting of all the start and end points, and the locks all intuitively fall on such a path. The primary heuristic the generator will assess levels on, if configured to produce more than one in a Search-Based manner, will be to assess the total difference in paths length of these two defined paths. This Path Difference heuristic can be defined as: !"#$%ℎ'()%)*+, − !"#$%ℎ./)#"

Page 19: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

18

The larger the difference, the more a player ideally has to wander around the map to find the necessary keys to traverse it to completion. Assessing the Critical Path length alone would encourage selection of a single long winding path, which would make for a more linear level. By contrast the difference between the two proposed paths rewards short Spines with spaces branching off them. Furthermore, this subtractive value helps to normalise the resulting value across differently sized dungeons. Figure 8 visualises the difference in the two paths. As all the rooms will have an index in order of their generation, this allows the Keys and Locks to be assessed in their intended order with point to point pathfinding over the 2D space.

Figure 8: The Path Difference for a Subsection. Critical path in Green, the Spine in Red.

3.5 Implementation The Generator is assembled separately in its two parts. The Mission Generator is built on a simple technique, and produces its output as strings. It is built as a Python script Sentence Generator built around [22], using a convergence rule to help limit the recursive pattern from generating forever and then modified with the Dungeon generation rules from 3.3. It is fast and can be easily configured to produce a large population of Missions in a Search-Based manner. The Space Generator is constructed in the Unity [24] Game Engine, a common development tool for games across many platforms, using C# as its primary scripting language. The Dungeon Generator program contains a core class that handles the generation methods, and produces a large, finite, 2D grid of Rooms. Each Room is defined as a class that has properties detailing its type (inherited from the Mission description), the status of its doors, and the colour of the subsection it is contained in.

Page 20: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

19

4. Results and Discussion As no standardised benchmarks exist for PCG at present, the generator and its methodical variations will be analysed in terms of their ability to produce levels that are possible to play, and then in the performance of the two more refined search methods in how they compare to one another within the provided heuristic. Any constructive approach to level design is insufficient if it fails to achieve 100% playability of its levels, where Search-based designs are allowed some leniency.

4.1 Initial Observations For the grammar/mission generator, not much meaningful formal analysis can be done, as there is no absolute criteria against which it can be compared. Context free grammars are a solidly tested concept in the field of Computer Science, and the program does output mission descriptions as intended. Keys always occur before Locks, and some simple rules were put in place to select Missions with well spaced Locks, rather than multiple ones in succession. A sample of a selected top five selected of one hundred Missions produced by one run of the generator is provided in Figure 9. Variety of output depends a lot on the kinds of content a designer would include within their game, and the variety of rules defined. Analysing the full results of 100 generated missions leads to massive variations in size, many of which are too small or large, suggesting the selection function is narrowing the field appropriately.

Figure 9: Sample Mission output

Informal observations of just running the space generator program, the levels produced are sufficiently varied in their topology, however with enough repeated runs occasional repeated patterns born of the consistent ruleset do show themselves. This however is true of any PCG system a player spends enough time with and could be considered a benefit as the experience should feel somewhat consistent between play sessions and never degrade into absolute chaos. The neighbourhood only version did not have sufficient complexity to generate complete levels consistently, and it would halt generation on a number of tests. This is because to halt it only needs to reach a point where all four directions around it have already been set, an outcome which is quite likely especially on generations with a large number of rooms. Between the two variations of the subsection generation rules, the one that persistently selects from its subsection seemed to display a much more varied distribution of rooms, and a lesser number of long uninteresting corridors with no freedom of exploration. These levels seemed to be completable at all times on observation of Lock and Key distribution, and had only infrequent generative defects when the generator had to cut it short to ensure it stayed completable, or when a subsection of the same colour fused with another to create a central branching area, which is easily addressed by configuring the number of colours differently. A selection of generated levels from the subsection search methods can be found in Figures 10 and 11. The space generator loads and analyses a single level in a couple of seconds, including the overhead from Unity rendering the components, making it suitable for runtime within a single game load screen, but generating large quantities of levels can much slower.

Page 21: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

20

Figure 10: Samples of the subsection on halt rule. Note the long winding corridors. Start (red subsection) and End (yellow subsection) rooms highlighted. Coloured doors are Locks.

Figure 11: Samples of the persistent subsection rule. Note the increase in branching rooms and clustered sections. Start (red subsection) and End (yellow subsection) rooms highlighted.

Coloured doors are Locks.

Page 22: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

21

4.2 Testing

4.2.1 Grammar Generator performance Although quality of the Missions is hard to assess the performance of the generative method and basic selection of good candidates is sufficiently fast for large quantities of produced missions to be suitable for any usage. A timestamp is taken at the beginning and end of runtime, across 10 samples for 100, 1000 and 10000 productions.

Table 2: Mission Generator runtimes 100 Missions 1000 Missions 10000 Missions

Average Time (s) 1.09 x 10-2

1.05 x 10-1 1.07

As for the properties of the generated Mission descriptions, due to the structure of grammatical rules, 100% of Key/Lock pairs were generated appropriately, and the Start and End always fell at the first and last symbols respectively. These were evaluated automatically across numerous sample sets without fail.

4.2.2 Space Generator performance Each Space generation rule was tested for five hundred generated levels and automatically evaluated for both completability and against the Path Difference heuristic using pathfinding between the important points. The neighbourhood only variant of the program simply reported back a False value whenever it hits a point where it can no longer progress, and the subsection search variations report whether they had to force the generation to come to its end. All tests were conducted on a single manually selected Mission description, consisting of 58 rooms and 8 Lock/Key pairs. This was created specifically to be somewhat larger than those typically selected by the Grammar generator, in order to increase the likelihood of collisions in the space generation behaviour. The chance for a door between adjacent rooms of the same subsection to be opened was set to 25%1. Additionally, the tests were only carried out using four colours to distinguish subsections, instead of a possible eight; this allows for a potential fusion of subsections due to the door opening, to observe if that impacts the physical playability of the space. Results of the path difference heuristic were collected alongside completability information for the two variants utilising subsection searches, and are visible in Table 3.

1 However, as this is applied on both sides of a door, in practice it’s a chance of 7/16 or about 44%.

Page 23: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

22

Table 3: Space Generator performance results

Random Neighbour

Random Neighbour with Subsection Search

on Halt

Persistent Subsection Search

Completability (Forced End)

53.2% N/A

100% 20% required Forced End

100% 7% required Forced End

Performance Not Analysed Path difference heuristic Mean 3.86

Median 2

St Dev 3.81

Min 0

Max 20

Path difference heuristic Mean 12.41

Median 12

St Dev 5.65

Min 0

Max 40

Figure 12: Graph of Heuristic performance between the two methods

Page 24: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

23

4.3. Discussion

4.3.1 Results evaluation Ostensibly, the naïve baseline method just barely passes half of its generated levels being actually playable. Without either additional high-level knowledge or more complex rules to protect it, there is a high probability the generator never places the End room and thus the levels aren’t playable. The other two methods with their much wider pool of available actions did not suffer from generative failures, and actually managed to achieve 100% playability, such that no matter what happened all Locks and Keys existed in accessible pairs on the map even despite some generative defects. This is accounting for the reparative Forced end rule, meaning some rooms described in the Mission description have been deleted; the levels remained playable even after such deletions in both conditions. Between these two, the version using the subsection search at all times produces a much higher score on the Path difference heuristic, emphasised in Figure 12 and Table 2, as well as more generally in visual comparisons between Figures 10 and 11. This is to be expected given the constant freedom of growth it is provided compared to the more linear trail left by its simpler counterpart. This is best emphasised by 24% of the simpler levels having a Path Difference score of 0, meaning that player would not need to venture off the Spine path ever in their journey to the end. Of course, whilst a player is not always guaranteed to take the right path first try, this suggests the formation of long corridors with little variation or option to digress. Conversely, only 0.4% of the persistent subsection-search levels had no difference at all between paths. It is reasonable to say that Path Difference Heuristic functioned as intended, scoring higher on levels that appeared less linear in their overall layout. A tendency observed by Ashlock et al [10] in their evolution of maze-like maps, was when assessing a fitness function based solely on maximising the distance between the start and the end points, it encouraged selection of long and uninteresting winding paths. The heuristic provided in this paper achieves the opposite, scoring highest on levels that that have short absolute distances from the start to the end, but require a large amount of meandering around the space to actually reach it. The subsection on halt rule is weak, but the persistent subsection search is more promising, generating with good consistency levels with a wider exploration space. This could be further amplified in use as a search-based method to remove levels below a certain threshold, or the small number but not insignificant number levels that required some generative protection to ensure completability. The aesthetic results of this Generator are in-line with similar experiments in the field, producing varied Dungeon layouts that feel both familiarly structured yet varied. The performance of the generator makes it sufficient to function as a constructive PCG method, when factoring in the ability to prevent levels from being unplayable during generation, however the heuristic provided also grants the option of being used as a Search-based approach. Search-based is always in theory going to produce more consistent results as it is provided the ability to select better content built by the rules, and account for any generative defects. Search-based approaches are slower and may not be suitable for use as a level generator within the playtime of a game however. The ease at which this hybrid method produced usable results while both utilising simple rules and with only requiring some repairs during generation and none after the generation, suggests that hybridisation of generative techniques is an effective means of producing interesting Procedurally Generated Content, that is worthy of further investigation and refinement. The two approaches chosen in this case effectively cover each other’s generative

Page 25: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

24

weaknesses, with the Grammar rules providing a structured order that isn’t too rigid to not be varied, but the non-deterministic automaton providing a varied and sufficiently random feeling space to map it to.

4.3.1 Future directions and Limitations The Dungeons generated in this paper are designed as top down 2D levels, however they have been configured as a 3D model within the Unity engine. 3D dungeon levels are common in RPGs such as The Elder Scrolls V: Skyrim (Bethesda Game Studios, 2011) and are far more complicated to model than the kind addressed in this work. A natural next step would be to expand a generator to change the elevation of rooms to create an explorable 3D space instead, however current attempts to generate dungeons in 3D space [1] tend to feel much more unnatural then their 2D counterparts, especially with regards to connecting rooms at different elevations. This Generator produces its subsections in a mostly linear manner, assuming that one locked off section naturally follows another. Another evolution to the design would be to create branching, tree-like subsections that can be completed in any order, however this requires additional rules to ensure the dungeon is always completable under all possible orderings, not just one, and thus requires additional high level rules to ensure such content remains balanced. Human authored Dungeons in more modern games also often have multiple-room spanning puzzles more complicated than simply finding a Key for a Lock, such as those seen in modern Legend of Zelda games, and it would be interesting to experiment with these concepts. An example of such an idea are the switches found first in the Tower of Hera Dungeon in The Legend of Zelda: A Link to the Past (Nintendo 1991). These Switches control the binary existence of obstructing blocks across multiple rooms that control where the player can move to within, requiring puzzle solving skills across multiple rooms instead of just one. Similarly, many dungeon levels have a global feature such as a controllable rising and falling water level that allows and denies access to different subsections. By including a few pre-constructed room types that feature this kind of puzzle content, it could be feasible to implement with this work’s generator, as such rooms could be included as distinct important room types (puzzle1, puzzle2, etc) in the top level rules of the grammar generator, or like the Lock/Key pairs defined in such a way that they always occur in necessary groupings. However this only allows for prebuilt inclusions and doesn’t consider generating the scope and context of the puzzle dynamically. Nintendo’s Eiji Aonuma, lead producer for the Legend of Zelda franchise recently had this to say in an interview with video game publication IGN regarding the simplicity of the Dungeon builder mode in the 2019 remake of Legend of Zelda: Link’s Awakening (Nintendo, original 1993). “I talk to Mr. Miyamoto regularly about ‘the next Zelda game,’ and one time, he asked me if I could come up with a game that features Super Mario Maker-like gameplay, but for Zelda. We talked about how a game like this for Zelda would have dungeons, but it’s generally quite difficult to devise the logic needed to solve them.” [25] Here Aonuma directly acknowledges the limitations and difficulty of devising complex dungeon layouts without using pre-assembled component rooms, even when providing the control to a human author, let alone an automated one. It would still be an interesting challenge to account for such additions in an automated model of level design, If the scope of formal PCG research were to ever advance to a point where there was a true way to assess objective quality of levels against one another beyond subjectively playtesting

Page 26: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

25

them with human players, this study’s concepts should be revisited and re-evaluated in order to conform to such a change. Similarly, if the study of level design as a language problem is ever investigated further, such findings could improve the quality of the Mission generator.

5. Conclusion This work presents an analysis into techniques used for Procedural Content Generation in existing research, emphasising their strengths and weaknesses relative to one another, and their suitability for use as a basis of PCG in new games. Based on this analysis, a prototype hybrid-approach Dungeon style level generator, defined by producing subsections of necessary Lock/Key pairs, was devised utilising generative context free grammars and behaviour based on cellular automata. This generator achieves a high completability rate for its produced levels, and total completability with the help of some additional failsafe rules, ensuring that above all else a level remains completable, along with aesthetically varied results and patterns. The hybrid approach provides a large amount of user control but still a sufficient degree of randomness to feel different on successive generations, and the ease at which hybrid methodology produced effective results is a promising direction for approaches to PCG. To make use of the Mission generator, a designer would need a simple understanding of recursive context free grammars to define their game specific rules, and for the space generator, the designer (or player) would only need to know how to provide a valid single string description of their intended level, provided the defined components exist. The space generator is constructed in the commonly used game development engine Unity, providing an easy to utilise baseline implementation of the methods for non-specific Roguelike games. Easy to understand and use PCG methodologies are a valuable tool towards creating infinitely replayable and unique game content. Provided also is a new heuristic by which 2D dungeon levels can be assessed, for use in Search-Based methodologies and general evaluation of dungeon style content, which attempts to capture their semi-linear qualities. This metric proved effective at capturing the semi-linear design properties of dungeon style levels, and also inherently usable while assessing levels for their completability, which is a important action for any and all necessary content.

Page 27: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

26

6. References [1] Section VI Procedural generation of dungeons, Van Der Linden R, Lopes R, Bidarra R IEEE Transactions on Computational Intelligence and AI in Games 2014 [2] Learning to generate video game maps using markov models, Snodgrass S, Ontañón S, IEEE Transactions on Computational Intelligence and AI in Games 2017 [3] Experience-driven procedural content generation Yannakakis G, Togelius J, IEEE Transactions on Affective Computing 2011 [4] Cellular automata for real-time generation of infinite cave levels Johnson L, Yannakakis G, Togelius J 2010. [5] Guest Editorial: Procedural Content Generation in Games Togelius J, Whitehead J, Bidarra R IEEE Transactions on Computational Intelligence and AI in Games 2011 [6] A prototype quest generator based on a structural analysis of quests from four MMORPGs Doran J, Parberry I 2011 [7] Adventures in Level Design: Generating Missions and Spaces for Action Adventure Games Dormans J 2010 [8] Level design as model transformation Dormans J 2011 [9] Formal Procedural Content Generation in games driven by social analyses Amato F, Moscato F Proceedings - 31st IEEE International Conference on Advanced Information Networking and Applications Workshops, WAINA 2017 [10] Search-based procedural generation of maze-like levels Ashlock D, Lee C, McGuinness C IEEE Transactions on Computational Intelligence and AI in Games 2011 [11] Search-based procedural content generation: A taxonomy and survey Togelius J, Yannakakis G, Stanley K, Browne C IEEE Transactions on Computational Intelligence and AI in Games 2011 [12] Controllable procedural map generation via multiobjective evolution Togelius J, Preuss M, Beume N, Wessing S, Hagelbäck J, Yannakakis G, Grappiolo C Genetic Programming and Evolvable Machines 2013 [13] Procedural Content Generation via Machine Learning (PCGML) Summerville A, Snodgrass S, Guzdial M, Holmgård C, Hoover A, Isaksen A, Nealen A, Togelius J 2017 [14] Learning-based procedural content generation Roberts J, Chen K IEEE Transactions on Computational Intelligence and AI in Games 2015 [15] Sampling Hyrule: Sampling Probabilistic Machine Learning for Level Generation Summerville A, Mateas M 2015 [16] Rogue-like games as a playground for artificial intelligence – evolutionary approach Cerny V, Dechterenko F Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) 2015 [17] Generating missions and spaces for adaptable play experiences Dormans J, Bakkes S IEEE Transactions on Computational Intelligence and AI in Games 2011 [18] Towards multiobjective procedural map generation Togelius J, Preuss M, Yannakakis G 2010

Page 28: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

27

[19] Evolving dungeon crawler levels with relative placement Valtchanov V, Brown J 2012 [20] Procedural content generation for games Hendrikx M, Meijer S, Van Der Velden J, Iosup A ACM Transactions on Multimedia Computing, Communications, and Applications 2013 [21] https://store.speedtree.com/ [22] Generating random sentences from a context free grammar, Eli Bendersky, January 28 2010. https://eli.thegreenplace.net/2010/01/28/generating-random-sentences-from-a-context-free-grammar/ [23] Evolution of artificial terrains for video games based on obstacles edge length Frade M, Cotta C, Fernandez de Vega F, IEEE Congress on Evolutionary Computation, 18-23 July 2010 [24] https://unity.com/ [25] Miyamoto asked Zelda Producer to make Mario-Maker style Zelda Game, which led to Link’s Awakening’s New Mode, IGN 2019 https://au.ign.com/articles/2019/09/20/miyamoto-asked-zelda-producer-to-make-mario-maker-style-zelda-game-which-led-to-links-awakenings-new-mode [26] Bootstrapping Conditional GANs for Video Game Level Generation, https://arxiv.org/pdf/1910.01603.pdf Torrado R, Khalifa A, Green M, Justesen N, Tisi S, Togelius J New York University and IT University of Copenhagen, 03 Oct 2019 [27] Emergent Gameplay, Wikipedia entry, https://en.wikipedia.org/wiki/Emergent_gameplay [28] Grid based Dungeon Generator, unknown Author, March 19 2009 http://roguebasin.roguelikedevelopment.org/index.php?title=Grid_Based_Dungeon_Generator

Page 29: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

28

7. Appendix:

7.1 Glossary Dungeon: named for their origin in the famous Tabletop game ‘Dungeons and Dragons’, these environments are typically maze-like, and often contain various forms of monsters, treasure and puzzles to solve. Typically, these are semi-linear levels defined by obstacles that have to be overcome, often in the form of Lock/Key design. Linear: in the context of game design, linearity refers to how much freedom the player has to do things in an order of their choosing. A game considered to be linear typically only has one path for a player to follow, be that in the sequence of the levels or the levels themselves. Procedural Content Generation (PCG): the creation of data algorithmically, as opposed to manually. Roguelike: a sub-genre of Role Playing Games (RPGs) in the form of dungeon crawlers defined by procedurally generated levels, turn based combat and permanent player death, taking after the 1980 game Rogue. Roguelite: (sometimes Roguelight or Roguelike-like) a less strict sub-genre of the Roguelike genre that refers to games utilising elements of Roguelikes, but not necessarily all of them. Permanent death and Procedural Generation generally remain as core features, but other components or the twists imposed on these design choices are often more varied. Often strays into different types of combat or are played in real time. Often debated how strict the line between Roguelike and Roguelite is, or whether the distinction is even necessary at all.

Page 30: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

29

7.2 List of Figures and Tables

Figure/Table Section Description

Figure 1 2.2 Togelius et al’s definition of the main approaches to PCG [11]

Figure 2 2.4.1 Snodgrass and Ontañón, success rates with Markov Chain generation [2]

Figure 3 2.4.2 Johnson et al’s Caves [4]

Figure 4 2.4.3 Doran et al’s MMO quest rules [6]

Table 1 2.4.7 Direct Comparison of PCG Techniques

Figure 5 3.3 Rendition of the simplest generation option having no valid options.

Figure 6 3.3 Figure 6: Rendition of the generation options for the same map as Figure 5, but with the subsection search rules

Figure 7 3.4 Left - Rendition of an ‘interesting’ path, Right - a not ‘interesting’ one in the same section layout

Figure 8 3.4 The Path Difference for a Subsection. Critical path in Green, the Spine in Red.

Figure 9 4.1 Sample mission output

Figure 10 4.1 Samples of the subsection on halt rule. Note the long winding corridors. Start (red subsection) and End (yellow subsection) rooms highlighted. Coloured doors are Locks.

Figure 11 4.1 Samples of the persistent subsection rule. Note the increase in branching rooms and clustered sections. Start (red subsection) and End (yellow subsection) rooms highlighted. Coloured doors are Locks.

Table 2 4.2.1 Mission Generator runtimes

Table 3 4.2.2 Space Generator performance results

Figure 12 4.2 Graph of Heuristic performance between the two methods

Page 31: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

30

7.3 Project Files

File Description

MissionGenerator.py Python script for generating Mission descriptions. Grammar Class and Generation Algorithm by Eli Bendersky cited as reference [22] in this paper. Additions made by Alexander Gellel [email protected] in the form of custom generation rules given to the program and some evaluation metrics. Python Version used: 3.7.2

MissionOutput.txt A sample output of a full 100 Mission generation, to better exemplify the range of outputs produced by the method.

MissionTest.py Python script containing the extremely basic evaluation needed to test validity of Mission strings. It exists in a separate file now to separate it from the Generation process. Python Version used: 3.7.2

DungeonGeneration.cs The primary C# file that handles the scripting of map generation within the Unity editor. Written by Alexander Gellel, [email protected] The custom provided Mission description used in the 500 generative tests will be left in as a comment. Unity Engine Version used: 2018.3.14.f1

RoomData.cs ARoom.cs Door.cs

C# class files describing the data of the Room objects used by DungeonGeneration.cs. Written by Alexander Gellel, [email protected] Unity Engine Version used: 2018.3.14.f1

Unity Model assets The simple room model and key model were constructed within the unity editor.

Unity Generated Files The rest of the provided files form part of a Unity Project and are generated by the Unity Engine itself.

README.md Description file detailing how to run the provided programs.

Page 32: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

31

7.4 Experimental and Testing Details

7.4.1 General Technical Details All program files were written on a 27-inch iMac Retina-5k running MacOS Mojave 10.14.6. It has a 4.2 GHz Intel i7, 16GB of 2400 MHz DDR4 RAM, a Radeon Pro 575 4GB Graphics Card and a Fusion HDD/SSD.

7.4.2 Mission Generator Python program was run from Terminal in on Python version 3.7.2. Time records taken using Python’s internal timestamps, printed as an output, and evaluated externally. Mission content verified for correctness by observation and simple automated testing that output generated as intended. This verification method is attached to the artefacts as MissionTest.py for running it on a single input mission, however the test was carried out as a function within the generator itself to verify 100% correctness, and was extracted later.

7.4.3 Space Generator The Unity Project was configured to produce the heuristic and completability metrics internally, and output these values to a text file. These values were then evaluated externally. Compiled and run using Unity version 2018.3.14.f1.

7.5 Readme Attached to artefacts submission as a .md file.

7.6 Study Contract Attached below. Includes Project Description and Goals.

Page 33: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

f--.-rl Australiano@ø NationalM Uníversity

IITI}EPENI}ENT STUI}Y COT{TRACTPROJECTS

Note: Enrolment ls subJect to approval by lhe course convenor

SECTION A (Students and Supervisors)

CTIMMENCING SEMESTER Ø St f] SZ YEAR: ,,!g1s Two-sEmesterproject (t2u courses only): fi

UniID: ü8048084

ST'RNAME FIRSTNAMES: ñcnlo

PROJECT SUPERVISOR (may be ettema):

FORMAL SLIPERVIS0R (yai¡erent, must be an RSSCS academic)i С. pennr¡:Kyburz. _

COURSE CODE, TITLE AND IJNITS: COMP4560. Âdva¡ced Prolêci.12

PROJECT TITLE:Procêdúral Ccntênt Generatlcn ol Roguefike Levels

Apply ¡(nowledge of dalå struclur€s rnd algorllhmlc deslgn to lrocedurål ccntent genera{oñL€arn rêlevant resesÌch and vÌ¡r:tieü communlcatlon akilla, deepen rêporl Írrltlng sk¡lls and ãpply all of theee to project workGaln â qusn:ltlable und€tstandlng ot plây6r Interacl¡on wl:h game lêvêtê lo producè ñeanlngtül¡y slruclured contênl

LEÀRNING OBJECTTVES:

PROJECT DESCRIPTION:

The appl¡caüon of Procedûral Generat¡on ln Games cån lead to dlye¡se and polenllally ¡iltinltê content. lndustry suêceâs6ssuch as Minêcrafl, tbe recent surge of the Battlê Royale genre ãnd lhe success of the ñrgueliksy'Roguellle lenrc wtthln the"lndie" game dêvelopmenl scene have shown lhat varlous dègre€B of randomlsallon and Procedurally Generated worlrtrwlthln game conte¡t ¡ar lead to cont¡nually engaglng experlences and emergent lnteräct¡on wlth syst€mr ln contrast lo :nanyestabll6hed trâdlllonal gamê de*lgn âppfoachês

Ihe flrst etage ot this Pro¡ect w¡ll b€ to ¡nvsst¡gate and compare existlng approaches io and ures of Procedurat ContenlGenerat¡on t€chniques used ln levêt deslgn ln both exl8t¡ng gâmêB ånd research. The tãrget têvel styte wlll be modelled afterslructured ToPDown "lungeon" lype levels, dellned by expllclt slarl/end polnis ãnd a loglcal progresslon lhrough lock/keysyst€ms. These methode wlll thên bê evaluated ôn the effectlveðess ¡n generat¡ng interestlrg ånd dlverse levsls, ãnd thsapproach dgemed most su¡table w¡ll be protoyped inlo â fully tunct¡oning leve, generatû., Á finãl report wlll bê writtèn todescrlbe the approach, tests pêrfoilned, and the results achleved,

Research School of Computer Science Form updated Jun 2018

Page 34: Procedural Generation of Roguelike Levels …...3 Abstract Procedural Content Generation (PCG) is the algorithmic generation of data and is an attractive prospect within the Video

f*1.! tu¡stralian

E-WæUffiffi,

ASSESSMENT (as per the proiect course's n¡les Í,eb page, with any differences noted belsü').

TVTEETING Þ,{TES (IF KNOlilN) :

8€il|-R.gulff t o¡ùy Mccting¡

STUDENT DECLA.RATION: I agree to fulfil the ¡bove delined contmct:

:fu#ffi ilïln$igaature

SECTION B (Supemisor):

I arn willing to supervise and support this project. I have checked the student's academic recordand believe this student can complete the project I nominate the following examiner, and h¿ve obhinedtheir consent {via signature below or attached ernail)

4ß12019

Ilate

Date

Dr Ben Swift Signaiure ..

{Nominated examiners may be subject to change on reguest by the supe:visor or course convenor)

DEPARTMEI{f RESO URCE$ I

SECTION C r spprovrl)

Ê:ramlner:Name:

Signature

g-M

\-l 3 [t1

Due date Svaluated by:Voof mark,dssessed proiect compon en ts:

(ex¡miner ){üin 45, def 60)

ooToReporÍ stylc:(e.g. research

Fffirch Rrportfeport, sofhvare description...,)

(sr¡pervisor)(max 45, def l0)

9'/oArtefacl kind: s"fi.srâ(e.g, software, user inTrrfæe, robot..,,)

(cowse convenor)(ro) tPresentation :

Researoh School of Computer Scienc€

Date

Form updatedJw 20i,8