Michael Darby wanted to create an “artificial life” project. So, he took a Raspberry Pi 3 and a Unicorn HAT and created a Python script to do it. He had the following goals:
- Create a number of artificial lifeforms that can move around a board and have colour/movement properties assigned to them via 3 random numbers; the ‘DNA’ of the life-form – and display them onto an easy-to-observe output.
- Have those artificial lifeforms be able to interact with each other to ‘breed’ and pass along their traits to offspring, as well as ‘kill’ each other to keep the population in check.
- Have random chance for ‘genetic chaos’ whereby instead of passing along a life-form’s properties to its offspring a random number is inserted into the offspring’s ‘DNA’.
- BONUS – plug the code into the Minecraft API and see what random patterns of blocks can be spawned from the artificial life-form’s movements and properties.
The script takes in the following parameters:
- Number of lifeforms to start with.
- The speed of the program.
- The maximum number of lifeforms that can be ‘on screen’ at any one time.
- Maximum lifeform lifespan.
- An “aggression factor” controlling how likely a lifeform will be to attack another.
It’s a wonderful project and you can read more (and download the code) here.
One would imagine with a bit of adaptation, you could use the same script with the Unicorn HAT HD and get even better results.