Skip to content

World Generation: Level Design Week 2

World Generation: Level Design Week 2 published on

Most of this week was spent on getting the basic infrastructure for the zone generation up and going. Exciting tasks such as “create a new zone in the direction of this zone”, “make sure there’s actually enough space there”, and “create a link when two zones touch”. Presently it’s operating on the very first step of generation, creating the 3 “continent” zones- the land masses that the level structure zones will get placed within. Each “continent” represents a different level range of the game.

fgen2The different objects represent the edges of each zone.

I’ve actually had some debate of whether the level design zones should define the shape of the landmass or if the landmass should be generated first. For the time being I’m generating the landmasses first since it makes for a good test case of zones. More than likely I’ll have to switch to having the level design dictate the continent shape. When the landmass dictates available area it makes it much harder for the level design to say, “okay I want a 3 zone long corridor in this direction” since there might not be enough space available there.

zoneproblemsGreen tiles are the zone interior, yellow tiles are the zone edges.

Another problem of note is how to define zone edges. You can either have zones share edge tiles (above picture), or you can have zones get their own unique edge tiles (first picture). The problem with the shared edge technique is that it results in situations such as above where the center edge is the only way for the top zone to connect to the bottom zone. But if it opens up that edge, it ends up inadvertently creating a connection to the left and right zones. Double edges fix this problem, but also end up creating significantly more bulky zones which is problematic given the tight space restrictions of the game. For the time being I’ll see how bad double edges are, but if it comes down to it I might have to make the generator a lot smarter when it comes to edges (doesn’t count as a connection unless there’s an unshared edge that can be used as an opening, etc).

In the coming week I’ll get to start working on creating actual level patterns, and fixing my currently broken edge detection.

World Generation: Level Design Week 1

World Generation: Level Design Week 1 published on

Traditionally when sitting down to start working on a game, the first thing I’d do is write a design doc. On this game I completely skipped that step. This was our second attempt at the game, and the last time we tried I never got passed the design phase. The game was just too big, with too many moving parts for me to fit it in my head all at once. We had a firm concept in mind, so I simply set out to build a generic engine for that concept. Instead of agonizing over every detail in my head, I’d do the most obvious solution to each problem and decide what needed improvement after play testing it.

For the world design the obvious design was to place towns and dungeons across the map with roughly the same distance between them. In theory, this means that the player would have at least 4 choices of where to go each turn. In practice this was quite dull. Not just because of the layout, but because towns and dungeons all did roughly the same thing no matter where they were. Traversal choices were boring: if weak, go to a town. if not weak, go to a dungeon of your level range. always head in the direction of a quest. There was no sense of discovery because none of the new destinations mattered to the players. It didn’t really matter which dungeon they went to.

world

There’s pretty much two parts of this problem. One, the destinations have nothing of interest behind them. Two, the -routes- to get to the destinations have nothing of interest to them. For the first part the solutions being employed are to have more nuanced degrees of difficulty on the map so players get to actively choose how far they want to push it, to give each type of place a unique purpose (one type specifically holds bosses, another specifically holds treasure, etc), and so on. For the routes is where the next step in world generation comes into play.

So I set out to add a better sense of route design to the world generator. In a perfect world one might hand craft several levels, take notice of fun patterns, and then try to distill them down into a form the generator could understand. We don’t have time to build a level editor that won’t even be used in the final product, so I am instead jumping straight into trying to produce a flexible generator that we can refine as we go.

The first step was deciding on a new building block for it: zones. Zones essentially divide the map into contiguous sectors. Since this is still an outdoor map, clumps of zone terrain end up forming the passageways rather than literal lines. Zones store adjacency properties to know whether a wall (mountains, water, etc) divides their adjacent zones or if they’re open. As such, a network of links develops.

zonesIn the illustration the only way to get to pink is through the grey zone.

 

It took awhile to decide how to build the network until I realized the same basic structure that we use for general terrain applies about as well. You have a “cursor” zone that moves about the network adding new zones to it, based upon some pattern. It can also apply sub-generators at a whim. The one design pattern that I kept in mind as an example is that of the long and short path. A primary zone would have two paths from town leading to it: a long one that’s typically safe, and a short one that typically has traps or poison marshes along it. This basic design handles that test case quite simply by adding the long zone after placing the short zone.

Presently I’m working on a very basic version of the generator that simply creates 2-3 linear paths in random directions from a starting town zone. These paths form the backbone of the world’s necessary plot locations, followed by a second generator that creates side paths/zones off the primary paths. We’ll see how that goes. Right now I’m building these generators as well as the underlying zone creation. Once I have that working we’ll see where this goes.

World Generation: Fundamental shapes

World Generation: Fundamental shapes published on

Random generation is a pretty interesting part of game development in that there aren’t that many standard algorithms to apply to it. There’s an edge of creativity when building an algorithm for it. It’s most commonly applied to dungeons, typically by splattering around a few randomly sized rectangles and then connecting them by thin hallways.

 

dungeon

 

Our game requires a more organic approach since it takes place on a world rather than a confined, man-made dungeon. A number of possible generation styles were considered- the most ambitious being to place a few elements at random and then “simulate” the world for awhile. Eventually I settled down into deciding that we mostly just needed to achieve a world with naturalistic edges- wavy, unpredictable and rarely straight. One of the early attempts at this was to place down random points, and then connect them together.

point

 

This worked well with enough points and a large enough area, but ultimately failed to create organic shapes for smaller areas given our large tile size. So I went down to an even simpler technique of having a “cursor” tile that moves about the map randomly creating land. This was, of course, a little too random so I structured it a further by having it move along all 4 “edges” of a shape, moving up and down at random to create the flow. Once the outline was finished it could simply be filled in.

phase1-2phase2

The end result was satisfactory at creating continents with an organic feel. The technique was then extended towards the rest of the world- lakes would use the same style of shape generation, rivers could simply move about towards a direction, and so on.