This is my first assignment from my first class with the one-and-only Dan Shiffman (applause). In our first session, Mr. Shiffman explained that vectors will more or less be the foundation of everything we do in the Nature of Code. I should also mention what the Nature of Code fundamentally is, which is basically recreating physical behaviors from the natural world through coding.
Our first assignment was to create a random walker. I made a few, but my first walker (shown above) I whipped up from scratch mostly to re-familiarize myself with .p5js after our long break (Here is a link to the code).This one does not use vectors, but it’s a random walker nonetheless. In this sketch, I spent a lot of time trying to figure out how to constrain the walker within the canvas bounds, but I’m realizing that it’s actually kind of complicated to do.
First, I tried reversing the values when the walker reached an edge, so “posx” would become “-posx",” and the same goes with Y. This definitely increases the likelihood that the walker will come back, but not by much. In the end, I found that you have to fundamentally change the probability of the walker once it reaches and edge in order to favor the likelihood that it will move away from the edge, which is actually pretty annoying to write out case by case. I also mapped the walker to a rainbow using HSB values, because why not a rainbow?