A Unity simulation that evolves artificial "creatures" to walk, then uses that setup to ask a question from evolutionary biology: how much competition is the right amount?
Each creature is a little soft-body made of weighted, frictional nodes joined by muscles that contract and relax on an oscillating cycle. Nothing tells a creature how to walk. A population of 800 is dropped on a flat surface, and the ones that travel farthest get to reproduce, with small random mutations to their bodies and muscle timings. Repeat for 50 generations and walking emerges.
This started as a computational biology project. The full write-up is in ComputationalBiology.pdf.
Investigating Performance Under Varying Selective Pressures in Artificial Organisms Benjamin Lamperti, Ryan Kinder, Steven Gao (March 2025)
- Organisms (
OrganismGenerator.cs,Organism.cs): a central node plus a few others positioned relative to it. Every node pair is connected by a muscle. Nodes have mass and friction. Muscles have a full length, a contracted length, and a cycle length and offset, and they behave like simple harmonic oscillators. A small chance of adding or removing a node is built in. - Generations (
GenerationsManager.cs): each generation runs for a fixed time. Fitness is how far the average position of an organism's nodes has moved. Organisms are ranked, the bottom ones are removed, and the survivors are copied with mutation until the population is back to full size. - Selective pressure is the one variable we changed: the share of the population that survives each generation (100% as a control, then 75%, 50%, 25% and 10%).
- Data (
UIDataManager.cs,FloatArraySaver.cs): per-generation distances are plotted live on a scatter chart (XCharts) and saved as text files for analysis.
- With no selection (100% survive), there was no improvement over generations, as expected.
- Stronger selection made organisms improve faster early on, but they did not reach the best final performance. The 10% group was highly variable in later generations.
- The mildest pressure we tested that still did selection (75% survive) kept improving, while the 25% and 50% groups levelled off or declined. Our hypothesis that 50% would be optimal was not supported.
- A one-way ANOVA across groups was significant (p ≈ 1.1 × 10⁻³⁹).
This fits earlier work: some competition is needed for evolution to work, but the pressure has to be strong enough to be worth the loss of population and variation. See the paper for figures, regressions and discussion.
Requirements: Unity 6000.0.25f1 (Unity 6), with the Universal Render Pipeline. Packages are listed in BioEvolutionSimulator/Packages/manifest.json.
- Open the
BioEvolutionSimulatorfolder as a project in Unity Hub. - Open
Assets/Scenes/TestingScene.unityand press Play. - Set the survival rate with Manual Percent Survive on the
GenerationsManagerobject, or tick Auto Mode to run the experiment groups back to back (each forAuto Gen Capgenerations, 50 by default). Auto mode saves*PercentData.txtfiles intoAssets/.
| Key | Action |
|---|---|
] / [ |
Double / halve simulation speed |
= / - |
Zoom camera in / out |
R |
Restart the scene |
BioEvolutionSimulator/
Assets/
Scenes/TestingScene.unity main scene
Scripts/ simulation, UI and data-saving code
Prefabs/ Organism, Node, Muscle
SavedImage/ScatterChart.png example output
ComputationalBiology.pdf the paper
The project draws on the idea of evolutionary design, using selection, mutation and variation to improve designs against a fitness measure (Bentley), and on the biology of how competition shapes adaptation (Osmond, Melotto et al., Ueda et al.).
- Bentley, Peter. "An Introduction to Evolutionary Design by Computers." University of California Berkeley, 1999. https://people.eecs.berkeley.edu/~sequin/CS285/TEXT/EvolDesign.pdf
- Hull, Sara Chandros. "Evolution." National Human Genome Research Institute, 2025. https://www.genome.gov/genetics-glossary/Evolution
- Masci, David. "Darwin and His Theory of Evolution." Pew Research Center, 2009. https://www.pewresearch.org/religion/2009/02/04/darwin-and-his-theory-of-evolution/
- Melotto, Andrea, et al. "Rapid adaptation to invasive predators overwhelms natural gradients of intraspecific variation." Nature Communications 11, 3608 (2020). doi:10.1038/s41467-020-17406-y
- Osmond, Matthew. "How competition affects evolutionary rescue." 2013. https://pmc.ncbi.nlm.nih.gov/articles/PMC3538452/
- Rahmoud, Kamel Hussein, and Ahmed Donkol. "Genetic Optimization for Self-Driving Vehicles Using Automated Behavior Cloning based on Convolutional Neural Network." Journal of Advanced Engineering Trends 43 (2024).
- Ueda, Masahiko, et al. "Stronger selection can slow down evolution driven by recombination on a smooth fitness landscape." PLoS ONE 12(8): e0183120 (2017). doi:10.1371/journal.pone.0183120
- Van Laer, Inez. "Tesla's Self Driving Algorithm Explained." Towards AI, 2022. https://towardsai.net/p/l/teslas-self-driving-algorithm-explained
Benjamin Lamperti, Ryan Kinder and Steven Gao.