Skip to main content

2.2. Example: Biology

2.2.1 Vibe Coding simulations in the biology classroom

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 aadditional newlayers factorof ecological complexity (e.g. hunting)a carrying capacity, a second species, a seasonal factor) by writing a structured promptprompts 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’don't need to code from scratch. Reading and testing an existing simulation, extendingthen itusing throughan LLM to add one layer of ecological realism at a well-structured AI prompt, and then deliberately trying to break it,time, is enough to build genuine understanding of a dynamic biological model — and, justsooner asor importantly,later, ofto whatdiscover anyfor themselves exactly where that model canreaches andits cannot show.limits.

VibeCodingSimulations.pngContent

PredatorMathematical models and preycomputer populationssimulations typicallyare showespecially cyclical,valuable phase-shiftedtools fluctuationsin (classicecology, example:because lynxthey can express highly complex relationships between organisms and snowshoetheir hare)environment through comparatively simple mathematical equations (often systems of differential equations). This makes it possible to run experiments in silico and test hypotheses on the model in situations where a real experiment would be too costly, too slow, ethically difficult, or outright dangerous — manipulating a real predator population, for instance, is rarely an option. At the same time, every model is necessarily a simplification of reality, and this is exactly where its weaknesses lie: real ecosystems are far more complex than any model can fully capture.

The Lotka–Volterra model (Lotka, 1925; Volterra, 1926) is a classic example of such a simplification, applied to predator–prey dynamics — the cyclical, phase-shifted fluctuations typical of many real predator and prey populations (classic example: lynx and snowshoe hare). It describes thisthe system 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.

ThisTo tidyproduce cyclethis onlyclean emerges becausecycle, the model makes several strong assumptions: it is deterministic: given (the same starting values, itvalues always producesproduce exactly the same curve.curve); it is a closed two-species system that excludes every abiotic factor (temperature, precipitation, season) and every other biotic factor (food plants for the prey, a third species, disease); and it makes each population's growth depend on nothing except the size of the other population.

Real populations arerarely notmeet likethese thisassumptions. — births,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. TheLikewise, modeladding is alsojust a closedsingle 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 suchmissing factor — a temperature-dependent growth rate, or a limit on the prey’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. In this lesson's main activity, students discover this for themselves by trying to add exactly these kinds of factors.

Lesson plan
Phase Time Activity
Warm-up 8 min ShowThe teachers shows 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 TeacherThe teacher introduces the model’s variables and parameters using a simple diagram (no differential equations needed.needed).
Explore 15 min In pairs, studentsStudents test their hypotheses in pairs on a ready-made HTML simulation and record their observations.
ExtendLayer within AIcomplexity 2035 min PairsIn writepairs, astudents work through 2–3 rounds of predict → prompt → test → diagnose (guiding questions below), each time asking anthe LLM to add one newmore factorlayer of ecological realism to the simulation (e.g. a “hunting”limit button), teston the result,prey's andfood interpret the change.
Stress-test the model 15 min Pairs usesupply, a second AI prompt to either (a) make one parameter random instead of constant, or (b) addspecies, a factorseasonal/abiotic fromfactor) outsideuntil the modelclean (e.g.two-variable temperature-dependentcycle growth,visibly limitedbreaks plant food for the prey), and observe how the simulation destabilises or breaks.down. Reflect: what the model can and cannot show 20 min Whole-class discussion, guided by questions such as: WhyAt which round did the randomisedsimulation orstop extendedproducing versiona behaveclean, differently?repeating cycle? What does the original model deliberately leave out, and why? What makes thisit a useful simplification rather than simply a wrong one?

Guiding questions: layering complexity

Pairs work through as many of the following rounds as time allows in the 35 minutes (most manage two; the third is an extension for early finishers). Each round follows the same four-step cycle:

    Round 1 — limit the prey's food supply (a carrying capacity):
      Predict: Before you prompt anything — what do you expect to happen to the cycle if the prey's growth slows down once the population gets large, instead of growing without limit? Sketch the curve you expect. Prompt: Ask the AI to add a maximum sustainable prey population to the simulation, and to explain in its own words how it changed the growth equation to do this. Test & compare: Run the new simulation with the same starting values as before. Did the amplitude of the oscillation shrink? Did the population settle at a steady level instead of cycling? Diagnose: Which assumption of the original model (unlimited food for the prey) did you just remove? Is this factor biotic or abiotic? Round 2 — add a second living factor:
        Predict: If a third species now competes with the prey for food, or preys on it as well, what do you expect this to do to the original two-species cycle? Prompt: Choose one option (a competitor, a disease, or a second predator) and write a prompt asking the AI to add it as a new variable linked to the existing ones — specify exactly how it should interact with the prey or predator population. Test & compare: Observe the simulation over several cycles. Does the original two-species rhythm survive, get distorted, or disappear? Diagnose: The original model assumed each population depends only on the other. Is that still true after this round? What real ecological relationship does your new factor represent? Round 3 — add a factor from outside the ecosystem:
          Predict: If prey growth now depends on temperature or the season (e.g. faster growth in “summer” months), how might the cycle change over a longer simulated time span? Prompt: Ask the AI to make one growth or mortality parameter vary over time (e.g. following a seasonal pattern) instead of staying constant. Test & compare: Run the simulation for a longer period. Does the cycle stay regular, drift, or become chaotic? Diagnose: This factor is abiotic. Which of the model's original “closed system” assumptions does it break? Optional round 4 — introduce randomness:
            Predict: If one parameter (e.g. the predation rate) is no longer fixed but drawn randomly within a range at each time step, what do you expect for the long-term stability of the populations? Prompt: Ask the AI to replace one constant parameter with a randomised value and to keep track of whether either population reaches zero. Test & compare: Run the simulation several times with the same settings. Do you get the same result every time? Does either population ever collapse? Diagnose: Why can the same “average” parameter values sometimes lead to extinction here, when the deterministic model never predicted that?

            Closing question (for the Reflect phase): At which round did the simulation stop producing a clean, repeating cycle — and what does that tell you about how many real-world factors the original Lotka–Volterra model has to leave out in order to stay solvable and easy to interpret?

            Materials
            • One laptop per student pair, with a browser
            Access to an LLM chat interface via the internet, or a locally installed model if internet access is restricted at school Ready-made HTML/JavaScriptHTML predator–prey simulation (single file, sliders for the fourselected parameters) TwoA short prompting templates:/ oneworksheet template for extending the simulation“layering complexity” rounds (e.g.predict adding hunting),prompt one fortest stress-testing it (adding randomness or an external factor)diagnose) Guiding questions for the exploration phase and the Nature-of-Science reflection (model purpose vs. model limits)