mxgmn / WaveFunctionCollapse

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics
Other
23.18k stars 1.24k forks source link

How to implement the autocompletion of the user input? #29

Closed MatveyK closed 7 years ago

MatveyK commented 7 years ago

Hello, awesome work on this algorithm. Really cool stuff.

I'm still reading the code and getting a grip on what's happening, so I don't understand every part of the code yet. But in the readme you give an example of a human started level completed by the algorithm. So I tried to implement that.

I tried manually creating a wave that has only one coefficient set to true on the tiles that I draw, with the rest set to false. I then set that as the wave in the simple tiled model. But this approach doesn't work as the algorithm always fails after about 19 iterations (using the Castle example). (Basically as soon as the propagation reaches the user defined tiles, the result is unsuccessful).

Could you explain how did you do the autocompletion?

NikkyAI commented 7 years ago

i hope i can help a little .. i made myself a little table to understand how it works

as far as i understand you match the right side of the left piece and the left side of the right piece the left piece can be rotated left by x the L x number pointing to where the side thats compared will end up the right piece cna be rotated right by x and i marked it using R x

L 3 R 1
bridge L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
component L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
connection L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
corner L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
dskew L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
skew L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
substrate L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
t L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
track L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
transition L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
turn L 2 L 0 R 0 R 2
L 1 R 3
L 3 R 1
vias L 2 L 0 R 0 R 2
L 1 R 3

PS: i am working on a script that generates the neighbor entries based on which faces/connections a tile has.. it also supports things like (circuit example again) connection has to connect to component_internal, component_internal, can connect to components, essentially circumeventing mini chips if i had only compare equality of face/connection names

i will share the script here probably

selfsame commented 7 years ago

@MatveyK I believe @mxgmn mentioned you have to call Propagate a few times after manually writing the wave coefficients? Interested in how to set this up as well :)

mxgmn commented 7 years ago

Hi! After setting up the wave (=observing with predetermined results) you need to propagate the obtained information with while(Propagate());. See, for example, how I set up the ground constraint in OverlappingModel.Clear().

mxgmn commented 7 years ago

@NikkyAI Yeah, the quickest way to setup adjacency data is just to label the edges of each tile. Then the settings xml files for each tileset would be very short. However, this works only with transitive adjacency data - if tile A can connect to tiles B and C then tiles B and C should also connect. Knots and Circles tilesets are transitive, the others - not.

mxgmn commented 7 years ago

I explained how to handle constraints in more detail in this issue.