Fish-in-Pond Simulation

A fish is swimming in a circular pond as shown. It uses its sensory organs to detect both food in the pond and the hazard (the pond edge) in order to generate the correct response, swimming toward the food but away from the pond edge. See the Details section to learn about mechanical and sensory modelling.
Click the pond to place the prey (an orange spot) and the fish will try its best to find it. You can also choose to do nothing and just watch how the fish swims in the pond and turns away from the edge.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


1. Equation of motion
Assume that the fish body is spherical, and the position and the orientation of the fish in 2D can be described in generalized coordinates . The equations of motion of the fish can be written as
where is the mass of the fish, is the radius, and and are damping coefficients due to the viscosity of water. and are control forces, generated from the left and right fins in response to any signals received from the eyes and ears. The angle is constant, which is the angle between the axis of symmetry and the line joining the center of the spherical body and the fin bases. The coefficients and are arbitrary constants.
Assume that the fish is small and light, and the inertial force term is negligible; the equation of motion becomes
Hence the equations of motion under the assumption of small mass and size takes the form
2. Sensory modelling
2.1 Weber–Fechner Law
Electrophysiology (recording neurons with electrodes) and psychophysics (asking people
or testing animals to discover what they perceive) show that we register constant relative changes in stimulus intensity as constant changes. This means that we can model the response of a sense organ as a logarithmic function of the stimulus intensity:
where is stimulus intensity and is the response amplitude.
2.2 Wall sensor
When the fish moves in water it displaces water ahead and around it. This water that gets pushed aside is called the bow wave. A solid object in the bow wave causes a change in the flow pattern over the fish’s skin as it swims by. This is called the acoustic near-field effect. The intensity of an acoustic near-field pattern falls exponentially with distance to the source. Applying the Weber–Fechner Law, the response due to the wall sensor (ear) stimulus can be written as
2.3 Prey sensor
We will assume that the prey or food generates some cue (e.g. light or sound or smell) that decreases following the inverse-square law as the fish moves away from it. The inverse-square law is a physically correct model of light, sound, or smell from a localized source under idealized conditions. Again, applying the Weber–Fechner Law, the response due to the prey/food sensor (eyes) stimulus can be written as
The parameter is infinitesimal; it is included as the conventional inverse-square law may result in a divide-by-zero exception and crash the program.
2.4 Force due to stimuli and )
The magnitude of the force generated in each fin is proportional to the strength of the responses. The fish has two eyes and ears, so it can determine whether the wall or the prey is on the right or left, as by geometry one of the eyes or ears will receive a stronger stimulus.
We want the fish to rotate away from the wall, but also rotate toward the food. If (for example), there is a wall on the left, then the left ear receives a stronger signal than the right ear. We want to push with the left fin to make the fish turn right, away from the wall, so we want to increase the force on the left fin while reducing the force on the right.
Therefore, and can be calculated using
where and are the forces generated by the fins when there are no stimuli.
3. Simulation
In the simulation, we discretize the equation of motion and introduce a stochastic term to model the noise.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+