Wa-Tor is a simulation of fish vs sharks in a toroidal wraparound world. It was devised by AK Dewdney in 1984 and published in Scientific American under the name “Sharks and fish wage an ecological war on the toroidal planet Wa-Tor”
The original Wa-Tor simulations took place on a VAX system with a display 80×23 characters in size. Each step of the simulation took a while to run (no exact time specs given). It is interesting to read in Dewdney’s article that to test a theory he had about the system he let a setup run overnight to see what happened in the morning. Now with a decent computer you can run these over thousands of cells in almost real time.
The world consists of a 2D array that wraps around at the edges. When you have the wrapped edges the world becomes a donut (or toroid) shape.
A number of sharks and fish are randomly distributed into the world.
Fish look for empty cells directly next to themselves (using a von Neumann neighborhood of neighbor cells directly north, south, east and west) and randomly move into one of them. If they are older than a specified breed age they will leave a child fish behind in their current location.
Sharks look for fish next to themselves and randomly eat one of them if found. When they move they will leave a child shark in their old spot if they are older than a specified breed age. If no fish are found they will randomly move into an available empty space. If they do not eat their starvation level increases. If they starve for too many steps of the simulation they die and are removed from the world.
Here is an example movie Wa-Tor. Green pixels are fish, red pixels are feeding sharks, gray pixels are sharks.
If you balance the settings right this sort of simulation will continue to cycle indefinitely.
Wa-Tor is controlled by the following parameters the user can play with;
Fish breed age – how many simulation steps does a fish need to survive for before it can give birth to baby fish. For these simulations I used 3 cycles.
Shark breed age – how many simulation steps does a shark need to survive for before it can give birth to baby fish. 15 cycles.
Shark starve time – how many simulation steps it takes for a shark to starve to death if it does not eat. 10 cycles.
An alternative method is to allow fish and sharks to only move randomly.
Fish pick one of the 4 directions at random. If it is empty they move into it and potentially have a child. If it is occupied they do nothing.
Sharks also pick a random direction. If a fish is there the shark eats it. If the spot it empty the shark moves into it. If it is occupied by another shark the shark does nothing.
Here is an animated gif showing fish and sharks both moving randomly.
This was a quick idea I had. Each fish has a color assigned to it. When it has a child fish, the child fish has the same color with slightly different RGB values. This way you can see how a “family” of similar fish spreads.
Wa-Tor can also be extended to 3D. In the following movie the simulation takes place in a 3D cube of cells, but cells outside a centered sphere are hidden to see the inner structures more clearly.
In this next movie only the fish are visible and they are colored to show how fish and their offspring spread.
Wa-Tor is available in Visions of Chaos.