Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Generation

gerhalt edited this page Jan 2, 2013 · 8 revisions

This is a work in progress (partially implemented, with a dynamic spec)

Introduction

Part of the intention of this library is to be fully independent of any internal Minecraft generation code. This means that terrain generation in a very similar vein is a requirement. Simplex noise looks very similar to the Minecraft approach.

Design Choices

All generation-related functionality will be contained within a Generator object, instantiated with a seed to create reproducible terrain. There will most likely be other configurable parameters.

Generation will occur in multiple passes. Supposing a chunk is being generated, the procedure will probably look like:

  1. Terrain shape - The Chunk's biome type will probably affect the block types used for the foundational blocks. Terrain will be generated using the noise approach (which will be expounded upon below).

  2. Resources - These will take the form of a resource and a dependency. For example, iron ore would have a prerequisite of a stone block. All blocks of the given type would have a change to be transformed into that block. Having a neighboring resource block would add some increased chance to the generation probability of its adjacent blocks. Note that this would cause resource deposits to not generate across chunks (except by chance). An alternate approach would be to use simplex noise in this case as well, with some set of modifiers to only generate small chunks of blocks. These could then be intersected with blocks in the chunk that fulfilled the prerequisite requirement.

  3. Decorators - Generated similarly to resources. Simplex noise would not be an option here. Instead of converting a block of a prerequisite type to another block, a dependency could be more complicated. For example, a chance to generate a mushroom decorator could consist of finding a dirt block with an empty block immediately above it, with some maximum light level (to ensure mushrooms would be more likely to spawn in caves than in the overworld). Were these conditions met and random chance aspect satisfied, the spawn point would then be the empty block above the dirt.

It seems that what makes the most sense is writing the terrain "shaping" portion of the code in C, with a provided Python interface, and writing the rules for defining block types and decorators in Python.

Customization

A number of things go into generation, beyond simply determining whether a block exists or not. Mixes of dirt and rock, for example, or sand and gravel. Intermingling at biome edges. Sharp cliffs versus wide, open plains. Creating interesting terrain requires much more configuration than just a seed, in turn requiring a way to configure these variables.

Perhaps a seperate Biome object containing these configuration values would be a good idea?

Interface

  • Generator(seed) - Initialization will occur on a seed. The seed will be used to generate a randomized permutation table.
  • Generator.noise(x, y, z) - Returns a scaled float representing the noise strength at a given location. x, y, and z are floats and thus can be scaled to deform terrain. The scale of the return value has not yet been determined.
  • Generator.octave_noise(octaves, x, y, z) - Add levels of noise together, to obtain more interesting noise patterns. Exact functionality to be determined.

in progress

Simplex Noise

to be defined

References

Clone this wiki locally