Straight out of quantum mechanics, Wave Function Collapse is an algorithm for procedural generation of images. 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. Also, check out WFC's predecessor: Model Synthesis (more info below). Code: https://thecodingtrain.com/challenges/171-wave-function-collapse
๐ Watch this video ad-free on Nebula https://nebula.tv/videos/codingtrain-coding-challenge-171-wave-function-collapse
๐ป Github Repo: https://github.com/CodingTrain/Wave-Function-Collapse
๐น๏ธ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/_kbz6Xq7l
๐ฅ Previous: https://youtu.be/0zac-cDzJwA?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
๐ฅ Next: https://youtu.be/FfCBNL6lWK0?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
๐ฅ All: 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
๐ Model Synthesis: https://paulmerrell.org/model-synthesis/
๐ฃ โ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
๐ Matrix Transformations: https://thecodingtrain.com/tracks/transformations-in-p5
๐ฅ Oskar Stalberg - Wave Function Collapse in Bad North: https://youtu.be/0bcZb-SsnrA
Related Coding Challenges:
๐ 10 Maze Generator: https://youtu.be/HyK_Q5rrcr4
๐ 162 Self Avoiding Walk: https://youtu.be/m6-cm6GZ1iw
๐ 165 Slide Puzzle: https://youtu.be/uQZLzhrzEs4
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 asymmetry
1:12:06 First asymmetric 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: https://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://thecodingtrain.com/discord
๐ Membership: http://youtube.com/thecodingtrain/join
๐ Store: https://standard.tv/codingtrain
๐๏ธ 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
#wavefunctioncollapse #generativeart #p5js #javascript