Each fish is re-positioned in the DOM using absolute positioning, every frame. Each frame is timed, and several frames make up one "tick". If the duration of a tick is within a predefined limit, another fish is added to the pool.
This continues until ticks start to take too long, and fish stop being added. If a predefined number of "ticks" pass without any new fish being added to the pool, you're presented with your number of Maximum Fish.
Each different fish also has its own personality, too. Some move faster than others. Some have a higher chance of turning around. Some are cuter. Some are more-eye-than-fish.
If you're bored ...
Once you hit your Maximum Fish, let them continue swimming, and try to work out which fish is at the top.
The script doesn't handle resizing, so using a smaller window results in much faster rendering, allowing for even more fish.