Skip to content

World Generation: Edges Complete

World Generation: Edges Complete published on

yay_oceans

 

As you can see here single edges with proper ocean hole detection was successfully implemented, pretty much finishing up the basic building blocks of the new world generation. You might be asking, “what is ocean hole detection”. Since the map generator fills in land by moving a cursor tile about randomly, there’s a chance for unclaimed ocean tiles to end up residing inside land masses. This isn’t really desirable since beach edge tiles take up a lot of space, so at the end of generation they’re searched for and filled in with land.

This was pretty simple when the map was composed of just ocean tiles and land tiles (find isolated ocean tiles), but the addition zones and edges made things a little more complicated since edges are neither ocean nor land until they’re next to another zone. It also added a secondary purpose for ocean hole filling since redundant edges were possible during generation:

redundantGreen is zones, yellow is edges.

While it was perfectly reasonable to leave the far right edge during generation, in reality it’s not a practical edge of anything- it’s surrounded by its own zone. As such, it’s the same thing as an ocean hole. Detecting redundant edges is exactly what you think it is: if you’re surrounded by other edges and are only adjacent to one zone, then you’re unnecessary and thus considered an ocean hole. A special exception was made for edges bordering the ocean, to prevent ocean rivers leaking into zones excessively.

Originally the ocean filling was run on a per-zone basis but this lead to a tricky edge case:

hard holesMountains denote zone borders, white mountains/caves/graveyards represent different zone’s edges.

If you ignore the bottom and left zones and consider the top right zone’s existence it made perfect sense for that edge to be where it is- it was just ocean there after all. But when the bottom zone was generated and it created an ocean hole, it was impossible for it to claim that tile- it was surrounded by the first zone’s edges. The first zone could fill it, but it had already been processed. The fix was to simply process all ocean holes for all zones at the end of generation, letting whatever logical adjacent zone fill them in.

So then I finally moved on to some proper level generation. This is a very early sample of generating a central town zone and then creating 3 linear paths off of it. At the end of one of the paths the next central town zone would be generated (not pictured) which will then create its own linear paths, and so on.

yay_paths

The generator basically consists of pre-made things called zone generators. These things create zones in specific patterns. In this example there’s the Linear Path zone generator which continually creates a certain number of small new zones in a given direction. The other is the Town generator which simply creates a single small zone.

In order to make more complicated patterns out of these, each zone can be given a deferred zone generator. So the real crux of this town generator is that it contains a populator component. The populator component is told to place a single town object within the zone, making it a proper town zone. Not only that, but the populator component can also place down a few Linear Path deferred generators on the town zone, so on the next pass of generation the linear paths will be created off of it.

In layman terms this level generator is ran by a magic gnome that can make land. After making some land, the gnome can plop down work orders for the next set of gnomes with instructions for what he wants built next to that piece of land. The next set of gnomes can do the same thing, and the process goes on until the gnomes are satisfied with the world.

This is all well and good, but now that it’s time to legit produce some level designs I realized I never really put down proper plans for the new world. I had a lot of scribbled ideas for what can be done and how it should be done, but not a concise plan. So get ready for an exciting adventure in game level design this Sunday.