Skip to main content

2.2. Example: Biology (Weingarten)

2.2.1 Alex: Vibe Coding withsimulations AIin the Programmingbiology HTMLor Simulationsscience classroom

Example: Predator–Prey Dynamics (Lotka–Volterra model)

Subject: Biology  ·  Grade: 9 (age 14–15)  ·  Duration: 1 double lesson (90 min)

Learning objectives

By the end of the lesson, students can:

  • describe the key variables (prey population, predator population) and parameters (growth rate, predation rate, conversion efficiency, mortality rate) of the Lotka–Volterra model;
  • form and test hypotheses about population dynamics using an interactive simulation;
  • extend an existing simulation with a new factor (e.g. hunting) by writing a structured prompt for an AI language model;
  • critically evaluate the model’s assumptions and limitations (Nature of Science), including why introducing randomness or an additional factor can destabilise it.

Take-home message: Students don’t need to code from scratch. Reading and testing an existing simulation, extending it through a well-structured AI prompt, and then deliberately trying to break it, is enough to build genuine understanding of a dynamic biological model — and, just as importantly, of what any model can and cannot show.

Content

Predator and prey populations typically show cyclical, phase-shifted fluctuations (classic example: lynx and snowshoe hare). The Lotka–Volterra model (Lotka, 1925; Volterra, 1926) describes this with two variables — prey population and predator population — and four parameters: prey growth rate, predation rate, conversion efficiency, and predator mortality rate. The oscillation results from a feedback loop: more prey → more food for predators → predator population grows → more predation → prey declines → less food for predators → predator population declines → prey recovers, and the cycle repeats.

This tidy cycle only emerges because the model is deterministic: given the same starting values, it always produces exactly the same curve. Real populations are not like this — births, deaths and encounters are subject to chance, and a stochastic (randomised) version of the same model tends to drift away from the clean cycle and can even collapse (e.g. the predator population dying out) in cases where the deterministic version predicts stable oscillation. The model is also a closed system: it excludes every abiotic factor (temperature, precipitation, season) and every other biotic factor (food plants for the prey, a third species, disease), and makes each population’s growth depend on nothing except the size of the other population. Adding just one such factor — a temperature-dependent growth rate, or a limit on the prey’s own food supply — is often enough to break the clean two-variable cycle. This is not a flaw to hide from students: it is the central Nature-of-Science lesson of the activity. A model can be genuinely useful (it explains why lynx and hare numbers rise and fall in step) while still being a deliberately narrow approximation of reality — and using it well means knowing exactly which factors it leaves out.

Lesson plan (very short)
Phase Time Activity
Warm-up 8 min Show an unlabelled graph of a real predator–prey data series (e.g. lynx/hare); students describe the pattern and form first hypotheses.
Input 12 min Teacher introduces the model’s variables and parameters using a simple diagram — no differential equations needed.
Explore 15 min In pairs, students test hypotheses on a ready-made HTML simulation and record their observations.
Extend with AI 20 min Pairs write a prompt asking an LLM to add one new factor to the simulation (e.g. a “hunting” button), test the result, and interpret the change.
Stress-test the model 15 min Pairs use a second AI prompt to either (a) make one parameter random instead of constant, or (b) add a factor from outside the model (e.g. temperature-dependent growth, limited plant food for the prey), and observe how the simulation destabilises or breaks.
Reflect: what the model can and cannot show 20 min Whole-class discussion, guided by questions such as: Why did the randomised or extended version behave differently? What does the model deliberately leave out, and why? What makes this a useful simplification rather than simply a wrong one?
Materials
  • Ready-made HTML/JavaScript predator–prey simulation (single file, sliders for the four parameters)
  • Two short prompting templates: one for extending the simulation (e.g. adding hunting), one for stress-testing it (adding randomness or an external factor)
  • Worksheet with guiding questions for the exploration phase
  • Guiding questions for the Nature-of-Science reflection (model function vs. model limits)

Take-home message: Students don’t need to code from scratch. Reading and testing an existing simulation, extending it through a well-structured AI prompt, and then deliberately trying to break it, is enough to build genuine understanding of a dynamic biological model — and, just as importantly, of what any model can and cannot show.