Moving World Living World Symbiotic World

Launch World Show Info

Worms

Greedy Smart

Fish

None Greedy Smart

Pollinators

Few Lots

Long back I came across a wonderful resource to learn javaScript. I don't want to discuss that here as I won't be doing justice to it. Needless to say I learned a lot from it. Especially from the projects.

One such project in it was, well, Electronic Life. Idea is to build a virtual ecosystem populated with electronic creatures. I decided to recreate it.

Population Chart

The Population Chart gives out the count of creatures alive on a given day for last 100 days.

The original project had alphabets for depicting living and non-living. Every turn the creatures get a chance to take some action. So plants grow and critters move around trying to eat up plants. Of course, I couldn't have the sketchpad have alphabets, I can do much better now. Thus we have the return of the Creatures. Instead of turns, I kept the unit as day. So every day, if the creature is not busy doing something, it gets to select among one of it's actions and act upon it.

Environments

The first world is pretty simple. It is populated with creatures which just indefinitely move around.

In the original project there was Bouncing Critter (o) which moved around randomly bouncing off walls. Here that role is played by the Fly.

The second critter was a Wall Follower (~) which moves along the walls. Here the Turtle is inducted to depict the same.

From the flat Population chart it should be clear that this is quite a boring world.
Here things start to get interesting. Creatures can also reproduce (asexually), eat and die.

The original project had Plants (*), Plant Eaters (O) and Predators (@).

It had introduced the concept of energy which is required for movement (if not plant), survival, and reproduction. Plants can accumulate energy on their own over a period of time. Plant-Eaters on the other hand eat plants for energy, which then they use up for moving and reproduction. And on the top of the food chain we have the Predators feeding on the plant eaters.

The organisms can die too, if they get eaten or run out of energy.

For my version the plant is replaced by Lily, Plant Eater by Worm and Predator by Fish.

Sustaining this world is tough! Very soon you might see the lines flat out on the Chart, a desolate world. Sometimes the world might just be left with plants.
This is my own problem statement. Actually the Living World had lots of hunting and killing which my 6 year old QA specialist was not very happy about.

So to counter that I came up with this beautiful world full of flowers where nobody kills anybody for survival and everybody lives happy ever after.

For the creatures, I got a little lazy this time and instead of coming up with something new (I had done that with Fish already), I reused existing creatures Lily and Fly from the previous world giving them additional/alternate behaviours to live in a symbiotic manner.

Pollinators and Pollinables (not sure if that's a word) help each other. The former collects nectar from the later for survival and the later exchanges pollen through the former for reproduction.

A new type of non-living actor was added here. Hive. That's where the pollinators live and thrive. The collected nectar is stored here and it transforms the same to energy that can be shared among the residents. The hive cells will get filled up with nectar as and when it is collected (nice golden fluid).

Creatures

As the name suggests, it flies around. Can't land on water. So it flies from land tile to land tile.

Needs rest between every flight.
This creature keeps itself restricted to shallow water. So it moves around land all the time. This is the only life-form in this world that doesn't move around. Grows on the water.

Can reproduce if it has accumulated enough energy and has empty space around it to drop a seed.

Can get eaten up and die.

As the Lily doesn't move around, to make it interesting to look at, they have different colors and different number of petals.
Moves around in search of Lily to eat.

The way this creature consumes is dependent on the intelligence provided to it.
  • The Greedy One: Eats up any lily on its way. This results in the ecosystem to quickly perish and devoid of any electronic being.
  • The Smart One: In the original project, multiple solutions were given to make the environment stable.
    • They could stop eating after they reach a certain energy level.
    • Also to make sure lily never go entirely extinct, worms could refuse to eat a plant unless they see at least one other plant nearby.
    • I also added my own criteria. Worms cannot eat young lily.
Can reproduce if it has accumulated enough energy and has empty space around it to hatch a young one.

Can die due to scarcity of plants. Or if eaten by fish.
Moves around in search of Worms to eat.

Just like Worms, Fishes can also be provided with intelligence consume food.
  • The Greedy One: Eats up any worm on its way. This might result in the ecosystem to be full of lily.
  • The Smart One: I took the solutions from the original project, they were good enough.
    • They could stop eating after they reach a certain energy level.
    • Also to keep food stock alive, fishes hunts more aggressively when there are a lot of worms around and limit hunting when preys are rare.
    • And the dont eat young worms criteria is also in.
Can reproduce if it has accumulated enough energy and has empty space around it to hatch a young one.

Can die due to scarcity of worms.
Special reproduction by pollination.

To simulate that, a Lily can only reproduce if it has got a pollen from another Lily. So when a pollinator lands on a Lily, if it is ready for reproduction (the required energy and empty space condition remains), checks if the pollinator has a pollen to offer. If yes, reproduces, if no then the lily attaches its own pollen to the pollinator to enable reproduction for some other Lily.

Another change here is that for the offspring, the petal color is a blend of itself and parents. Gives some variety to the world.
Instead of the bee, I am using the Fly as a pollinator here.

They have just one job to do. Go and collect nectar from surrounding Lily and deposit them in the Hive. Every trip they visit multiple Lily's and also carry pollen from them to spread around.

Once it deposits the collected nectar in the Hive, the Hive recharges them with energy so that they can make the next trip.
The flies can't reproduce. Only the Queen can give birth to more flies. Visually it's just an oversized Fly. But behaviour wise it's only job is to give birth to more flies for the Hive.

The Queen doesn't go around to collect nectar/energy. That is shared to her by the other flies from their collection. Once it has enough energy, it gives birth to a young fly who goes straight to work collecting more nectar.

Once the Hive is fully populated, the Queen's primary job is done and occasionally she flies around the archipelago.

Controls

While the moving world is a basic (boring) one, the living world is quite dynamic in nature. Use the controls to simulate a living world of your liking.

For the symbiotic world, you can select how many flies you want it to have. Sparsely populated or overpopulated.

Make sure to Launch the world after your selections are done.

Show/Hide Info toggles information regarding the following:

  • Frames Per Second (FPS) for the performance.
  • World Grid
  • Also enables you to click on a particular creature to put out its vital information.

It's not a Bug, it's a Feature: If you are careful enough to click at a time and a location when/where there are multiple creatures, information for all of them will pop up.

Eloquent JavaScript - by Marijn Haverbeke. Awesome content for anyone who wants to understand functional programming.

Chart.js - To render the Population Chart.