Understanding life-like behaviour is a fascinating pursuit of the sciences that tries to characterise the qualities of physical entities which helps us to distinguish between life and non-life. This pursuit has major implications in various fields of science. For example, when we model life through some known characteristics, it allows us to observe patterns that can guide progress in discovering more characteristics of the biology of life; it also helps us confirm observations/behaviours we see as a natural consequence of the model. Which is not only useful to understand ourselves better, but could also help us better search for life outside our planet.
All the phenomena that are simulated in this project are heavily influenced and inspired by the Nature of Code [Schiffman 24] online book. Therefore, both the progression of concepts in chapters, and ideas of the simulation possess resemblance to Schiffman’s book.
But this project also wishes to depart and go further than the book in a few aspects.
Therefore, in this project we are approaching the question of “What makes life, life?” through the lens of motion phenomena of physical entities and with the eyes of computer simulation. We take interest in motion phenomena because natural phenomena cover a broad area of topics, therefore focusing on a particular section of it lets us dive deeper into more elaborate models. Hence, providing further insight into the various characteristics (or components) of natural phenomena. Motion is also chosen because it integrates with animated simulations (i.e. the visualisation aspect) and Object Oriented Programming easily, which is the core engine of the simulations in this project, especially the p5.js library that we will be using.
We will try to understand what makes motion phenomena natural-looking / life-like by looking at three specific components of such phenomena - physics of motion, randomness, and autonomy. One can think of this as creating an environment with a set of governing rules (the physics), and allowing the entities in it to act (autonomy), but also allow for uncertainty within the environment and the actions of the entities (randomness).
In the 1st chapter, we explore how to animate and model our required physics for motion simulation with the help of vectors and Euler integration to simulate the laws of physics. The chapter also discusses how such models often look at the limitations of the modelling environment (here computers) but also accounts for limitations of the viewer which allows us to reduce the complexity of the model.
In the 2nd and 3rd, we study how randomness is generated in computers and how to simulate entities that move randomly but also with other desired characteristics. For example, we try to achieve ‘smooth’ walkers by both restricting parameters of the distributions and applying the generated random numbers to different quantities. But, also introduce an algorithm (Perlin Noise) specifically intended to achieve this quality. Lastly, the chapters also elaborate on how one can use these simulations in order to better understand the distribution and algorithms which produced them.
Then we define what autonomy is and provide a hierarchical classification of autonomous agents in the 4th chapter. A key coding technique called Inheritance is explored, to showcase the relationship between how both nature and code evolve. We also simulate a wandering autonomous agent and compare it with other randomly moving entities created previously, and make observations trying to distinguish one from another - autonomous and not.
Finally, in 5th chapter we devise a model for multi-agent systems based on the particle system introduced in 2nd chapter and the implementations given by [Reynolds 99], [Schiffman 24]. Using the model and all the components of natural motion that have been explored until now, we create a flock of entities each acting based on their individual perception and we observe the emergent behaviours of the entire system.
Sketch
Canvas
createCanvas(width, height) in the setup() method.Look at Appendix to learn how to run the code written in this project.
Part of all p5 sketches:
setup(): is used to define the initial environment properties such as screen size and background colorsetup() function once in the beginning (automatically). And looks for the defintion of our p5Canvas element and the other properties as mentioned above.draw() : is called repeatedly in a infinte loop. It is used to animate the objects on the canvas (explained in the next chapter)Therefore every p5-sketch at its core, has these two functions. With one or two more global functions - usually for handling HTML events like, mousePressed, deviceMoved, etc.
We also have built-in ariables/constants with attached values/meaning - variables like width, height, frameRate, frameCount, etc., all containing their obvious meaining. The dimensional variables refer to the Canvas.
For convenience we also have some mathematical constants such as PI, and its multiples like QUARTER-PI and TWO-PI (also called TAU)
usual animation object attributes:
fill: defines the colour in which shapes are filledstroke: defines the colour of the border of shapes after its' callstrokeWeight: defines the border thicknesspush: will save the current transformations (changes in point of references, rotation of the plane to color, size, etc.). Used in complement withpop: whichsetup()draw()display() function and the we would also update() the required variables to be drawn in the next framewindowWidth and windowHeight - to fit to the dimensions of the entire browser screen.