wave-function-collapse | Wave function collapse python implementation

 by   Coac Python Version: Current License: No License

kandi X-RAY | wave-function-collapse Summary

kandi X-RAY | wave-function-collapse Summary

wave-function-collapse is a Python library. wave-function-collapse has no bugs, it has no vulnerabilities, it has build file available and it has low support. You can download it from GitHub.

Wave function collapse python implementation
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              wave-function-collapse has a low active ecosystem.
              It has 28 star(s) with 4 fork(s). There are 6 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 1 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of wave-function-collapse is current.

            kandi-Quality Quality

              wave-function-collapse has 0 bugs and 0 code smells.

            kandi-Security Security

              wave-function-collapse has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              wave-function-collapse code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              wave-function-collapse does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              wave-function-collapse releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              wave-function-collapse saves you 158 person hours of effort in developing the same functionality from scratch.
              It has 394 lines of code, 41 functions and 8 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed wave-function-collapse and discovered the below as its top functions. This is intended to give you an instant insight into wave-function-collapse implemented functionality, and help decide if they suit your requirements.
            • Propagate cells in cell
            • Checks if the given candidate pattern is compatible with the given offset
            • Get the neighbors of the grid
            • Return the cell at the given index
            • Run the wizard
            • Observe the low entropy cell
            • Check if all cells are allowed
            • Perform a single cell
            • Returns the image of the grid
            • Return the value of the rule
            • Convert a pattern to an image
            • Create a pattern from a sample
            • Convert a sample image to a NumPy array
            • Plot patterns
            • Precompute legal patterns
            • Export notes to a MIDI file
            • Load a MIDI sample from a MIDI file
            • Set the legal patterns for the given pattern
            • Export a voxel
            • Run a single cell
            • Load a sample from a file
            • Load a voxel sample from a file
            Get all kandi verified functions for this library.

            wave-function-collapse Key Features

            No Key Features are available at this moment for wave-function-collapse.

            wave-function-collapse Examples and Code Snippets

            No Code Snippets are available at this moment for wave-function-collapse.

            Community Discussions

            Trending Discussions on wave-function-collapse

            QUESTION

            Issues implementing the "Wave Collapse Function" algorithm in Python
            Asked 2019-Jul-25 at 07:48

            In a nutshell:

            My implementation of the Wave Collapse Function algorithm in Python 2.7 is flawed but I'm unable to identify where the problem is located. I would need help to find out what I'm possibly missing or doing wrong.

            What is the Wave Collapse Function algorithm ?

            It is an algorithm written in 2016 by Maxim Gumin that can generate procedural patterns from a sample image. You can see it in action here (2D overlapping model) and here (3D tile model).

            Goal of this implementation:

            To boil down the algorithm (2D overlapping model) to its essence and avoid the redondancies and clumsiness of the original C# script (surprisingly long and difficult to read). This is an attempt to make a shorter, clearer and pythonic version of this algorithm.

            Characteristics of this implementation:

            I'm using Processing (Python mode), a software for visual design that makes image manipulation easier (no PIL, no Matplotlib, ...). The main drawbacks are that I'm limited to Python 2.7 and can NOT import numpy.

            Unlike the original version, this implementation:

            • is not object oriented (in its current state), making it easier to understand / closer to pseudo-code
            • is using 1D arrays instead of 2D arrays
            • is using array slicing for matrix manipulation

            The Algorithm (as I understand it)

            1/ Read the input bitmap, store every NxN patterns and count their occurences. (optional: Augment pattern data with rotations and reflections.)

            For example, when N = 3:

            2/ Precompute and store every possible adjacency relations between patterns. In the example below, patterns 207, 242, 182 and 125 can overlap the right side of pattern 246

            3/ Create an array with the dimensions of the output (called W for wave). Each element of this array is an array holding the state (True of False) of each pattern.

            For example, let's say we count 326 unique patterns in input and we want our output to be of dimensions 20 by 20 (400 cells). Then the "Wave" array will contain 400 (20x20) arrays, each of them containing 326 boolan values.

            At start, all booleans are set to True because every pattern is allowed at any position of the Wave.

            ...

            ANSWER

            Answered 2019-Jul-18 at 22:46

            While looking at the live demo linked in one of your examples, and based on a quick review of the original algorithm code, I believe your error lies in the "Propagation" step.

            The propagation is not just updating the neighbouring 4 cells to the collapsed cell. You must also update all of those cells neighbours, and then the neighbours to those cells, etc, recursively. Well, to be specific, as soon as you update a single neighbouring cell, you then update its neighbour (before getting to the other neighbours of the first cell), i.e. depth-first, not breadth-first updates. At least, that's what I gather from the live demo.

            The actual C# code implementation of the original algorithm is quite complicated and I don't fully understand it, but the key points appear to be creation of the "propagator" object here, as well as the Propagate function itself, here.

            Source https://stackoverflow.com/questions/57049191

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install wave-function-collapse

            py-vox-io is used to load magica voxel file to numpy array.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/Coac/wave-function-collapse.git

          • CLI

            gh repo clone Coac/wave-function-collapse

          • sshUrl

            git@github.com:Coac/wave-function-collapse.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link