Coding Challenge 171: Wave Function Collapse
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
Trailer by https://twitter.com/bernizeck
π 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