This started as a random thought many years ago where I considered if it were possible to create digital creatures that evolved. It started out as a simple project but quickly became very complicated, although that is what I would have expected. My first attempt was based on a grid world and the creatures evolved to find food and compete. The system worked although it was ugly and unidirectional. The higher level creatures evolved to be large formless masses that simply drifted in one direction.
My second attempt involved Microsoft’s XNA studio which looked much better than the first attempt. In that version I needed to work out the collision detection, rotational math, physics, etc. As such it was not an optimal solution and was very processor intensive. I also had built it before fully deciding on the DNA structure and behaviors.
This, the third attempt, is built on the Unity2D platform (with a few 3D elements). I decided to spend a lot of time working out the structure, DNA, behaviors, mutations, and environment rules before moving to the next step. I am pleased with how it turned out this time and have tried to incorporate one rule, let the creatures evolve naturally. I cut a corner or two to make it a bit more interesting, like how they favor symmetry or are more likely to react to food. I did not tell them how to react, they can run from food if they so choose, just that they are more likely to react to a food signal. I hope you enjoy it!
July 22, 2017
Evolution is a fairly complex application that translates a small (1.24K) file into a functional creature. This series of bytes defines the structure and all the behaviors the creatures display as well as a balanced set of traits that each cell has. Each time a creature reproduces a small portion of the dna mutates, the most successful versions start to dominate.
The creatures are constructed from a series of 1024 bytes that are randomly generated. The DNA defines eight cell types, how they connect, their structure, how much of the world they detect, how and why they signal, and how they react to the signals i.e. the world. The sections of DNA were purposely grouped in blocks of 8 bytes and sections of 8 blocks. This allows for mutations that duplicate sections or move one byte to the same spot in another section. There are also sections that are never used and other sections that are dormant or do not express any structure/behavior. The block structure allows creatures to duplicate traits in recumbent sections and store successful traits for future generations. I would guess that a really old species would have far more useful recumbent DNA than a new one that looks and behaves exactly the same.
The structure was one of the hardest bits to nail down in the development of this game. After many iterations I settled on a system that uses a matrix to build branches. Additionally each branch can attach to the parent cell in one of two ways. It can extend like an arm or each part of the branch can grow directly off the parent cell. Each bit of the branch can also repeat and it can do so at the same size or a percentage of its parent.
The symmetry of a cell has many variations. There can be no symmetry where the child cells simply grow at a particular angle. There can be evenly spaced symmetry where there is an even angle between each child. There can be mirrored symmetry along either axis, think in terms of a clock where 1 O’clock is duplicated at 11 o’clock or 2 is mapped to 10, 8, and 4.
Also each cell can be a left or right cell which makes a big difference in relation to symmetry. Think of a turtle’s legs and his feet. They all face forward, it would be an evolutionary misstep if his feet all pointed counter clockwise. These creatures can evolve with a variety of L/R combinations. They can have appendages that are all left or all right, they can alternate LRLRLRLR, have LLRRLLRR, or LLLLRRRR.
The joints that connect the cell can have a default length and angle. They can also have a range of motion that defines how rigid or fluid they are. The length is extendable based on behaviors. The cells themselves have traits like storage, attack, defense, size, and speed where increases in one will decrease another. The color of the cells and their nucleus provide clues to their traits.
The creature’s sensor is a large circle around the main cell, the size is determined by their DNA and is balanced against other traits. They can see the objects around them and differentiate between rocks, other cells, their own cells, food cells, attack cells, other sensors, and cells of their own species. Each one of these is mapped to a set of signals that they all share. They can also, based on behaviors, alter the signals which modifies their behavior. They also set signals based on their health and energy levels.
As mentioned before the creatures have a set of signals that they can react to and modify. A behavior is simply:
if signal A is (greater than, less than, or equal to) X (and/or) if signal B is (greater than, less than, or equal to) Y the do something.
The somethings they can do are, move relative the source of the signal, move relative to my parent cell, move relative to myself, move randomly, extend or contract my joint, and finally change a signal. Each cell has many behaviors and most go unused. This system allows the cells to react to food differently if they are hungry or run from a creature if there is less than X food. It also allows them to communicate with each other through signals and oscillate or delay reactions.
Some of the signals that are not mapped to the sensor, health, or energy diminish over time. This allows them to do X for Y seconds then stop. It is important to note that one of the sensors is to detect if the other creature is the same species. They can evolve to not attack their own kind or move relative to each other which means they can flock, just hang out together, or keep their distance. When two creatures touch they can run or attack, however some creatures do neither to their own species – all of these things are mutations and can change from one generation to the next.
There are two types of food, plants and meat. Plants grow in the environment randomly and are slow to eat. The amount they can store and the speed they can eat is a trait that varies from cell to cell, in a given creature they may have some cells that eat faster than others. They can share energy between cells which takes time. Meat is produced when a creature dies and it has energy within its cell. They also lose some if they are critically attacked. Meat is faster to eat and can be stored separate to the plant energy. It will replenish energy and also replenish health. This allows carnivores to take damage and, if successful, repair themselves. Fat storage also gets shared between cells and the amount they can store also varies between cells.
The amount of energy a cell needs to reproduce is another evolved trait. The creature has a separate storage facility similar to an egg and they cannot reproduce until it is full. Some creatures can reproduce quickly but their offspring will have little energy, others may need lots of energy but can reproduce infrequently. When a creature is ready to reproduce the only thing left is for a slot to be available (it is a limited world). Lastly, if you are controlling a creature he or she is much more likely to reproduce. This makes it easy for you to decide who should evolve.
While they are growing their DNA defines how their structure will get expressed. Sometimes it does not work out well and any cells that overlap will pop. If that includes cell zero, the creature dies – so sad. This is a harsh world and only viable creatures can inhabit it. New creatures will be various and random, new creatures are generation 1 and usually don't do much. Creatures also cross over from a shared pool of creatures online so you will have to compete with any number of invasive species.
A creature belongs to a species and shares a lot of traits with other creatures of its species. If a child's DNA differs too much from its parent then it creates a new species. This only matters with regard to how it reacts to creatures of the same species and if they damage each other when they touch. For the most part creatures of the same species look alike however they do not have to. A very small deviation in DNA can have a very dramatic effect on the structure. The eyes are clues to the species they belong to. The size of the eye has some relation to the sensor however the position and number of eyes is built from the unique species number. Its not 100% accurate if they look the same however if the eyes are different, they are different species no matter how similar they are. They also look in the direction they think they are moving in.
HOW TO PLAY
Ok, here’s the tricky part – how to keep it fun but also keep it true to the evolution model. The creatures evolve on their own so you are not required to do anything. That said you can control the creatures and help them find food, kill enemies, and reproduce. You can then take the offspring and selectively breed creatures to your liking. Early on you will find creatures that have no interest in food or too much interest in rocks but a few generations later you can find great-great……great-grandchildren who love food and hate rocks.
Controlling a creature can be a bit like trying to get your cat in a bath tub or it can be like trying to get your dog to eat ice-cream. If you find (or breed) the right creature you simply need to move it close enough to food for it to sense it. Other times you need to force feed them until their offspring acquire a taste for it. Larger creatures are more complex and take much longer to evolve behaviors. They also require more food and reproduce slower. It may be easier to first find a small creature you like with useful behaviors and then selectively breed the children who have more cells. Also you can smite the creatures you don’t like although they can exist in many places and may not be truly extinct
Primordial Soup Demo
This is a scaled down version of Evolution - Primordial Soup. This is actually just a cross section of creatures created in all running instances of Evolution (alpha world). It should change if you refresh the demo but no evolving is going on here. Eventually one of these creatures will dominate this demo and you would probably want to refresh. The full version of Primordial Soup has the ability to control and help the creatures you want to evolve (otherwise they just evolve on their own, cheeky buggers). It also uploads and downloads creatures to the pool you are currently looking at which effectively links all instances into one continuously evolving world. You can view their stats & smite those that displease you. These guys can evolve their structure, attack, defense, sensors, food storage, and a very complex set of behaviors in response to their environment. There are a nearly infinite number of possible creatures and, to be honest, I am not sure how interesting this is going to get.