Skip to main content

A customizable Python tool for generating maps for games and simulations.

Project description

TerraForge v1.6.0 🗺️

Procedural Biome/Island, Town & Dungeon Map Generator using Simplex Noise

TerraForge is a versatile Python toolset for procedural map generation.

It includes tools for creating noise-based biome maps, procedural town layouts, and multi-level dungeon layouts...


🚀 Features

🌍 Biome Generator (TerraForge)

  • Elevation, Moisture, and Temperature map generation
  • Supports single and clustered multi-island generation
  • Falloff support: Radial, Edge, or None
  • Parameters for island spread, spacing, scale, and strength
  • Biome mapping based on environmental conditions (supports both visual colors and logic-driven biome data)
  • Outputs high-resolution PNG images
  • JSON preset import/export for reuse in games

🏰 Dungeon Generator (DungeonForge)

  • Multi-level dungeon generation (3D stack of floors)
  • Procedural room placement and corridor carving
  • Up/down stairs for vertical navigation
  • Console-based movement demo included
  • Optional PNG export per dungeon level
  • Tile color customization for export
  • JSON preset import/export

🏘️ Town Generator (TownForge)

  • Procedural town generation
  • Configurable building types and quantities
  • Randomized building sizes and placement
  • Overlap prevention with configurable spacing
  • Configurable edge padding
  • Randomized door placement
  • Configurable door sides and inset spacing
  • Building metadata access helpers
  • Optional building label rendering
  • PNG export support
  • Deterministic generation using seeds

📦 Requirements


📦 Installation

You can install TerraForge using pip.

pip install terraforge-core

🧪 Demos

Biome Map Generator

Run the included demo script:

python demo.py

The generated maps will be saved as biome_map, elevation_map, moisture_map, temperature_map, (noise_type)_map.

Dungeon Map Generator

Run either the included dungeon_demo script or dungeon_demo1 script.

python dungeon_demo.py

Console based demo with movement.

python dungeon_demo1.py

Generates .pngs for each dungeon level.

Town Map Generator

from townforge import TownForge

generator = TownForge(
	map_size=300,
	image_size=None,
	seed=None,
	building_padding=4,
	map_edge_padding=5,
	door_inset=1,
	door_sides=("north", "south", "east", "west"),
)

town_map = generator.generate()

generator.export_town_map_image(
	output_dir=".",
	show_building_names=False,
)

This generates a procedural town map and exports it as a PNG image.


🚀 Usage - TerraForge (Biome Maps)

from terraforge import TerraForge

generator = TerraForge(map_size=300, image_size=(600, 600))

generator.generate(output_dir="maps")

🔁 Preset Workflow

generator.export_preset("world_preset.json")

generator.import_preset("world_preset.json")
generator.generate("maps")

🧩 Biome Schema (Presets)

Biomes are stored as a list of objects. Each biome requires:

  • color (hex string)
  • rules (dict of noise_type -> [min, max])

Optional (recommended for tools like TerraForge Studio):

  • id (unique string per biome)
  • name (display name)

Example biome:

{
  "id": "forest",
  "name": "Forest",
  "color": "#3E7C3C",
  "rules": {
    "elevation": [0.4, 0.6],
    "moisture": [0.5, 1.0]
  }
}

Notes:

  • id is optional, but if provided it must be unique within the preset.
  • Rule ranges must satisfy min <= max.

🧠 Accessing Biome Data

Each tile now stores full biome data instead of just a color.

biome = generator.get_biome(x, y)

print(biome["id"]) # logic (e.g., "forest", "ocean")
print(biome["name"]) # display name

To get the visual color of a tile:

color = generator.tile_color(x, y)

⚠️ Update (v1.4.0)

  • biome_map now stores full biome dictionaries instead of hex color strings
  • Use tile_color(x, y) to retrieve the visual color
  • Use get_biome(x, y) for biome data and game logic
  • PNG export behavior remains unchanged

🚀 Usage - DungeonForge (Dungeons)

from dungeonforge import DungeonForge

generator = DungeonForge()

dungeon_map = generator.generate()

🔁 Preset Workflow

generator.export_preset("dungeon_preset.json")

generator.import_preset("dungeon_preset.json")
generator.generate()

🚀 Usage - TownForge (Towns)

from townforge import TownForge

generator = TownForge()

town_map = generator.generate()

generator.export_town_map_image()

🧠 Accessing Building Data

building = generator.get_building_at(x, y)

print(building["name"])
print(building["type"])

You can also retrieve buildings by their door tile:

building = generator.get_building_by_door(x, y)

⚙️ Customization Options

Biome Generator

Edit the values in terraforge.py or the demo to control:

  • map_size and image_size

  • falloff type: "radial", "edge", or None

  • num_islands, island_spread, min_island_spacing

  • noise types (elevation, moisture, temperature)

  • biome_thresholds for noise types (elevation, moisture, and temperature)

Dungeon Generator

  • Map size (width, height)
  • Number of levels (z_levels)
  • Maximum rooms and room size constraints
  • Tile symbols and export colors
  • Specify which levels to export (levels=[0, 2])

Town Generator

  • Map size
  • Image size
  • Building spacing/padding
  • Map edge padding
  • Door placement rules
  • Door inset spacing
  • Building types
  • Building quantities
  • Building sizes
  • Building colors
  • Ground color
  • Door color
  • Outline color
  • Building label rendering
  • Random seeds

Related Tools

TerraForge Studio

Screenshot (583)

A GUI tool built on top of the TerraForge library that allows you to quickly generate multi-level dungeons for games, prototypes, and tabletop use.


Related Libraries

  • CQCalendar: A lightweight, tick-based time/calendar/lunar cycle system for Python games and simulations.
  • MoonTex: A procedural moon texture generator for Python that creates stylized, noise-based moon phase images.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terraforge_core-1.6.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terraforge_core-1.6.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file terraforge_core-1.6.0.tar.gz.

File metadata

  • Download URL: terraforge_core-1.6.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for terraforge_core-1.6.0.tar.gz
Algorithm Hash digest
SHA256 18ab866144bafb26d2f34be5a549642c7a70a9fa96929cecfff983c7270b34a9
MD5 d6b555d80c04cad54a96be2aac920781
BLAKE2b-256 1fe6266f6da4118f8fe73f36f4f64f22c48166fceac91129d8fc667dbdc6e332

See more details on using hashes here.

File details

Details for the file terraforge_core-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for terraforge_core-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12943036db6db6f03e73eb3c4fb980eed1bf85f6be6ed752b35df5d051e489d6
MD5 ebcc95a5b68e0a301a49d0d9d992d628
BLAKE2b-256 18b12e8a2928bede4d7c9acb42b4f52e708ba66cdd64ddee6f5c00e77196c67c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page