Tuesday, March 21, 2017

Evolution - Survival of Fittest

Orange dots are animals.  Green dots are plants.  Can the animals adapt and survive to your conditions?

Evolution is a "game" or rather, more of a simulation really, taken from the book "Land of Lisp" by Conrad Barski (see: http://landoflisp.com/), where it was written in Lisp.  I created a demo of that game a while back, in Lua using the Love module for graphics.  Today, I've finished a demo of that game with more sophisticated GUI controls in Visual C# with .NET.


Overview

Evolution starts with a world that includes plants and animals.  Plants do not move and provide energy to animals that happen across them.  Animals consist of genetic material that guides their motion, as they expend energy while searching for food to sustain themselves, and ultimately, to reproduce and grow as a society.  Reproductions halve an animal's energy and their newly created offspring have the chance to incur mutations to their direction-sense genetic material.  During the course of a single "day" in the game, new plants are added to the world and they are more frequently added into the "lush forest" area of the map, a special section of the world designated by a square box.

Hence, it stands to region that from an evolutionary sense, and under the right conditions, the animals will evolve as a society that thrives wherever the lush forest is.  Any animal that adventures beyond the lush forest becomes a "roamer", and its chances of survival and reproduction are much less in the severe wilds.

GUI Controls

Under the right conditions, its easy to see, upon firing up the simulator provided by this C# demo, that the animal population will indeed converge fairly quickly upon the lush forest.  To make things more interesting, I've provided a number of "god" controls for the user to play with and see how they effect the natural evolution of the animals in the game.

Lush Forest

using the mouse, the user can click to establish a new grounds for the lush forest.  Additionally, the mouse wheel can control the size of the lush forest.  The larger the forest, the more active the plant life within needs to be, or else, the lush forest will just seem like another section of the entire world without any special properties.

Speed Controls 

the bottom right offers a number of controls for expediting the length of each day.  This helps to see convergence happen much quicker.

Parameters

A number of parameters are editable in this demo.

  • "Plant Growth" specifies the number of new plants per day to be added in random places in the entire world.
  •  "Lush Plant Growth" specifies the number of new plants per day added in the lush forest section.
  •  "Animal Energy Use" specifies how much energy per day is spent by each animal
  •  "Animal Reprod Energy" specifies how much energy an animal requires before it can reproduce.
  •  "Initial Animals" specifies how many initial animals to start with in the simulation
  •  "Plant Energy" specifies how much energy an animal will gain when it eats a plant


4-Way/8-Way/16-Way

Animals in the world follow one of these three systems.  4-way are the cardinal four directions while 8-way adds the cardinal diagonals.  16-way adds eight more directions that represent the "L" steps a Knight can take on a chess board.  You might expect learned animals to figure out that more advanced directional choices are higher on the evolutionary chain than the simplest four cardinal directions, unless the lush forest was so small that every "L" step might cause an animal to keep "missing" where plants are.

Wrap World Control

When checked, the control indicates that animals that walk off the edges of the world will wrap around to the other side.  Otherwise, animals that prefer a single direction are doomed to stick to the wall until they die.

Interesting Scenarios

Sporadic Microbursts

Try adjusting the "Animal Reprod Energy" to something very small, perhaps even to 1 energy.  Animals will reproduce every turn they get, halving their energy until they become so halved and weakened that they die.  This will result in extremely intense but also awfully short population bursts.

Crossroads

Sometimes an animal will learn that all it has to do to survive is to walk in a single direction forever, bounding around the world with enough energy provided to it from the plant it eats from the lush forest.  Now go ahead and be cruel and turn off the world wrapping.  If you wait for a lot of very high-energy animals to get stuck on the wall, and then re-enable world wrapping, you will begin to see some cool visual patterns among all of the animals as they bound across the ends of the world in unison.

Nothing to Learn

If plant growth inside and outside of the lush forest are roughly equivalent per cell, then you'll begin to see fairly consistent randomized motion among all the animals, as the conditions for life are simply not harsh enough to promote adaptation behaviors.

Too Harsh to Live

If you set conditions for animals to live that are too harsh, then a civilization of animals will never be possible.  Animals will die out before they ever find food, and become extinct.  If this happens in auto mode, the simulation will automatically restart.

How to Play

You can grab the file from here: http://fun.unbox.org/apps/Evolution.exe.  Your computer will probably suspect this file as malicious, so you may need to bypass the warnings.

Requirements

.Net Framework, maybe (try: https://www.microsoft.com/en-us/download/details.aspx?id=53344)

No comments:

Post a Comment