Skip to content

MWojniewski/Wave-Function-Collapse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wave-Function-Collapse

This project is my C++ implementation of the Wave Function Collapse (WFC) algorithm using the SFML graphics library. It generates patterns on a 2D grid by progressively collapsing tile possibilities while respecting adjacency rules, similar to procedural texture or map generation.

🚀 Features

  • Tile-based procedural generation using WFC.

  • Interactive controls:

    • Press Enter to advance the collapse step-by-step or resume after interruptions.

    • Click & drag with the left mouse button to reset/renew tiles manually.

    • Press Escape to close the application.

  • Weighted randomness: Tile chances are read from tile_probabilities.txt so different tiles can appear more or less frequently.

  • Dynamic rendering: Tiles are drawn in real time with a gradually increasing framerate as the collapse progresses.

  • Customizable tile set: Comes with 41 tile variants split across multiple colors.

🖼️ How it Works

  • The grid starts with all possible tiles available for each cell.

  • A priority queue selects the next tile to collapse, weighted by entropy and probability.

  • Once a tile is chosen, neighbor constraints propagate through the grid, reducing possibilities.

  • This continues until the grid is fully collapsed into a valid tiling.

📂 Project Structure

  • WFC.cpp – Main program loop and SFML rendering.

  • wfc_header.h – Core WFC logic, data structures, and utility functions.

  • tile_probabilities.txt – Tile definitions and probability weights.

  • tiles.png – Sprite sheet containing tile textures (required).

About

This project is my C++ implementation of the Wave Function Collapse (WFC) algorithm using the SFML

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages