jLife : a new version of the game of Life (Conway) that uses win32 SDK and genetics
Download Files
Changes
- Initial Version
Installation
None.
Notes
The original game of Life was described by John Conway here
Conway's Scientific American Article.
and a Java implementation is here Game of Life.
This design essentially came from a conversation Thomas my son and I had about evolution and how things interact.
How to use it
Press Go! to start it up.
If all the Animals die, press Re-init!. You don't have to stop it to re-initialize the screen.
Press Settings...
- Sunshine% - the probability the sun shines on a given cell
- Plant Life w/ Dirt - the plant life increment if there is sunshine and dirt in the cell
- Plant Life w/out Dirt - the plant life increment if there is sunshine but no dirt in the cell.
- Plant Life w/out Sun - the plant life decrement if there is no sunshine in the cell.
- Use Genetics - a child inherits from the parents (i.e. crossover and mutation is done).
- Sociability - 0 is unsocialable, just a voracious eating machine! 100 is "clingy", barely survivable.
What the colors mean
- The white squares have no sunshine, no plants, no dirt and no Animals.
- The yellow squares have sunshine but no plants, no dirt and no Animals.
- The brown squares might have dirt but, no plants and no Animals, and perhaps some sunshine.
- The green squares might have plants but no Animals and may have dirt and sunshine. The darker the green, the more plants there are.
- The blue squares have an Animal, and may have sun, plants and dirt. The darker the blue, the more Energy the Animal has.
- Newborns are "baby blue" :)
This screen shot shows jLife just after start up. The screen is randomly set to have Animals or
not, in this case there are 10,448 Animals.
What the text means
- Generation: The number of updates that were done. See below for a description of what happens during a generation.
- Non-Animals: the number of cells that don't have an Animal.
- AnimalX pop.: the number of cells that have an Animal of Type X.
Type's range from 1 to 512, but only the first 19 are shown.,
This screen shot shows jLife just after starting up. The big die-off has already occurred and
five colonies have started (two merged together in the middle right of the screen).
Cool things
After the first initialization is done, there is the big "die-off" where most of the initial
Animals die from starvation. The result is usually less than 100 Animals are on the screen.
During the pause where there are few Animals, the plant life builds up.
Then one to four "colonys" start up. Within a short time, the entire screen is filled with Animals
eating at the abundant plant life, usually up to 2000 - 3000.
But eventually the plants run out and another "die-off" starts. The Animals almost go extinct,
some times down to a few hundred. The plant life recovers and the Animals re-populate again.
This cycle will continue for hours. It is possible for the population to go extinct but it's rare.
Try setting Sunshine% from it's default of 32 down to 31, 30, 29 and so on. Notice that the downward swing
of the Animal population goes closer and closer to zero. There will be a point where the
Animals do not start up (somewhere around 26 or 27). Click the Re-Init! button to recover.
Try setting the Sunshine% to 80. It's difficult to describe what
seems to happen here. The Animals go nuts, but the color patterns produced
are kind of "inverted" from the normal case.
Now set Socialibility to 100 and leave Sunshine% at 80. The Animals clump in tiny tribes of 5 - 10 each.
They can split in two and new tribes show up.
Leave Socialibility at 100 and set Sunshine% to 50. The population drops dramatically,
most of the time going to zero.
This screen shot shows jLife Settings dialog. I am setting the proabability of Sunshine in
a cell to 80%.
This screen shot shows jLife after running with Sunshine% set to 80.
What's next?
- Fix bug: changing the setting doesn't update the screen. You can force the update by minimizing the window and the restoring it.
- Fix bug: Settings, "Use Genetics" is boolean but it only accepts a number. Use 0 (false) or 1 (true) for now.
- Fix bug: after Settings dialog is closed, the menu items stay grayed out.
- Fix the Type to use a full "DNA" string for identification of a type. Then hash the string and
use that for the Type index.
- Move the algorithm for calculating various parts of the Animal's behavior into an AST (Abstract Syntax Tree)
then use crossover and mutation on the AST to simulate fundamental evolutionary behavior.
- Gather statistics: Average life span
What happens every Generation
- The presence of sunshine is calculated based on Sunshine%.
- If there is no sunshine, the plant life is decremented Plant Life w/out Sun. If that's the end of the plant life,
the "dirt" is incremented.
- If there is sunshine, the plant life is incremented Plant Life w/out Dirt. If there's dirt too, then the plant life
gets a different increment Plant Life w/ Dirt and the dirt is used up (decremented).
- If there is an Animal in the cell:
- It's age is incremented
- It loses a bit of Energy every Generation. Older and very young Animals lose a bit
more Energy.
- It gains Energy by eating plants, if it can.
- An Animal creates some "dirt" every day.
- If the Energy goes to zero or below, the Animal is dead.
- If the Animal is socialable:
- The next layer of surrounding cells are checked for the existence of Animals.
- If the current Animal has the highest Energy, it doesn't move.
- Otherwise, it moves towards the Animal with the highest Energy.
- If there isn't enough food in the current location and it has enough Energy to move,
it checks surrounding cells for the highest plant life and moves there.
- If a cell started with an Animal but it died during the Generation, some dirt is created.
- If a cell doesn't have an Animal, there is a check if a birth is possible:
- The immediately surrounding cells are checked for the existence of two Animals.
- The two with the highest Energy are selected.
- If they both pass a threshold, a baby is born.
- The Energy of the baby is a minimum plus a percentage from both parents
- The parent's Energy is decremented by half the amount given to the baby.
- If either parent goes below zero, the parent is killed (Energy set to zero).
- If you select "Use Genetics":
- crossover - 50% chance you inherit a trait from one parent or another
- mutation - 1 in 1000 chance a trait spontaneously increases or decreases.
- Otherwise you get the full traits of one parent.
| Contact me about content on this page using john_web-at-arrizza-dot-com |
| For Web Master or site problems contact: webadmin-at-arrizza-dot-com |
| Copyright John Arrizza (c) 2001-2010 |