Evolution Sandbox
Seanan Riley
This project is a small in browser sandbox for observing evolutionary dynamics under simple ecological rules. It models evolution by natural selection, unequal survival and reproduction, and inheritance using a population of agents whose behavior is driven by evolving neural networks and possess ‘genetically’ encoded traits such as maximum age and stored energy before reproduction. The goal is to show how simulated evolution occurs and adapts when resources change or when the player alters the environment using the provided tools, which can create hazards and alter resource distributions.
Agents all use the same neural network structure consisting of a set of inputs, two hidden layers, and thrust outputs to control their actions. Inputs include energy, health, age, nearest food and peer positions, wall distance, velocity, a bias value, and hazard distance. Keeping the input set small reduces the search space and makes selective pressures easier to interpret.
Movement consumes energy, food restores it, and the aging gene limits lifespan. Reproduction requires excess energy, a minimum age, and an amount of stored food based on a separate gene. These constraints are enough to generate unequal survival and reproduction. Unlike a normal Neural Network evolving algorithm, agents reproduce and die continuously to reflect living organisms. High energy agents create mutated offspring, while low-energy or older agents die off, allowing ongoing adaptation. To prevent extinction and allow for the initial population to adapt there is an automatic rollback to a small set of recent agents when the population hits zero, in practice extinction does not occur besides the unadapted early generations or in response to user created environmental change.
The player can manipulate the environment by placing food, applying damage, and drawing food or hazard lines. Visualization tools include a live neural-network viewer with weight and activation displays, a genealogy graph showing up to the most recent common ancestor, and a genetic drift chart (which is not based on allele frequency but by normalized gene value, since genes are encoded as floats rather than alleles). These tools allow the user to see how selection pressures shape behavior.
Variation arises through mutations in network weights. Differential survival and reproduction follow from energy limits, starvation, hazards, and player actions. Inheritance occurs when offspring receive parent weights with crossover and mutation, allowing successful strategies to spread. Resource availability and hazards create shifting selective pressures, and by fixing physical traits while evolving only neural weights, the model highlights how sensing and decision-making influence behavioral adaptation.
Interesting behaviors to watch for include agents learning to move toward player-placed food or avoid harmful zones, changes in population size and average energy under different resource levels or culling, and whether behaviors settle into stable patterns or oscillate as the player modifies the environment.