Nature of code, a very first [pancake] assignment: a random walk.

3 min readFeb 3, 2020

Initially, I wanted to create something original based on the key concepts of this week. However, I failed and had to turn to the alternative of studying the tutorials and trying to repeat them, and searching for the inspiring examples across the web – to study and play with them. There are a few reasons for this.

First of all, I genuinely love the concepts but it feels like my brain is still adjusting to the new kind of thinking, and for now, I just can’t be creative at the same time with trying to get the math. More specifically: I started the process thinking either about something simple that I can use later in my portfolio or something that could be a start for the bigger project that could take a few months.

After watching and reading I realized that I can try to practice something ‘painting with colors // particles // pixels’ since I definitely want to learn it OR make something that looks living — just because it’s cool, and if I succeed I will entertain the class which is definitely worth doing.

Both plans didn’t end up gracefully. I began with following the basic Random walk tutorial — I watched the video and read this part in the book ‘Nature of code’ which helped me a great deal when I was basically close to panicking. However, the only thing with color that I could achieve in my first sketch was making the Walker change its color — which is not a great achievement. Nevertheless, here is my first attempt.

I didn’t stop here. After watching a few tutorials I got the feeling that I can get help from the ‘Diffusion-Limited Aggregation’ video because it definitely deals with playing with colors. The thing is, I couldn’t really play with the final code, it just doesn’t make any sense when there are so many things that trigger questions and need something I call ‘brain restructuring’. So, I decided to follow this video along, step by tiny step. Since this video is more than 40 minutes long, at some point, somewhere here:

… my localhost just stopped responding just as my head stopped consuming information.

HOWEVER. Before I even started trying to get deeper into the Diffusion-Limited Aggregation, I found a few examples by Johan Karlsson, one of them won my heart for being ALIVE.

Here are the examples of Random walk art by Johan Karlsson. The thing is, at the time I found I couldn’t do something with the code except for copypasting it and being jealous. But after I followed along even the beginning of the longest tutorial on the subject I somehow realized I can actually take the code from the example I love, and, at least study it thoroughly, leaving comments about what is going on where, and try to adjust the parameters I fully get.

That's what I did. I must admit I still didn’t get myself to the point where I can actually imagine how I want to build such little ‘creatures’ out of vectors and tails on my own, and how can I predict beforehand that their movement will look this simulative. I think it’s gonna take some practice and finding my own patterns.

Here is the final look:

I posted the code with my comments on GitHub. There is still one part of it that I couldn’t get by myself:

Some conclusions

  1. As for me, the book ‘Nature of code’ truly HELPS not to get too many panic attacks.
  2. I really hope to get more creative starting with the next assignment.
  3. My favorite fractals are somewhere close.
  4. Vectors are cool.