Coding Challenge #34: Diffusion-Limited Aggregation

In this Coding Challenge, I explore the generative algorithm “Diffusion-Limited Aggregation.” The DLA visual pattern is generated from random walkers clustering around a seed (or set of seed) point(s).

Support this channel on Patreon:

Send me your questions and coding challenges!:


Links discussed in this video:
Diffusion-Limited Aggregation Wikipedia:
Paul Bourke’s DLA reference:
Atom Live Server Package:

Source Code for the Video Lessons:


For More Coding Challenges:

Help us caption & translate this video!






37 responses to “Coding Challenge #34: Diffusion-Limited Aggregation”

  1. Soumyadipta Sengupta Avatar

    Periodic Boundaries are needed

  2. Ted Zards Avatar

    I just wasted 27 minutes of my life… Yes 27… The first 20 were very informative!

  3. Johan Karlsson Avatar

    I did these animations with JavaScript in 2015, also using Paul Bourke's "paper".
    * Builds from the center:
    * Builds from the sides:
    * Builds from the sides, visualizing the walkers:
    * Builds from the bottom of the screen:

    Instead of storing the stuck walkers in a flat list I use a 2d array to keep track of the stuck ones. The 2d array has the same size as the canvas, that way I don't need to loop through a flat list to check for stuck walkers – I can just index them directly like tree[x][y].

  4. 김혜리 Avatar

    Thanks a lot Daniel!

  5. Harold Wren Avatar

    Thank you, great job, I was looking for an introduction to dendritic computing with SPH models !

  6. TheToalNoob Avatar

    I love this channel, and i find it amazing that it's grown so fast and to such a big size. I'd be interested to know the average level of expertise your audience has that are watching. I only ask because you go through some pretty intermediate/expert topics, and little for a beginner programmer to start to learn with. Just curious if the little explanations you give on why your doing certain things, is enough for a beginner to pick up on and understand the bigger picture.

  7. LifE's YouTube Channel Avatar

    what program are you using for programming p5?

  8. David Sullivan Avatar

    I think something that would give a good result is being able to change the radius of the walkers while they are moving, not just when they are created. You could also tie the radius to how many walkers have become stuck. (You might want to tie this to a logarithm so they scale a bit nicer.)

  9. Rodrick Avatar

    I think I wanna have an object – thats what I answer my grandma, when she asks me, what I want fo christmas.

  10. 93hickey Avatar

    Did my final year physics project on DLA… did it in python, first real program i've made , was replicating nanotubes undergoing DLA and trying to get some fractal dimension numbers/trends from different "nanotube" aspect ratios. it was an interesting projects, my results were fairly shit because i ran out of time but I might revisit it sometime.

  11. Galex Avatar

    Can You make a Atom Tutorial PLESE!!!!!! I have Atom But this dose not work for me.
    The (Background, Color etc.) Do you have a packege?


    You said we should remind you if there is no Processing Version of this? Well here is that reminder! (Unless there is and I just can't find it)

  13. Tell Me Why Avatar

    Great videos, Daniel! Keep up good work! I cannot take a break! Watched all previous your challenges in a row!
    Just a comment; why not trying to relate stickiness to size? I think it makes so much sense.

  14. Dominic Forster Avatar

    Why don't you just let the tree handle the radius of the 'stucked' walkers? Decrease the radius by the length of the array.

  15. Richard Budíček Avatar

    +Daniel Shiffman Can you code Pac-Man?

  16. C-Zar Avatar

    I have been trying to figure out how to create a local multiplayer game in processing but I don't know where to start, or how to create a server. How would you go about creating this in Processing?

  17. JiffyJames85 Avatar

    so your approach is different than the standard Walker, but it reminds me of a seed particle being placed in a supersaturated bath (like copper oxide in hydrogen peroxide). Molecules are free to roam until they come in contact with the seed or an arm of the seed.

  18. Rodrigo David Avatar

    I'm kind of lost here.
    Which language is it? Processing or JavaScript?

    And which IDE is he using?


  19. ip jonathan daniel Avatar

    Hi, I just found out your series of videos a few days ago and they are great! The instructions and explanations are great. However when I tried to follow your videos to do some programming, I got stuck with many errors and I can't proceed. Are there any recommendations for me to configure the p5.js to work as well as yours?

  20. Jaime G. Avatar

    I am not sure how I stumbled upon your channel..But now I'm hooked! I'm working through your book playlist now. How could I purchase a copy? Are you one of the creators of p5js? My mind is exploding with joy!

  21. HJ Mg Avatar

    Excellent 😀

  22. Everest Ev10 Avatar

    how did you become such a good progamer and how can i get as good as you too?

  23. Jack Rugile Avatar

    I had a fun time messing around with this one!

  24. Ken Haley Avatar

    Another good one!! Suggestion: When a walker gets stuck to the tree, set its size and color based on the tree element it got stuck to. So if a walker sticks to a tree element with radius 10, it's radius becomes 10 * .95 (or whatever). And the hue could be set based on the radius assigned. Also, instead of slicing out the stuck walker, replace it with a new one at the same place in the walkers array. That way you keep the walker count constant and never have to do any slices or pushes into the walkers array.

  25. Lorenzo Dossi Avatar

    what code editor did he use?

  26. Kenneth Luplau-Brøgger Avatar

    In the case where the tree started at the bottom… In my mind, I would start a tree and base the next random "walker" along the last walkers edge. Why is that a bad idea?

  27. Peter Heijstek Avatar

    Hey Dan, first of all I want to say you are an amazing person and you make very cool videos about interesting things! But I think you and your channel can get even more awesome if you could do a (or some) bigger project(s) (like a video every (two) weeks). For example: making a basic game, cloning/remake a simple program, etc.

    Don't get me wrong, your projects are already always fun to watch, but I think many viewers (including me, of course 😉 ) would love to see something like that. You don't have to, of course, but just think about it!

  28. Philippe Debie Avatar

    Hey why don't you use place, velocity and acceleration in the walkers like you did previously? They would move faster from one side to the other of the screen and increase performance, right?

  29. zlotnleo Avatar

    When you tried the probability, you wrote random(1) < 0.1 and I believe random(1) always evaluates to 0. Also, it was not the best of ideas to do both probability and downwards-biased velocity at the same time since walkers not getting stuck will just fill up the bottom row due to the 0-height constraint

  30. Andrei Gavrila Avatar

    Check the git repo for pull requests. I have submitted one fixing a small bug.

  31. Ibab Galakhov Avatar

    Love your videos! Keep up the great work.

  32. Foodey Avatar

    Yay 😀 Another video to translate!

Leave a Reply

Your email address will not be published. Required fields are marked *