Games · AI · Evolution simulation game / personal project

Gene Hive

An insect colony simulation on a hex map that you watch rather than command. Workers forage, care for brood, expand an underground nest and defend it from spiders, and each insect's body and decision policy is inherited from an evolving genome.

26 genes per insect
Godot 4.7 C# Genetic algorithms Neural networks
Role
Solo developer
Platform
Windows · Godot
Status
Playable foundation, in development
Workflow
AI-assisted, agent-driven

Gene Hive brings together a colony simulation, an artificial-life experiment and a set of tools for understanding autonomous behaviour. Each insect has needs, a body, an inherited policy and a small adaptive neural network. The colony’s story comes from those individuals sharing a world of limited resources, changing weather and predators.

You observe through a strategy-game camera, moving between the surface and the nest below: follow a worker, inspect its decisions, speed up time and watch the population change. The aim is to make the link between a creature’s traits, its choices and the colony’s survival visible.

  • 17 behaviour genes
  • 9 morphology genes
  • 103 neural parameters
  • 60 Hz fixed simulation steps

A colony of individual decisions

What happens when the same inheritance shapes both the creature that carries the food and the decisions that send it out to find it?

A worker may be quick but expensive to sustain, well protected but heavy, or especially responsive to a hungry larva nearby. Its own needs compete with foraging, care, exploration and rest, and those choices decide how much reaches the stores, how quickly brood develops and whether the nest has room to grow.

The interesting scale is the space between one insect and the whole colony: a small difference in response can change who does the work, while a shortage or a predator can change which traits are useful.

Genes you can see

  • Behaviour · 17 genes Priorities, persistence, risk tolerance, cooperation, kin preference, recruitment, learning rate and willingness to answer colony demand.
  • Morphology · 9 genes Eyes, legs, storage tissue, mouthparts, antennae, hydration and immune tissue, carapace and defensive spines.
  • A finite tissue budget No insect gets every organ at full size for free: oversized allocations are scaled back, and body mass and metabolism make every body a trade-off.
  • A painted part rig Bodies are assembled from artist-editable pieces, so expressed traits are visible, with age and injury changing the look further.

Eyes and antennae affect what a worker can sense, legs how it moves, storage what it carries, mouthparts how it handles food, and armour and spines how it fights. The inspector shows inherited and expressed traits side by side, so a large genetic allocation and the body that actually develops can be told apart.

A small brain in a defined world

The neural network has 11 inputs, four hidden neurons and 11 outputs. It reads signals such as hunger, thirst, fatigue, threat, resource scarcity and nearby distress, and adds a bounded adjustment to authored utility scores.

  • It shapes intent The network nudges which goal wins. Feasibility checks, pathfinding, resource accounting, job claims and action execution stay deterministic rules.
  • Safety stays authored A separate safety system steps in when an urgent need or a threat calls for recovery or escape.
  • Learning is not inheritance The output layer learns during an insect’s life, but offspring inherit the stored genotype, not the parent’s learned weights. Evolution across generations and adaptation within one life stay separate.

The diagnostics keep that boundary visible: they separate policy decisions from safety, defence, hauling and other authored interventions, and report how often the neural adjustment actually changed the chosen goal.

Life above ground

The surface is both the source of resources and the source of pressure.

  • Nectar, water and resin Collected, carried and stored explicitly. Carrying costs something, and resources have to physically reach the colony.
  • Pheromone trails Local cues for home, food and water that evaporate over time, so no insect ever knows the whole map.
  • Weather, seasons and daylight They change the environment and its demands. Pond water is finite, recharged by rain and lost to evaporation.
  • Plants and soil Regrowth, biomass, decay and fertility are linked. Dead insects keep their identity, body mass and cargo until recovered or decomposed.
  • Fungus and injury Costs beyond hunger and thirst. Rest and mutual care help, but contact can also spread infection.
  • Spider predators They stalk, attack, recover and retreat. A defeated spider becomes food, but hauling and processing it takes work.

Four pressure presets run the colony under different conditions:

  • Calm Observation
  • Seasonal Challenge
  • Predator Focus
  • Disease Focus

A nest with physical limits

Below the surface, the colony lives on its own hex layer, connected through entrances. The Nest view shows nurseries, food and water stores, material storage, resting space and the other chambers, and these spaces matter: brood needs nursery capacity and care, stored resources need room, and digging competes with every other job.

How storage and chambers work

Resin is required for specialised storage chambers and can reduce the cost of an ordinary brood cell. Stores fill up instead of accepting deliveries without limit: when every suitable store is full, a carrier keeps its cargo and tries again once space frees up. Spider carcasses brought into the larder are processed into food over time.

The nest uses painted chamber tiles whose contents show their purpose. Hovering reveals capacity, stock, sleepers or developing brood, and switching layers keeps attention on the part of the colony being observed.

Inheritance and the next generation

