Home

Awesome

Wave Function Collapse in Dart

This repository contains a Dart implementation of the Wave Function Collapse algorithm, originally written in C# by mxgmn. Wave Function Collapse (WFC) is a constraint-solving algorithm often used for procedural content generation, such as creating bitmaps, maps, or levels.

Acknowledgments

This project is a reimplementation of the Wave Function Collapse algorithm created by mxgmn. The original C# version serves as the foundation and inspiration for this Dart implementation.

The purpose of this project is to make the algorithm accessible to developers working in Dart, including those building cross-platform applications with Flutter.

All credit for the core ideas and concepts of WFC goes to mxgmn. This repository focuses on translating the implementation into Dart while adhering to Dart-specific conventions and idioms.

Features

  import 'package:wfc/src/logging/logger.dart'; // in other projects if you'd like to try it

Usage

  1. Clone the repository:
   git clone https://github.com/rick-dalley/wfc.git
   cd wfc
  1. Install dependencies: Ensure you have Dart installed on your system. Install dependencies by running:
   dart pub get
  1. Run the project: To execute the example provided in main.dart, use:
   dart run
  1. Input files: Place your XML configuration files in the appropriate directory (e.g., lib/tilesets). Modify the sample JSON file (samples.json) to include your tile configurations.

  2. Output: Generated bitmaps and optional text outputs will be saved in the output/ directory. Samples of the output can be found in the output folder

Importing the Package

To use the wfc package, in your own projects, import the public API (look in example/example.dart or ./main.dart to see examples):

   dart
   import 'package:wfc/wfc.dart';

Code Structure

  1. Contributing

Contributions are welcome! If you find a bug or have a suggestion for improvement, feel free to open an issue or submit a pull request.

Steps to Contribute:

  1. Fork this repository.
  2. Create a new branch for your changes:
git checkout -b feature/my-feature
  1. Commit your changes:
git commit -m "Add my feature"
  1. Push to your branch:
git push origin feature/my-feature
  1. Open a pull request. Make sure to follow the existing coding style and include tests where applicable.

  2. License

This project is licensed under the MIT License.

The original C# implementation by mxgmn is also licensed under the MIT License.