Skip to content

World Generation: Level Design Week 3

World Generation: Level Design Week 3 published on

ocean problem

 

It all started with that little ocean hole right there.

ocean problem 2Green represents claimed zones, yellow edges, blue ocean.

The problem was that it was impossible for the current zone to claim that ocean tile. It wouldn’t be able to create a double edged border . No amount of hole checking would solve it, it’d require allowing an already placed zone to revise itself or manipulating it in some other way. A can of worms. With single edged zones rapidly appearing more sane I hastily started to revise the edge system to use them instead of wasting time on a double edged system I’d probably just change later anyway.

If you can recall from last week, the big problem with single edged zones was the possibility of multi-zone connection edges:

zoneproblems

 

My solution is quite simple, during zone creation a single edge tile is reserved to be used as a doorway link between two zones at a later date. If two zones don’t have a reserved edge, then they aren’t truly connected. If an edge is connected to 3 or more zones, then it can only be opened if all 3 zones are declared open to each other. The problem was trying too hard with two edge cases:

single edge problem3  The white edge represents the currently considered reserved edge.

In this problem the considered edge is only directly connected to two zones. But it’s adjacent to an edge that’s connected to a third zone- if both are opened then it effectively creates a link between all 3.

single edge problem2

In this case the considered edge is connected to unclaimed ocean. In theory, a new zone could eventually crop up there and then it’d need an edge adjacent to the reserved edge lest it create an unintended connection! But that new edge wouldn’t actually be connected to any other zones unless it knew the reserved edge was actually open.

My unnecessarily complicated solution was to mark adjacent tiles that there was a possible zone connections near the reserved edge and to not create an open tile unless it was desired to connect to those two zones. This was, of course, completely stupid and unnecessary complexity. In the first case, who cares if it creates a connection- for all intents and purposes the player is traversing through the middle zone to get to the other zone- it just happens to be a particularly quick route. In the second case the unclaimed tile should simply be assumed to eventually be another zone and consequently that edge is unusable for reservation.

So then another problem cropped up:

double edged swordGrey mountains represent edges linking two zones. White mountains and caves represent unlinked edges.

If you direct your eyes to the top of the image you’ll notice the top of the border of the two zones isn’t detected as linked. This is because those two edges are bordering against the unclaimed ocean tiles. The solution to this was mercifully simple: I had been placing land on -all- zone edges. If I simply kept edges as ocean tiles up until a link is detected, the issue goes away.

At this point the code base had been ravaged from multiple ways of doing edges, unnecessary reserve code, and so on. So I stripped it all down, re-implemented critical components, made it so zones generate land instead of the layered multi-zone continent non-sense I had going, and so on. This entry doesn’t end on a high note, that’s where I still am. Ironically, doing the last few adjustments to get ocean hole detection working again. Look forward to a mid-week shame post, where I actually start generating level design.

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.