Reproduction draws on healthy, eligible adults and the colony’s resources. Contribution credit influences who becomes a parent, and brood has to be funded and raised, so every birth is part of the colony economy. Crossover and mutation create new combinations of behaviour, body and brain, and occasional immigrants add variation when population or genetic diversity runs low.

Social behaviour combines inherited tendencies with authored mechanisms: food sharing, kin-biased helping, grooming and alarm recruitment give individual differences a way to matter. Whether a worker responds to care requests depends on what it perceives nearby and on its inherited threshold, and increasingly urgent requests recruit less responsive workers too.

A changing gene distribution is not, by itself, proof of adaptation.

That is why the project measures whether traits are expressed, whether they affect work and survival, and whether the insects carrying them actually contribute to later generations.

Built to be observed

The interface is part of the experiment: it should explain what happened.

  • Specimen inspection A worker’s body, needs, current goal, genome and neural activity in one place.
  • Evolution statistics Population, generations, genetic variety, trait distributions, ancestry and likely breeding candidates.
  • Decision diagnostics Where decisions came from, how much the network influenced them and how time was spent across goals.
  • Environment statistics Climate effects, pond conditions, fungal load and the cost of predation.
  • Resource statistics Incoming supplies separated from upkeep, brood and construction, next to physical storage capacity.
  • Overlays and history Map overlays and an event log for exploration, traffic, resources, danger and change over time.

Pause, speed controls, seed changes, scenario resets and save/load support watching at different timescales, and interface scaling and reduced motion keep a dense simulation readable.

Architecture and reproducibility

The simulation advances in fixed 60 Hz steps with seeded random streams and explicit state; fast-forward changes how many steps run, not their size. The authoritative colony model is plain C# and runs without a scene tree. Godot handles presentation, input and the camera, and the views only read simulation state: opening a statistics panel or switching an overlay must never change the colony’s outcome.

Saves, rendering and performance

Saves keep everything needed to continue a run, including agents, learned state, resources, brood, routes and random streams. Compatibility is versioned explicitly, because exact continuation depends on compatible simulation rules.

Rendering separates terrain that only changes when the world changes from dynamic presentation. Hex terrain is batched with MultiMesh, routes use cached A* searches, and ecology updates concentrate on active or changed areas. Performance tools measure simulation timing, allocations and pathfinding separately from what the player sees.

Testing evolution against the real simulation

An offline genetic algorithm searches for policies with selection, crossover and mutation; optional NSGA-II selection compares several objectives instead of reducing every trade-off to one ranking. Broad searches can use a cheaper proxy, but promising policies also face the real headless colony runtime, because doing well in a simplified evaluator is no evidence of doing well in the game.

Seeded comparisons, separate validation banks and frozen-versus-learning runs separate inherited performance from lifetime adaptation, and test-only tools hunt for policies that collect reproductive credit without doing the useful work.

Does a policy help the colony under the rules it will actually meet, and does that still hold when the scenario changes?

AI-assisted development

Gene Hive is also an experiment in human-directed, AI-assisted development. Coding agents help with implementation, investigation, testing and documentation; the running simulation itself is explicit C# rules, genetic operators and a compact neural network.

How the agent workflow is set up
  • Design documents before risky or substantial changes
  • Isolated branches or worktrees, with explicit ownership when agents work in parallel
  • A task ledger that records open work, decisions and evidence
  • Automated gates selected by the changed files, and a broader verification path for release work
  • Tests of observable effects, not checks that a setting was stored
  • Gameplay and visual inspection alongside headless verification

Documentation is checked against the current implementation. A plausible explanation, a passing test and a measured improvement are different things, and the workflow keeps them apart.

Where it is going

Gene Hive is a playable foundation in active development. The next questions are about behaviour and selection:

  • Cooperation When does helping others repay its cost?
  • The brain How much useful control does the network actually exert?
  • Pressure Do weather, disease and predators produce meaningful differences across generations?

The current tools make these questions inspectable: trait distributions reveal differences a colony average hides, decision traces show when the policy had a real choice, and resource and predation statistics show what that choice cost. The direction is a colony whose changes can be followed from the body of one worker to the history of the nest, backed by evidence whenever the simulation seems to have learned something.

Technical snapshot
  • Runtime: Godot 4.7, C# and .NET 8; playable Windows build
  • World: hex surface and underground nest, local resource collection, pheromones, environmental pressure and predators
  • Inheritance: 17 behaviour genes, 9 morphology genes and 103 neural parameters
  • Brain: 11 inputs, 4 hidden neurons, 11 outputs; bounded influence on utility scoring, output-layer learning during life
  • Simulation: fixed 60 Hz steps, seeded random streams, a headless C# model and versioned saves
  • Evolution tooling: offline genetic search, optional NSGA-II, proxy and exact evaluation, seeded comparisons and exploit probes
  • Presentation: painted modular insects, batched terrain, environment effects and read-only inspection tools
  • Development: human-directed, AI-assisted, with explicit ownership, automated gates and effect-level verification