Level Generation

Marching Cubes Level Generation

The Marching Cubes algorithm is a system for generating objects while following a set of rules.

This project uses a 2D version of the Matching Cubes algorithm (Matching Squares?) to generate terrain for a general video game.

The example above has only a few simple rules; there are 5 materials: Water, sand, grass, shrubs, and forrest.

Tile examples

Each material can only be next to it's neighboring tiles.

  • Water can only be next to sand.
  • Sand can only be next to water and grass.
  • Grass can only be next to sand and shrubs.
  • Shrubs can only be next to grass and forest.
  • Forest can only be next to shrubs.

If you look at what the above program generates, you'll notice that all of these rules stay the same.

You can add more rules to this system to make it better. This could include directional connections, such as "Water can never be below water" or more general additions like "Water must come in groups of at least 3" so that you don't get any one-off tiles.