🎮 What is This Simulation?
This is an evolutionary neural network simulation where creatures controlled by artificial neural networks
learn to survive, find food, and reproduce through natural selection. Each creature has a brain (neural network)
that processes sensory inputs and makes decisions about movement and mating.
Creatures evolve over generations: the most successful ones (highest fitness) are more likely to pass their
genes (neural network weights) to the next generation. Through mutation and crossover, the population gradually
improves at the tasks of finding food, avoiding collisions, and reproducing.
🧠 Neural Network Architecture
Each creature's brain is a feedforward neural network with:
- 14 Input Neurons - Sensory information about the environment
- 8 → 5 Hidden Neurons - Two hidden layers with progressive compression (funnel architecture)
- 3 Output Neurons - Control movement and mating behavior
The network uses TensorFlow.js for computation and processes inputs every frame to determine the creature's
acceleration and mate attraction/repulsion.
📥 Neural Network Inputs (14 total)
1. Vision Direction (-1 to 1): Weighted direction of food in vision cones. -1 = food on left, 0 = center/no food, 1 = food on right.
2. Creature Direction (-1 to 1): Direction to closest creature in vision. -1 = creature on left, 0 = center/no creature, 1 = creature on right.
3. Creature Gender (-1, 0, 1): Gender of detected creature. -1 = male, 1 = female, 0 = no creature detected.
4. Creature Is Mate (0 or 1): Whether the detected creature is the current mate. 1 = is mate, 0 = not mate or no creature.
5. Creature Is Family (0 or 1): Whether the detected creature is a family member. 1 = is family, 0 = not family or no creature.
6. Creature Distance (0 to 1): Normalized distance to detected creature. 0 = close, 1 = far/at vision limit, 0 = no creature.
7. Boundary X (-1 to 1): Normalized X position relative to center. -1 = left edge, 0 = center, 1 = right edge.
8. Boundary Y (-1 to 1): Normalized Y position relative to center. -1 = top edge, 0 = center, 1 = bottom edge.
9. Vel X: Normalized X velocity component (current movement direction).
10. Vel Y: Normalized Y velocity component (current movement direction).
11. Energy (0 to 1): Current energy level normalized by max energy. Creatures die when energy reaches 0.
12. Mate Cand Energy (0 to 1): Energy level of the best potential mate candidate.
13. Mate Cand Fitness: Fitness score of the best potential mate candidate.
14. Mate Cand Food: Number of food items eaten by the best potential mate candidate.
📤 Neural Network Outputs (3 total)
🎯 Simulation Mechanics
- Food: Creatures gain energy by eating food. Energy is required to survive.
- Energy Decay: Creatures lose energy over time. They must find food to survive.
- Collisions: Colliding with walls or other creatures causes energy loss. Mates don't take damage from normal collisions, but do take damage if stuck pushing against each other.
- Family: Family members (siblings, parents/children) take half collision penalty and don't compete with each other.
- Same-Sex Competition: Creatures of the same gender compete for resources, with stronger creatures dominating weaker ones.
- Mating: Creatures can form pairs. Mated pairs receive bonuses and are more likely to pass genes to the next generation.
- Evolution: When creatures die, they are replaced by offspring of the most successful creatures. 80% are evolved from parents (crossover + mutation), 20% are mutated versions from the top 2 family groups.
- Fitness: Primarily based on time alive (frames lived) - this is the most important factor. Also includes smaller bonuses for food eaten, energy level, and exploration. Survival is prioritized above all else.
- Family Limits: Only 50% of the population can be directly related. If exceeded, excess family members are replaced with the best creatures from other family groups to maintain genetic diversity.
🎮 UI Controls & Options
Top Controls:
- Pause: Pause/resume the simulation
- Reset: Restart the simulation with a new random population
- Show Vision: Toggle visibility of creature vision cones
- Speed Slider: Control simulation speed (0.1x to 2.0x)
Statistics Panel:
- Population Slider: Adjust number of creatures (1-30)
- Generation: Current generation number
- Alive: Number of living creatures
- Best/Avg Fitness: Performance metrics
- Oldest Living: Age of the oldest living creature (with Select button to monitor it)
- Evolved vs Random: Count and ratio of evolved creatures (from parents) vs random creatures (mutated from top families)
- Living Family Groups: Number of unique family lineages/clans in the current population
- Active Creature: Select a creature to monitor its neural network diagram
Settings Panel:
- Food Quantity: Maximum number of food items in the simulation (1-30, default 5)
- Food Respawn Time: Frames between food respawns (0 = instant)
- Energy Decay Rate: Energy lost per frame
- Collision Energy Penalty: Base penalty for collisions (0-200%, default 100%)
- Creature Skin: Visual style (Classic, Alien, Pet Rock, Bug)
Evolution Settings:
- Mutation Rate: Probability of gene mutation (0-50%)
- Auto-reduce Mutation Rate: Automatically reduces mutation rate by 1% every 2 generations (minimum 5%) to allow convergence as creatures improve
- Generation Time: Frames before next generation (500-5000)
- Gene Transfer Ratio: Percentage of genes inherited from the fitter parent (50-95%, default 70%)
Creature Settings:
- Max Speed: Maximum movement speed (1-10)
- Vision Distance: How far creatures can see food (100-1000)
- Energy Per Food: Energy gained from eating (50-500)
- Exploration Noise: Random movement component (0-50%)
Mating System:
- Mating Enabled: Toggle mating system on/off
- Mating Distance: Maximum distance for mating (50-200)
- Buff Type: Bonus type for mated pairs (Energy Regen, Speed Boost, Fitness Bonus, Vision Range)
- Buff Strength: Bonus magnitude (5-50%)
- Mate Evaluation Frequency: Frames between mate candidate evaluations (5-30)
🖱️ Interactions
- Click on a creature: Select it to view its neural network diagram and statistics
- Neural Network Diagram: Shows the selected creature's inputs, hidden layer activations, and outputs in real-time
💡 Tips
- Watch the neural network diagram to see how creatures process information
- Fitness is primarily based on survival time - creatures that live longer are more successful
- 80% of new creatures come from evolved parents, 20% are mutated from top families - this balances exploration and exploitation
- Family limits prevent inbreeding - only 50% can be directly related, maintaining genetic diversity
- Auto-reducing mutation rate helps convergence as creatures improve (reduces by 1% every 2 generations)
- Mated pairs are more likely to pass genes, promoting successful strategies
- Family members cooperate (reduced penalties), encouraging group survival
- Creatures learn to balance survival, food gathering, energy conservation, and mating
- Adjust generation time to see evolution happen faster or slower
- Monitor the "Evolved vs Random" stat to see the population composition
- Use the "Oldest Living" Select button to monitor the longest-surviving creature