Talk:Wave function collapse: Difference between revisions

Content added Content deleted
Line 25: Line 25:


: I had several problems there. One was an off-by-one error on the size of the result. Another was that I had flipped the left/right top/bottom constraints, so the tiles were not matching up right. The implementation on the task page is fixed now. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 07:46, 11 July 2022 (UTC)
: I had several problems there. One was an off-by-one error on the size of the result. Another was that I had flipped the left/right top/bottom constraints, so the tiles were not matching up right. The implementation on the task page is fixed now. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 07:46, 11 July 2022 (UTC)

== Task not to the point ==

The required task is not showcasing the point of the so-called wavefunction collapsing idea, which seems to be that it is fast and is able to generate neighboring tiles in a more coherent manner. The task asks for a routine that uses only 5 tile types, which are very easy to interconnect almost arbitrarily, thus becomes a little pointless (no doubt influenced by the initially linked silly youtube video). The following code that sequentially generates tiles indefinitely:
<lang python>import random

def make_row(w):
conn = '0000 1101 1110 0111 1011'.split()
tiles = ' . ╠.═╩.═╣.═╦'.split('.')
r = []

while True:
p, r = r, []
for i in range(w):
t = [x for x in range(5) if (not r or conn[x][2] == conn[r[-1]][0])
and (not p or conn[x][1] == conn[p[i]][3])]

r.append(random.choice(t))

yield ''.join(tiles[x] for x in r)

for x in make_row(20):
print(x)</lang>
is a lot shorter and a lot more efficient than another piece of code I wrote using WFC, and the output between the two are pretty much indistinguishable.

I guess my point is that the task is still bad, but given the existing solutions, throwing them away would be a shame, so I don't know what's a good solution to this. --[[User:Katzenbaer|Katzenbaer]] ([[User talk:Katzenbaer|talk]]) 07:44, 12 July 2022 (UTC)