Giter Club home page Giter Club logo

wfc's Introduction

Wave Function Collapse

test dependency status

Collection of rust libraries implementing the "Wave Function Collapse" procedural generation algorithm.

  • wfc: low level crate implementing wfc on arbitrary grids
  • wfc_image: helper crate simplifying running wfc on image files

Read this page for a description of how the Wave Function Collapse algorithm works.

wfc's People

Contributors

0b01 avatar gridbugs avatar nsmryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wfc's Issues

How to use WFC for tiles?

I found out about this library through the blog post
https://gridbugs.org/wave-function-collapse/
It describes the library as being composed of a basic WFC algorithm, which is part of the wfc
crate, and another library that uses the former in order to operate on images, wfc-image.
I have been successful in trying out wfc-image however I need a tile-based approach for my own
application.

I have a 2D tileset and want to create a map using adjacency rules (so basically tiled, not overlapping method)
This is described on the blog:

Note that there are some alternative applications of WFC besides generating similar images, such as arranging hand-crafted tiles with user-specified adjacency rules and frequency hints. These applications would still use the same core algorithm, but the image processor would be different.

In the post there's a function mentioned that would basically do what I want:

fn wfc_core(
    adjacency_rules: AdjacencyRules,
    frequency_rules: FrequencyHints,
    output_size: (u32, u32),
) -> Grid2D<TileIndex> { ... }

However this function doesn't exist inside wfc.
I've tried to understand how wfc-image uses wfc.
It seems like it calls new_wrap_forbid().
But it's not clear to me how I would accomplish my goal in particular, as there's no examples of using wfc by itself.

My question is, is this possible with your library? If so, then could you point me in the right direction as to which functions I should use?

I understand I'd probably have to call new_wrap_forbid().
I don't think I need to set the wrap to anything special, I assume it works with just WrapXY for my case? Same with forbid, I don't know what that is but I assume I can just set it to ForbidNothing.
Output_size and RNG are obvious.
But I don't understand what the GlobalStats part represents.
It must represent the adjacency rules since no other parameter contains those.
How do I construct the adjacency rules? I have explicit rules I already know beforehand.

Thanks in advance for any help you can give me.

Better documentation of public members

Documentation of the public members of the crate is really sparse. Example in wfc_image makes the implementation a little easier to understand, but I personally don't find it straightforward.

I am currently in process of implementing WFC algorithm in my crate and will compare my implementation to the one derived from this crate. After successfully implementing it over grid type in my crate, I can try to open a PR with some additional documentation - would it be welcome?

Question: is it possible to use it passing fixed tiles?

Hello! I was about to implement my own wfc and found this, I have being playing with it and it's great!

I have a case of use where I need to create a map, but this map have fixed tiles in it, let's say that the tile in (0,0) must be type 1, (1,4) is type 2 and then the rest of tiles must be randomly generated using wfc

Does this crate cover that case? Can you point me in the right direction on how to do this?

Thanks

License

I would like to use your library in my pixel art editor. Can you add a license? Thanks!

Assertion about compatible pattern weights fails

The assertion in WaveCell::choose_pattern_id fails, seemingly no matter what global stats I use. I use patterns that all have the same weight (100).

        assert_eq!(
            self.sum_compatible_pattern_weight(global_stats),
            self.stats.sum_compatible_pattern_weight
        );
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `316900`,
 right: `321800`'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.