For this week's Random Walk assignment, I was heavily inspired by the notion of a Levy Flight simulating the behavior of a predator searching for prey. The differences in step size of the 'walker' reminded me of a shark swimming through water amongst smaller fishes:
In this video, the two sharks navigate through the large school of fish, moving in a Levy flight fashion. The smaller fish naturally avoid the sharks by maintaining a certain distance, but also fill the gaps once the sharks change position. The result is a mesmerizing phenomenon where it seems as if the sharks are drawing trails within the crowd of fish.
In order to simulate this phenomenon, I created an array of objects that would act as the role of the shark. The objects would be represented by a red point, and move 'randomly' across the canvas.
I also wanted the user to be able to spawn multiple sharks at any location in the canvas using their mouse.
I also created an array of 'fish' objects that would move towards the sharks, but maintain a certain distance once they swam close enough.
Final Sketch
(Click anywhere on the canvas to spawn a shark object)
Final Thoughts and Improvements
This was my first time hearing about Levy Flight and attempting to simulate a predator-prey relationship using code. Mimicking the attraction-repulsion effect was quite difficult, and I had to refer to Professor Shiffman's tutorial multiple times. The Levy Flight itself was actually not too hard; however, I did not utilize the step-size technique, and simply randomized the pixel movement in the switch statement to achieve the same effect.
In terms of future improvements, I would like to create smoother movement for the shark objects. As of now, the point moves a bit too erratically for it to be convincing enough as a fish in water. I would also like to be able to control the shark objects using arrow keys, which would add more interaction between the user and the sketch.