This project is a simple 2D terrain generator using the Wave Function Collapse algorithm.
It creates a procedurally generated map made of tile images based on adjacency constraints which are hard coded.
Built as a learning experiment to understand how WFC works in Python and how it can be used in procedural generation.
- Supports square image tiles (e.g., grass, water, soil, rock, lava)
- Generates terrain using constraints
- Renders the final terrain using Pillow (
PIL) as an image - Simple and good for demos and learning
-
Install required libraries:
pip install pillow -
Make sure your image tiles are located correctly (adjust paths in
renderer.pyif needed, the tiles have been provided inTilesfolder). -
Change the constraints as needed in
renderer.py. -
Run the project.
- Only square tiles of the same size are supported
- No support for rotation or sample-based training
- You can tweak the
tileProbdictionary inwfc.pyto create new rules
- It takes time to generate large maps
- The terrain follows scattered pattern but with the given constraints
- No seed ability for more controlled terrain generation
- The code can halt sometimes (Edge case) especially around 100 x 100 map size
