FishEco is a fish ecosystem based on the survival of the fittest. At the start of the program, multiple fish are spawned with very different traits/stats. Some are physically advantaged and some are doomed to die of hunger.

The above video showcases most of the features of FishEco. Every fish has it's unique genes based on two stats : Speed and Sight. Fish need to find food in order to survive, if not they will die from hunger. Some fish are simply genetically superior than other, by having good sight range and/or moving quite fast.

Food



In order to survive, fish need to eat food which randomly spawns each time a food unit has been consumed. Therefore there is always the same amount of food scattered on the map.

Hatching



Fish lay eggs which hatch into more fish! In FishEco, fish are asexual (A single fish is required to lay eggs). The child fish inherits it's parent's trait but with a slight variation.

By letting the simulation run, the genetically disadvantaged fish slowly disappear leading to intense competition for food. The food competition allows only the best fish to reproduce, hence the fish become faster and see further over the generations.

Water currents

The water currents are randomly generated using Simplex Noise which is very similar to Perlin Noise. By keeping it simple, I could explain Perlin Noise by saying it's a random function that keeps the randomized numbers closed together. For example, if I generate 0.5, I'm likely to generate 0.45 or 0.55 the next time I generate a number.



Perlin noise used for 1 dimension. Source



Perlin noise used for 2 dimensions. Source

My use of Simplex Noise was for the movement vectors of the water currents.

We can see that every moving vector is similar to the others besides it.

Fish that get to the border of the map will reappear on the other side. This means if a fish goes outside of bounds at the right, it will come back from the left.A problem I encountered was when the fish was going out of bounds sometimes the grid was generated so that current at the right side of the map was pushing fish out of bounds to the right and the current on the left side was also pushing fish to the left. Fish that ended up out of bounds were stuck. I simply generated a few maps until I found the one above and kept the seed in order to reuse it.

Fish color

Fish color is determined with only 3 variables :

Sight

Speed

Hunger

The RGBA (Red, Green, Blue, Alpha (Opacity)) color is determined like this in pseudo code :

color = rgba(maximumSpeed, sight, 1.0, foodLeftInBelly)

Each color value ranges from 0.0 to 1.0. Note that regardless of color, all fish have a black border delimiting them.

This means :

If a fish is ...

Very slow with bad eye sight and has a full belly it is blue .

. Very fast with good eye sight and has a full belly it is white .

. Very fast with bad eye sight and has a full belly it is magenta .

. Very slow with good eye sight and has a full belly it is cyan.

However...

Any fish with an empty belly will be transparent.

The project is open-source