Coding Challenge 171: Wave Function Collapse
The Coding Train The Coding Train
1.68M subscribers
516,804 views
0

 Published On Premiered Jul 3, 2022

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...

šŸš€ Watch this video ad-free on Nebula https://nebula.tv/videos/codingtrain-...

šŸ’» Github Repo: https://github.com/CodingTrain/Wave-F...
šŸ•¹ļø p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/s...

šŸŽ„ Previous: Ā Ā Ā ā€¢Ā CodingĀ ChallengeĀ 170:Ā TheĀ MontyĀ HallĀ ...Ā Ā 
šŸŽ„ Next: Ā Ā Ā ā€¢Ā CodingĀ ChallengeĀ 172:Ā HorizontalĀ Dire...Ā Ā 
šŸŽ„ All: Ā Ā Ā ā€¢Ā CodingĀ ChallengesĀ Ā 

References:
šŸ’” WFC Challenge Suggestion: https://github.com/CodingTrain/Sugges...
šŸ—„ Wave Function Collapse Algorithm: https://github.com/mxgmn/WaveFunction...
šŸ—„ Model Synthesis: https://paulmerrell.org/model-synthesis/
šŸ“£ ā€‹Wave Collapse Function algorithm in Processing: https://discourse.processing.org/t/wa...
šŸ—„ Array.prototype.filter(): https://developer.mozilla.org/en-US/d...
šŸž Encoding tiles symmetry and rotation #14: https://github.com/CodingTrain/Wave-F...
šŸž The issue with asymmetric tiles and an easy solution #16: https://github.com/CodingTrain/Wave-F...
šŸ—„ Array.prototype.reverse(): https://developer.mozilla.org/en-US/d...

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/ze...
šŸŽØ Wave Function Collapse Demonstration: https://oskarstalberg.com/game/wave/w...
šŸŽØ Infinite procedurally generated city: https://marian42.de/article/wfc/
šŸŽØ Generating stairy scenes: https://twitter.com/exutumno/status/8...

Live Stream Archives:
šŸ”“ Day 1: Ā Ā Ā ā€¢Ā WaveĀ FunctionĀ CollapseĀ TakeĀ 2Ā Ā 
šŸ”“ Day 2: Ā Ā Ā ā€¢Ā WaveĀ FunctionĀ CollapseĀ TakeĀ 3Ā Ā 
šŸ”“ Day 3: Ā Ā Ā ā€¢Ā WaveĀ FunctionĀ CollapseĀ theĀ FinalĀ Coun...Ā Ā 

Videos:
šŸŽ„ Solving Wordle with Information Theory: Ā Ā Ā ā€¢Ā SolvingĀ WordleĀ usingĀ informationĀ theoryĀ Ā 
šŸŽ„ Pixel Array: Ā Ā Ā ā€¢Ā 11.3:Ā TheĀ PixelĀ ArrayĀ -Ā p5.jsĀ TutorialĀ Ā 
šŸŽ„ Arrow Function: Ā Ā Ā ā€¢Ā 16.3:Ā ES6Ā ArrowĀ FunctionĀ -Ā TopicsĀ ofĀ ...Ā Ā 
šŸŽ„ Higher Order Array Functions: Ā Ā Ā ā€¢Ā 16.5:Ā HigherĀ OrderĀ FunctionsĀ inĀ JavaS...Ā Ā 
šŸš‚ Matrix Transformations: https://thecodingtrain.com/tracks/tra...
šŸŽ„ Oskar Stalberg - Wave Function Collapse in Bad North: Ā Ā Ā ā€¢Ā EPC2018Ā -Ā OskarĀ StalbergĀ -Ā WaveĀ Funct...Ā Ā 

Related Coding Challenges:
šŸš‚ 10 Maze Generator: Ā Ā Ā ā€¢Ā CodingĀ ChallengeĀ #10.1:Ā MazeĀ Generato...Ā Ā 
šŸš‚ 162 Self Avoiding Walk: Ā Ā Ā ā€¢Ā CodingĀ ChallengeĀ 162:Ā Self-AvoidingĀ WalkĀ Ā 
šŸš‚ 165 Slide Puzzle: Ā Ā Ā ā€¢Ā CodingĀ ChallengeĀ 165:Ā SlideĀ PuzzleĀ Ā 

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: https://thecodingtrain.com/
šŸ‘¾ Share Your Creation! https://thecodingtrain.com/guides/pas...
šŸš© Suggest Topics: https://github.com/CodingTrain/Sugges...
šŸ’” GitHub: https://github.com/CodingTrain
šŸ’¬ Discord: https://thecodingtrain.com/discord
šŸ’– Membership: http://youtube.com/thecodingtrain/join
šŸ›’ Store: https://standard.tv/codingtrain
šŸ–‹ļø Twitter: Ā Ā /Ā thecodingtrainĀ Ā 
šŸ“ø Instagram: Ā Ā /Ā the.coding.trainĀ Ā 

šŸŽ„ Coding Challenges: Ā Ā Ā ā€¢Ā CodingĀ ChallengesĀ Ā 
šŸŽ„ Intro to Programming: Ā Ā Ā ā€¢Ā StartĀ learningĀ here!Ā Ā 

šŸ”— 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-o...

This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecod...

#wavefunctioncollapse #generativeart #p5js #javascript

show more

Share/Embed