https://github.com/a-moseman/wavefunctioncollapse
https://github.com/a-moseman/wavefunctioncollapse
java java-17 procedural-generation wave-function-collapse
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/a-moseman/wavefunctioncollapse
- Owner: a-moseman
- Created: 2024-07-16T23:07:03.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-07-17T18:37:49.000Z (over 1 year ago)
- Last Synced: 2025-02-23T10:16:19.243Z (12 months ago)
- Topics: java, java-17, procedural-generation, wave-function-collapse
- Language: Java
- Homepage:
- Size: 17.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
An implementation of the [wave function collapse](https://en.wikipedia.org/wiki/Model_synthesis) algorithm.
## Rule Encoding
The implementation represents the constraints of the model as a set of rules. Each rule represents a valid pair of neighboring cells. Namely, it encapsulates a target cell's state, a valid neighbor cell's state, and the cardinal direction from the target to the neighbor. The set of rules is one-hot encoded in a 3D matrix. The target cell's state, neighbor cell's state, and direction being the axes of the matrix.
## Iteration
Each iteration of the algorithm selects the cell with the lowest entropy. If there are several of the same, lowest, entropy, one of them is chosen randomly. The entropy is calculated using the [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory)). The chosen cell is randomly collapsed to one of its remaining, valid states. Cells with no valid states are left as undetermined.
## Setup Requirements
Java 17
## Example
