Little MartianDiscordTwitterDevlogDemo!

Procedural World Generation in Little Martian

Little Martian is a survival game with a strong emphasis on exploration. Each time you start a new game a unique world is generated procedurally, so no two worlds will ever be the same.

GPS Device

What's more, the rarity of biomes varies between worlds, meaning resources that are scarce in one world could be abundant in another, and vice versa. In turn, this affects which items you'll be able to craft early on in the game, and the hope is that this will cause different strategies to emerge, adding to the replayability of Little Martian.

We'll go into detail how the worlds are generated, but first, here's an overview of some of the biomes you're likely to encounter.

Lush Grassland

Found near water – where moisture levels and temperatures are high – lush grasslands provide an abundance of vegetation for Little Martian to eat, and plenty of biofuel to power generators.

Temperate Forests

Away from temperature extremes, temperate forests thrive. The types of trees that grow depends on the exact temperatures: where it's a touch warmer, oak trees grow; cooler, and you'll find spruce trees; and sitting in the middle are birch forests.

Rain Forests

When it's hot and there's a lot of moisture, temperature forests become rain forests, where there's an abundance of thick vines and ferns that are difficult to trek through, but provide an excellent source of biofuel. If you can bring yourself to chop them down?

Desert

Dry, desolate, and arid; deserts provide very few useful materials, other than the occasional branches that could be fashioned into primitive tools.

Tundra

Cold, snowy, and icy; the tundra may at first appear to be as sparse as the deserts, but beneath the surface lies a rich, untapped supply of rare minerals and ores. You'll need your spade and plenty of perseverance to find them, however.

Sulfur Fields

Also known as a fumarole, sulfur fields occur where an opening in the planet's crust emits sulfur dioxide and other poisonous gases. They are rare, but they are the primary cause of the atmosphere on Unknown Planet being unbreathable. Pools of toxic sulfuric acid make this a dangerous and inhospitable environment, but one that is very rich in rare ores.

Mineral Vein

Another biome that contains an abundance of the extremely rare ores and minerals that you'll need to rebuild your damaged spacecraft.

World Generation Algorithm

The basic world generation algorithm is based around the standard Perlin noise functions. For a great primer on using noise functions to procedurally generate terrain checkout this amazing article which does a far better job of explaining it than I ever could! We'll wait...

...

Thanks for coming back!

So, for Little Martian we begin by generating three random noise values for each tile in the world: elevation, temperature, and moisture. These values are combined and we assign biomes in a manner that mimics the sorts of biomes found on Earth. For example, higher moisture levels will result in fertile biomes such as plains and forests, where lots of foliage grows. Lower moisture levels will result in drier biomes such as deserts and barren wastelands.

Essentially this is just a bunch of nested if..then..else.. statements.

function getBiome(e, m, t) {
  // oceans, unless it's frozen over.
  if (e < 0.30) {
    if (t < 0.31) return BIOMES.FROZEN_OCEAN;
    if (t < 0.35) return BIOMES.OCEAN;
    return BIOMES.DEEP_OCEAN;

  // surround oceans with beach, swamp or tundra.
  } else if (e < 0.40) {
    if (t < 0.33) return BIOMES.TUNDRA;
    if (m < 0.58) return BIOMES.BEACH;
    return BIOMES.SWAMP;
  
  // and so on...
  } else {

  }
}

This gives us a pleasing mixture of biomes that blend together in a seemingly natural way. It gives rise to nice mix of mostly generic terrain with the occasional unusual landforms to liven the world up. But, to give the player more to explore and discover we layer on top special biomes that are not tied directly to the three variables of elevation, temperature, and moisture.

Mineral veins, for example, appear as long, curved, slashes across the terrain, cutting through everything above sea-level. Sulfur fields, however, tend to be small and fairly regular in shape with smooth curved edges.

Generated Structures

In addition to a vast and varied landscape, the planet Little Martian has crash-landed on was once inhabited. The decaying remnants of civilisation are littered all around the planet, just waiting to be discovered.

We're keeping most of the details of generated structures a secret, so as not to spoil the surprise! But here's a sneak peek of one structure: randomly generated warehouses, packed fun of useful materials and tools, often ones that can't be found elsewhere.

Warehouses

Other planned structures include: large, abandoned laboratory complexes; derelict living encampments; disused mine entrances (yes, you can go underground, but you're going to want to bring a torch); exploded nuclear reactors; overgrown bio domes; and more...

Through your encounters with these structures the history of the planet will be revealed, which may hold clues to its future, and maybe Little Martian's fate!?