Author Topic: Wavefunction collapse  (Read 2065 times)

chrisws

  • Guest
Wavefunction collapse
« on: February 05, 2019, 08:45:32 PM »
The "Wavefunction collapse" algorithm is pretty interesting.

Here's an article that explains how it works.

https://robertheaton.com/2018/12/17/wavefunction-collapse-algorithm/

The example was given in python.  Here's my version in SmallBASIC.

https://gist.github.com/chrisws/badd5d0c1a53d86e1020c00878bb4738

B+

  • Guest
Re: Wavefunction collapse
« Reply #1 on: February 06, 2019, 02:16:33 PM »
Hi Chris,

Should this Wavefunction collapse.bas code work on SB 12.14 Win64 Mon, 19 Nov 2018 version (Windows 10)?

I am getting error:
« Last Edit: February 06, 2019, 02:19:36 PM by B+ »

chrisws

  • Guest
Re: Wavefunction collapse
« Reply #2 on: February 07, 2019, 12:01:10 PM »
Hi Chris,

Should this Wavefunction collapse.bas code work on SB 12.14 Win64 Mon, 19 Nov 2018 version (Windows 10)?

I am getting error:

Sorry, yes there's a minor bug in 0.12.14 giving this error. Just change the line to

        j = self.wavefunction.get([x, y])
        if len(j) != 1 then

There's also a similar problem in propagate(), change:

        for other_tile in self.wavefunction.get(other_coords)

to:
        j = self.wavefunction.get(other_coords)
        for other_tile in j

To play around, you can also try changing this line

model = Model([15, 20], weights, compatibility_oracle)

and give some other dimensions.

Have fun!


B+

  • Guest
Re: Wavefunction collapse
« Reply #3 on: February 07, 2019, 05:57:39 PM »
OK that fixed it for me, Thanks!