Straight out of quantum mechanics, Wave Function Collapse is an algorithm for procedural generation of images. https://thecodingtrain.com/challenges/171-wave-function-collapse
In this video (recorded over 3 live streams) I attempt the tiled model and explore a variety of solutions to the algorithm in JavaScript with p5.js.
???? Github Repo: https://github.com/CodingTrain/Wave-Function-Collapse
????️ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/_kbz6Xq7l
???? Previous video: https://www.youtube.com/watch?v=0zac-cDzJwA&list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
???? All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
???? WFC Challenge Suggestion: https://github.com/CodingTrain/Suggestion-Box/issues/287
???? Wave Function Collapse Algorithm: https://github.com/mxgmn/WaveFunctionCollapse
???? Wave Collapse Function algorithm in Processing: https://discourse.processing.org/t/wave-collapse-function-algorithm-in-processing/12983
???? Array.prototype.filter(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
???? Encoding tiles symmetry and rotation #14: https://github.com/CodingTrain/Wave-Function-Collapse/issues/14
???? The issue with asymmetric tiles and an easy solution #16: https://github.com/CodingTrain/Wave-Function-Collapse/issues/16
???? Array.prototype.reverse(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
Creative Works Featured:
???? Oisín: Wave Function Collapse for poetry: https://github.com/mewo2/oisin
???? Townscaper: https://www.townscapergame.com/
???? unity-wave-function-collapse: https://selfsame.itch.io/unitywfc
???? Zelda WFC: https://observablehq.com/@makio135/zelda-wfc
???? Wave Function Collapse Demonstration: https://oskarstalberg.com/game/wave/wave.html
???? Infinite procedurally generated city: https://marian42.de/article/wfc/
???? Generating stairy scenes: https://twitter.com/exutumno/status/895683455299723265?lang=eu
Live Stream Archives:
???? Day 1: https://youtu.be/6Vag7NJUjJo
???? Day 2: https://youtu.be/FGmB5ZHhhiA
???? Day 3: https://youtu.be/QvoTSl60Y88
Videos:
???? Solving Wordle with Information Theory: https://youtu.be/v68zYyaEmEA
???? Pixel Array: https://youtu.be/nMUMZ5YRxHI
???? Arrow Function: https://youtu.be/mrYMzpbFz18
???? Higher Order Array Functions: https://youtu.be/H4awPsyugS0
???? Transformations in p5.js: https://youtu.be/o9sgjuh-CBM
???? Oskar Stalberg - Wave Function Collapse in Bad North: https://youtu.be/0bcZb-SsnrA
Timestamps:
0:00 Day 1! Wave Function Collapse!
2:00 Entropy in Sudoku.
5:41 Comparing Sudoku to WFC
9:24 Starting to code.
11:05 Collapsing cells.
13:30 Evaluating entropy.
18:47 Updating entropy after collapse.
22:45 Data structure for rules.
24:50 Implementing rules for next collapse.
36:28 Explaining the rules.
38:45 Day 2! Refactoring the code.
39:26 Create a Tile class
44:57 Generate the rules from Tile objects.
55:40 Using new circuit board tileset.
1:00:40 Day 3! Dealing with asymmetrical tiles
1:01:56 Assigning index values to edges.
1:06:53 Incorporating edges into code.
1:10:05 Change adjacency for assymetry
1:12:06 First assymetric WFC image!
1:12:40 Restart if no valid cell found.
1:15:48 Next steps!
1:18:05 Thanks for watching!
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
???? Website: http://thecodingtrain.com/
???? Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide
???? Suggest Topics: https://github.com/CodingTrain/Suggestion-Box
???? GitHub: https://github.com/CodingTrain
???? Discord: https://discord.gg/hPuGy2g
???? Membership: http://youtube.com/thecodingtrain/join
???? Store: https://standard.tv/codingtrain
???? Books: https://www.amazon.com/shop/thecodingtrain
????️ Twitter: https://twitter.com/thecodingtrain
???? Instagram: https://www.instagram.com/the.coding.train/
???? Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
???? Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
???? p5.js: https://p5js.org
???? p5.js Web Editor: https://editor.p5js.org/
???? Processing: https://processing.org
???? Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new