Skip to main content

Predator-Prey Public Goods

The model is a spatial predator-prey-grass ecology with an evolving predator cooperation trait:

  • predators pay a private cost for hunt investment,
  • successful hunts generate a shared benefit,
  • offspring inherit the hunt-investment trait with mutation,
  • selection acts through survival, hunting success, and reproduction.

Interactive Replay

The exported browser replay is rendered directly on this page. It is based on sampled frames from a fixed Python run.

GitHub Module

Evolved Cooperation

Predator-Prey Public Goods Replay

Sampled browser replay of the Python model. The page now renders the replay directly instead of embedding a separate frame.

Replay

World State

0 / 0

Step 0

Loading replay bundle.

Cooperation Rate

Mean Hunt-Investment Trait

State Variables

  • predator i: position (xi, yi), energy Ei, hunt-investment trait hi
  • prey j: position (xj, yj), energy Pj
  • grass field: per-cell energy G(x, y)

Interpretation:

  • hi is a continuous inherited trait in [0, 1]
  • higher hi increases a predator's contribution to coordinated hunting
  • higher hi also increases its private per-tick cooperation cost

Tick Structure

Each call to the main world-step function applies the ecology in this order:

  1. Grass regrows, capped at the cell maximum.
  2. Each prey may move, pay metabolic and movement costs, eat one grass bite, and reproduce.
  3. Hunting is resolved from the prey side.
  4. Dead prey and hunted prey are removed, and newborn prey are appended.
  5. Each predator pays metabolic, movement, and cooperation costs, then may reproduce and may die from starvation.
  6. Diagnostics are written into per-step histories.

Important details:

  • movement uses a Moore neighborhood with dx, dy in 1
  • movement cost depends on realized Euclidean distance
  • prey reproduction happens before hunting in the same tick
  • newborn prey and newborn predators act only from the next tick onward
  • predators committed to one successful hunt cannot be reused in a second successful hunt during that tick

Hunt Mechanism

Common symbols:

  • hi: hunt-investment trait of predator i
  • Ei: current energy of predator i
  • Ci = Ei × hi: effective contribution of predator i
  • Wg = sum of all Ci: total coalition contribution
  • Sg = sum of all hi: unweighted sum of predator traits in the hunting group
  • P: current prey energy
  • ng: number of predators in the hunting group

The active default is the threshold_synergy rule.

Formation conditions:

ng ≥ nmin
Wg ≥ P × αform

If both conditions hold, kill probability is:

pkill = pmax × σ(k × (Wg − P × αexec))

Variable meanings:

  • nmin: minimum coalition size required to form a hunt
  • αform: formation effort factor
  • αexec: execution threshold factor
  • k: steepness around the execution threshold
  • pmax: maximum success probability
  • σ(z) = 1 / (1 + e−z)

This rule creates a real coalition barrier rather than a smooth one-predator escalation.

Reward Sharing And Private Cost

If a hunt succeeds, the captured prey energy is split across participating predators. The active default uses contribution-weighted sharing:

rewardi = P × Ci / Wg

Private cooperation cost is always on:

costi = ccoop × hi

So the model combines a persistent individual cost with intermittent group hunting gains.

Reproduction, Mutation, And Selection

Prey reproduce asexually when they exceed the prey birth threshold and pass a reproduction draw.

Predators also reproduce asexually, but their reproduction probability is scaled by crowding and prey availability:

spred,birth = max(0, 1 − Npred / Kpred) × min(1, Nprey / Nprey,0)

Variable meanings:

  • Npred: current predator count
  • Nprey: current prey count
  • Kpred: predator crowding soft cap
  • Nprey,0: initial prey count
  • spred,birth: predator reproduction scale

At predator birth:

  • parent energy is halved,
  • the child inherits the parent's current trait,
  • the child is placed nearby,
  • with some probability the trait receives Gaussian mutation noise,
  • the trait is then clamped back into [0, 1].

This is where natural selection enters the model: higher-trait predators may gain more from coordinated hunts, but they also pay a continuous private cost, so trait frequencies change through ecological success and reproduction rather than within-lifetime learning.

Diagnostics

The Python run collects:

  • predator and prey population histories,
  • mean and variance of the predator hunt-investment trait,
  • trait statistics for successful hunters, reproducing parents, and dead predators,
  • macro energy-flow histories,
  • the final distribution of survivor traits.

The integrated replay exposes a lighter subset of that state: the world grid, agent positions, and the cooperation-rate trajectory.

Source

Source module: