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 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

Generating Ancient Ruins

Generating Ancient Ruins

While creating algorithms for random continent generation, I came across an old algorithm I had worked with called Coupled Map Lattice. Using that to create a continent was hard but I was able to accomplish it doing layers of filters:

  • generate map with noise between -1 and 1
  • apply CML using Spatiotemporal Intermittency settings
    • (a = 1.75, ε = 0.6)
    • I found that using something too chaotic didn't have a noticeable affect compared to just generating noise in general.
  • normalize values to between 0 and 255
  • apply a gaussian blur
  • normalize values to between 0 and 1
  • apply slight height

Read More

Object Collision With Spatial Hashing

Object Collision With Spatial Hashing

I ran across a great article today by Christer Bystrom that talks of the difference between Quadtree's and Spatial Hashing at implementation and subsequently alludes at the performance implications. I've made a more appropriate demo (in my opinion,) than the confusing code in the spatial hashing implementation on the page to make it more simple to see and understand. I thought that it was worth taking a look at. In my code example I do not show his spatial mapping library. You'll have to use this link to gain access to that. I merely show how I implemented the library.

Read More