Giter Club home page Giter Club logo

wavefunction-collapse's Introduction

Wavefunction Collapse

This is the example code for my blog post, "The Wavefunction Collapse Algorithm explained very clearly". To install dependencies:

virtualenv vendor
source vendor/bin/activate
pip install -r requirements.txt

Then to run:

python main.py

You will get a nice picture of a coastline.

WFC Example

wavefunction-collapse's People

Contributors

robert avatar scan-lan avatar sdierauf avatar vaskivo 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  avatar  avatar

wavefunction-collapse's Issues

dirrections

It looks like directions are taken in standard way. X is horizontal axis and Y is vertical.

UP = (0, 1)
LEFT = (-1, 0)
DOWN = (0, -1)
RIGHT = (1, 0)

But as far as I know iteration over matrixes is happening first over Y axis and then over X.

for x, row in enumerate(matrix):
for y, cur_tile in enumerate(row):
if cur_tile not in weights:
weights[cur_tile] = 0
weights[cur_tile] += 1
for d in valid_dirs((x,y), (matrix_width, matrix_height)):
other_tile = matrix[x+d[0]][y+d[1]]
compatibilities.add((cur_tile, other_tile, d))
return compatibilities, weights
input_matrix = [
['L','L','L','L'],
['L','L','L','L'],
['L','L','L','L'],
['L','C','C','L'],
['C','S','S','C'],
['S','S','S','S'],
['S','S','S','S'],
]
input_matrix2 = [
['A','A','A','A'],
['A','A','A','A'],
['A','A','A','A'],
['A','C','C','A'],
['C','B','B','C'],
['C','B','B','C'],
['A','C','C','A'],
]

License missing

Great code and blog. I don't suppose you could put a license on it?

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.