Basicprogramming(.org) > SmallBASIC

Wavefunction collapse

(1/1)

chrisws:
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+:
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:

chrisws:

--- Quote from: B+ 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:

--- End quote ---

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+:
OK that fixed it for me, Thanks!

Navigation

[0] Message Index

Go to full version