mxgmn / WaveFunctionCollapse

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

some issues about the neighbor rule #95

Open Alex-skiler opened 1 week ago

Alex-skiler commented 1 week ago

when I write my neighbor part(in the sample.xml),I found i couldn't define upper or below neighbor rule. As an example, there is 'T',I want 'T' below neighbor a 'I'. How can i do it?

mxgmn commented 1 week ago

Indeed, it is only possible to specify left and right neighbors in the xml file. But you still can specify arbitrary adjacencies, because you can rotate the tiles. For example,

<neighbor left="cliff 1" right="road 3"/>

means that the cliff tile rotated 1*90 degrees can be adjacent from the left to the road tile rotated 3*90 degrees. So it is possible to specify vertical adjacencies using tile rotations.

Alex-skiler commented 1 week ago

I found these code seem to decide the "upper or below" rules int L = action[firstOccurrence[left[0]]][left.Length == 1 ? 0 : int.Parse(left[1])], D = action[L][1]; int R = action[firstOccurrence[right[0]]][right.Length == 1 ? 0 : int.Parse(right[1])], U = action[R][1]; why the D and U directly use '1' as the second number in the action[][]?

mxgmn commented 1 week ago

Because Down and Up correspond to Left and Right by rotating 1*90 degrees.