October 19th 2022
My first attempt at continuous genetic simulation was a basic project to test my understanding of the genetic algorithm through the implementation of a dynamic simulation that would allow me to test my ideas about evolution. Back in 2018, I was able to observe cyclical patterns in the population that in part matched my beliefs. When I was working on the project initially, I was quite happy that the algorithm was working and complex behavior was beginning to emerge. Understanding that all those quickly moving dots on the screen represented organisms in an entirely simulated world was enough for me. However looking back, with a better understanding of maths and science, I felt that the presentation and accuracy of the simulation were lacking in certain places and could do with a much-needed touch-up.
The first thing I changed was to introduce a more explicit main loop by updating all of the agents with respect to the change in the time between each frame to allow for more precise and accurate simulation, and support for different simulation speeds separate from the framerate. Using concepts of game design I was able to redefine the cells’ update step to account for the change in time as opposed to being of a fixed duration.
Another element that I wanted to change was the random movement of the cells. Instead of moving within a range, cells will now move in a direction based on their unique orientation. Now, each cell faces a particular direction and moves based on its speed and angular speed, both of which are determined by its genes. The angular speed genes affect the speed at which the cell can change direction, and the speed refers to the maximum magnitude with which the cell can move in the cell's direction. To enact this change, I applied some concepts of trigonometry and vectors. And, voíla! The cells are moving in a much more smooth and more controlled manner than before.
Lastly, to make it easier to distinguish between different species and their relations to each other, I changed the way the cells are displayed to have their RGB color values correspond to their genes. I also added real-time graphs using Chart.js to show the population and the distribution of genes present in the simulation to make it easier to spot trends over time and collect data.
Overall I enjoyed updating this older exploration of mine and retracing my thoughts while working on it. I still need to do a bit of tuning with the parameters to achieve more convincing results, but the presentation is far closer to what I had envisioned. There is already some exciting emergent behavior that serves to motivate me to continue developing more advanced simulations.
In future versions, I would want to incorporate concepts from Machine Learning and use the NeuroEvolution of Augmenting Topologies (NEAT) algorithm to add a neural network gene in conjunction with the current genes to allow for potential speciation of “predator” and “prey” classes of roles. In later versions, I may implement vegetation to simulate the energy capacities of the system and further speciation.
Stay tuned!
If you'd like to have a play with it yourself, you can find it here: https://aagrawal05.github.io/Genetic-Evolution-Project/