Meander Algorithm

Meander Algorithm

The meander algorithm is a combination of using mazes to allow a meandering with bresenhams line. Below you can see the actual algorithm in simplicity. Obviously you could use noise maps to created heighted terrain based on the river to make it look pretty.

Meander Algorithm:

  1. Choose a starting map edge and ending map edge, acquire
    the terminal points based on those edges. Usually this would be a random point on those edges. Maybe you'd want to weight it so it's predominately in the center, or you could restrict it to a certain part.

  2. Create Bresenhams line between the terminal

Read More

Generating Exhumed River Channel

Generating Exhumed River Channel

I recently did some work in generating rivers in a 2d game. Revisiting this work to create an exhumed river channel, I decided it might be fun to revisit how to generate it to make the channel look more realistic. Instead of using a drunken walker, this is a more expensive but interesting map generator:

  • Start by generating 2d simplex noise where
    • less <0.6 is floor
    • rest is walls
  • Generate terminal lines at each map exit (north, south, east, west). Shuffle those lines and randomly choose a start and end location for the river based on two of

Read More

Generating Cliffs for 2d Game

Generating Cliffs for 2d Game

Source code available on github here.

A recurring problem in 2d games is how to represent depth. In isometric games this is easily solved but in discretely top-down games it's harder to solve. After doing a lot of research I fell onto a simple idea: do the best you can insinuating the depth and leave the rest to the imagination. Here's the algorithm I used to create 2d top-down cliffs:

  • Create a small map of perlin noise and a wide map of perlin noise. Add the two together and give the large map a weight of 3 with the small

Read More

Generating 2d Rivers

Generating 2d Rivers

Rivers are really hard to generate for 2d top-down games for multiple reasons:

  • Rivers primarily form based on heightmaps which are hard to display in top-down
  • Displaying fluidity when working with sectors or grid-based rendering can be complicated, bresenham's line algorithm only goes so far to make things look smooth
  • naturally occurring mechanisms of nature have numerous factors in play that caused them to exist. Simulating all of these factors isn't reasonable.

I was able to make relatively decent 2d rivers using a few techniques.

  1. Started by having terminal points where rivers can start/stop. Primary start positions might be

Read More

Pigeon Hole Stepping v2

Pigeon Hole Stepping v2

I had originally written an article on how to implement PHS here. Having found the maps generated slightly redundant I decided to take another look. Here are the steps taken to successfully generate a more realistic "town." It's essentially a drunken walker like Diffusion Limited Aggregation mixed with a hallway constraint that mimics the large part of PHS.

  1. Start somewhere in the middle, add this and all possible directions up to a certain dynamic length (I used a standard deviation of 1.4 with a mean of 5, ) as nodes: [{x,y,direction},...].
  2. We will be looping until all nodes

Read More