Pages

Thursday, February 16, 2012

Notes on Building an Artificial Life Simulation

Some people spend their free time building model airplanes, watching TV, or washing their cars. A decade ago I spent the better part of two years building my own "Artificial Life" simulation inside a computer, using my own "simplified" versions of genetic algorithms. I called it "Cyberdrome" and eventually wrote a science fiction novel of the same name, loosely based on this "game." Here's a flashback to some of my notes from that period, that were posted on my very first website back then.



20 October 1999

Work has resumed on the Cyberdrome Simulator, our 3D digital recreation of Cyberdrome's Infected Program Zone. Our current version contains 36 memory sectors, with each sector covering a scaled area of 25 square miles, for a total of 900 square miles of cyberspace to explore!

In addition, each of the 36 sectors now contain up to 1000 independently moving Artificial Life forms, which means almost 36,000 new enemy programs are now infecting our Cyberdrome Simulation. These digital creatures currently consist of the first four species, Bantams, Spiders, Mantises, and Polymorphs. The remainder of the nine enemy species will go on line at a later date, along with perhaps a few digital life forms modeled after humans!

With this many new enemy programs to deal with, our TRACER interface ships needed to be upgraded as well. Our software ships now have the capability to change from their standard Explorer modes into two new configurations; Recon mode- 50% faster and flight capability, but no shielding or weapons, and Warrior mode - a sort of "tank" configuration with double shields and more powerful weapons, but speed is cut in half. Also, TRACERs in Explorer mode now have the ability to create their own localized Quantum Tunnels, which allow them to travel a quarter way across the 5 mile wide sector in just seconds.



01 December 1999

All of the one thousand ALife forms inhabiting each of the 36 sectors of the Cyberdrome simulation are now having their "DNA" defined, which is my term for an adjustable array of creature attributes or behaviors, such as aggressiveness, herding behavior, maximum speed, maximum shielding, and about a hundred others. For example, an aggressiveness factor of +100% means that the creature will attack any foreign species that comes within its sensor range, while a factor of -100% would mean that it would always run from foreign creatures. Any value in between would allow the creature to balance what it is currently doing (such as eating) to the potential threat from an approaching foreign creature. Likewise, a high herding value would cause the creature to stay close to creatures of the same species, while a negative value would cause the creature to avoid its own species, creating a rogue individual.

Just using the two factors of herding and aggressiveness, here are just a few of the millions of possible creature types that might emerge:

  • Herding: -100% / Aggressiveness: +100% 
    • A creature born with very negative herding behavior and very positive aggressiveness factor would be a great "warrior", since it would tend leave the area controlled by its own species and attack neighboring species. Chances of having a long life and breeding would be slim for these creatures. 
  • Herding: +100% / Aggressiveness: -100% 
    • A creature born with very positive herding behavior and very negative aggressiveness factor might be considered a "sheep", since it would stay close to it's own kind and run from all intruders. These creatures would probably survive much longer than more aggressive types and would have a better chance of mating and bearing offspring, but with no desire to leave their home space, they might overpopulate the area and use up all local resources. 
  • Herding: +100% / Aggressiveness: +100% 
    • A creature born with both very positive herding behavior and very positive aggressiveness factor would be a great "defender", since it would stay close to it's own kind but would attack any intruders who came too close. 
  • Herding: --100% / Aggressiveness: -100% 
    • A creature born with both very negative herding behavior and very negative aggressiveness factor could be a good "explorer", since it would tend leave the area controlled by its own species but would also avoid all other species. These individuals might colonize unexplored territories, although breeding would be difficult since they avoid their own kind. 
  • Herding: -50% / Aggressiveness: -5% 
    • A creature born with somewhat negative herding behavior and only slightly negative aggressiveness factor could be a good "scout", since it would tend leave the area controlled by its own species but would not tend to interact at all with other species (except perhaps to move away from anyone who gets really close). This scout creature could wonder through enemy territory and possibly gain information or even steal resources.  



10 December 1999

They're alive! All of the one thousand ALife forms inhabiting each of the 36 sectors of the Cyberdrome simulation are now moving independently and reacting to their environment! With only a few of their DNA values defined so far, these first generations of digital creatures are currently little more than mindless eating machines. With limited resources within the confines of the IPZ, border skirmishes between the four main species are common. It is so dangerous inside there right now, our interface ships, the TRACERs, will need to be upgraded with longer-lasting Altered State Modules (making us invisible to them) so that we can study their behavior without getting the bits blasted out of us.



15 December 1999

This past weekend, we allowed all the ALife forms inside our Cyberdrome Simulation to interact for the first with other species. Rather than observing simple fight and flight behavior, we discovered what appears to be a new and unknown species growing inside our simulation, which we are calling, Species X. We are assuming that the creation of this new species is "just a bug" in the code, but until this is confirmed, we are minimizing direct contact. The following image shows an overhead view of one IPZ sector, and the new species (blue dots) begin appearing in the area between the Mantis and the PolyMorphs within a few seconds of beginning the simulation. This species is able to take over the sector in under 10 minutes, converting all other species it comes in contact with, into its own kind. Flying through a sector in our TRACERs, we discovered that Species X is invisible, somewhat like a Phantom. However, unlike a Phantom, it can be easily tracked by scanners.



28 December 1999

The mystery of the strange formation of Species X has been solved! Only C and C++ programmers will understand when I say that the symbols |= look very similar to != but are definitely not the same (!= means "NOT equal", while "|=" means "OR equal". Suffice it to say, Species X has been eliminated with a simple symbol change - if only it were that simple in the REAL Cyberdrome ;)

The Simulator is now working amazing well, and below is an example image showing the four main species inhabiting a fractally-generated terrain in one sector of Cyberdrome. The upper left image is a top view, the upper right image is a zoomed section, and the lower image is a 3D view from above. The lighter regions are higher elevations while the darker regions are the lowlands, and the blue areas in the lowlands are lakes of Positive Energy which the ALife programs treat like water sources and flock towards them when they become low on power. You can see a group of Bantams (green dots) in the upper left portion of the top view image, as well as a large group of Spiders (yellow dots) in the upper right. In the center (inside red square) you can see many species sharing one large Positive Energy source (see zoomed section in upper right screen). Red Spiders and Gold PolyMorphs can be seen along with the green Bantams and yellow Spiders. Enjoy the pictures and we will return with more updates in January. Have a safe and happy New Year!



05 January 2000

Our Cyberdrome Artificial life programs now have 12 of their 100 "genes" defined. These digital genes control attributes such as species, gender, age, walking speed, current energy level, energy level required to mate, vision (the distance a creature can "see"), strength (used in fighting to calculate damage caused to other creature), as well as behaviors such as flocking (desire to move towards (or away from) creatures of your same species) and aggressiveness (the desire to move towards (or away from) creatures of different species). With only a dozen genes defined so far, the one thousand ALife creatures inhabiting each of the sectors are exhibiting quite interesting and unpredictable behaviors, especially after a few generations.

Now that the basic ALife Engine is working, we have started work on the "game" aspect of our simulator. We currently have variations of "search and recovery" or "search and destroy" missions where we pilot our TRACERs inside a sector filled with up to 1000 ALife forms, and try to complete our mission while avoiding getting the bits blasted out of us by the indigenous population, who, it just so happens, don't really like us being there. Luckily for us, the four species inside dislike each other more than they dislike us, so we often try to use that to our advantage. We also have Altered State Modules which make us invisible for a short while, decoy mines which attract enemy fire, and other digital weapons and tools at our disposal, so we are not exactly helpless. Still, these ALife creatures are the size of 3-story buildings and some of them can move faster than we can! Let's just say it can get pretty hairy in there sometimes. That's when we remind ourselves, "It's only a game!" Or is it?



14 January 2000

We have doubled the maximum number of ALife programs from 1000 to 2000 individuals per sector with no noticeable difference in simulator frame rate! With a much larger starting population there is a greater variety in the gene pool passed to subsequent generations. As Martha Stewart would say, "This is a good thing!" In addition, the Artificial life programs in Cyberdrome now have 20 of their 100 genes defined. In addition, all of the ALife now age with time. With aging, there is now a limited age range where an individual can mate and bear offspring. Also, when females bear children, they lose 10% of their strength, and must regain this energy before mating again.

Newly born children cannot mate, are very weak and slow, and have a strong desire to follow adults of the same species. When they reach "puberty", they can mate and they are at full (genetically programmed) strength and speed, but still tend to follow adults and avoid other species. When the individual reaches adulthood, which it will remain at for 80% of its life, it will follow its full genetically programmed series of behaviors, which may include chasing and attacking other species if its aggression factor is high enough.

Old age brings an inability to mate and a greater probability of getting "sick". Getting sick means that they tend to slow down, grow weaker, and they lose their vision (as it is with most living creatures). There is currently no maximum age for the creatures, but the very old ones eventually to get so weak, blind, and slow, that they eventually become sitting ducks for other species to attack and kill. It can seem cruel inside Cyberdrome for the very old and weak, but we are aiming for a balanced system much like it is in nature.



24 January 2000

The overall ALife processing cycle was completely redefined this past week. Originally we had each of the 2000 ALife forms making decisions based on directional weighting factors derived from what its sensors perceived from the simulated environment of Cyberdrome. Sensor data includes how many enemy are to the South, how much food is to the East, etc. Then the ALife would move in a direction based on these weighting factors and on its current health and fitness levels. This was a good start, but we have noticed that the more docile and weak ALife creatures tended to stay near food sources (randomly generated "lakes" of Positive Energy) while the more aggressive creatures were usually out fighting other species. Since the ALife hanging around the lakes had more direct contact with others of its own kind, they tended to breed much more than the fighters out in the wild. Thus, after five or six generations, only docile sheep-like ALife remained in the simulation. Really boring.

So, this week we changed a few things. First, we created Activity Modes that help determine what the creatures will do with all of its sensor data. These modes include Attack Others, Seek Food, and Mating. For example, when in "Attack Others" mode, a creature will concentrate on seeking individuals of other species (to fight), and will tend to ignore food and members of its own species (unless it bumps in to them of course). We also removed the "flocking" gene described earlier, and gave all ALife positive values (0-100) of the aggression gene. This makes all ALife want to seek out and do battle with other species to some degree, and their ability to do well in battle is determined by their genes of speed, strength, vision, health, plus one new gene defined this past week: a "courage" gene which defines how much damage an ALife creature will endure before running away to seek food to repair itself. A creature will stay in "Attack Others" mode until it either runs low on energy or is severely damaged in battle. It will then switch over to "Seek Food" until it finds a food source and recharges itself, or dies trying.

Mating is now carried out in a completely different manner. We now use devices called "Replicators" which monitor species population size and then act as a "call to mating" when the population falls too low. To explain how Replicators work, imagine you have your own kingdom and that you are an evil ruler (like CJER). You have sent your best warriors, both male and female, off to do battle with neighboring kingdoms. After a few months, you receive word that your army has been reduced in half. Instead of waiting for your army to die off completely, you decide to send word out to have all remaining warriors return home so that they can rest, find mates, and have children. You can assume that the warriors who made it back in one piece, were probably good fighters, or at least good at staying alive. You can therefore assume that the children of two good warriors will be naturally good fighters as well. This is the process commonly referred to as "natural selection". When your army has once again regained its full size, you send them out again to do battle, with the children following as soon as they are old enough.

We have simulated this scenario by installing Replicators in each sector of our PC-based Cyberdrome simulation. Now when a species population falls below a critical level, let’s say one-third of the starting population, then that species' Replicator is awakened and begins to send out a signal which attracts all members of that species, no matter how far away they are. When the returning creatures eventually come within range of the Replicator, they switch over to Mating Mode. In this mode, they will spend all of their time seeking others of the same species for purposes of mating. This Replicator signal will continue to keep the species within a small area (allowing for ease of finding a suitable mate) as well as supplying them with direct energy (to keep all members healthy and eliminate the need for them to go out looking for food), until the population has again grown to full capacity. Then, all adult members of the species switch back over to "Attack Others" mode, and the cycle repeats.

This new strategy in working quite well and our Artificial Life populations are fighting and thriving. There is also a great deal more variety in ALife behavior, which is something we are after. We are still eagerly looking forward to observing our first true emergent behavior. We will keep you posted.



15 February 2000

While we have worked nearly full time this past month to complete Chapter 6 of the book, work continues on the simulator at a steady, but more relaxed, pace. Issues we are now working on include; how to get the ALife creatures to spontaneously "develop" certain tools, such as Quantum Gates (to allow faster movement around Sector), portable chargers (to recharge power when ever needed), and memory mines (to prevent enemy creatures from moving in to certain areas). Also, we want the creatures to be able to interact with the terrain itself, for example, moving memory block around to either get past obstructions, or to block another creature’s advancement. With this "block moving" behavior, later advancements made lead to the ability to build large structures or bases.

12 May 2000

Back to working on the simulator with the hope of putting out a beta demo version sometime this summer. New items for the ALife creatures: ALife now have a new "occupation" gene set, which is assigned at birth and is based on attributes such as speed, strength, vision, etc. Three of these occupations have been assigned so far - they are:

  1. Defend_Home_Replicator - Stay near Home Replicator and defend it from all enemy 
  2. Attack_Enemy_ALife - Search for and attack all enemy ALife 
  3. Attack_Enemy_Replicator - Search for and attack Enemy Replicators, avoiding other ALife 
Note: An "occupation" is what an individual does when all other influences are normal (i.e. it is not eating or looking for food, not damaged or recharging, not fighting or fleeing an enemy, and not mating or looking for a mate.)



08 August 2000
Cyberdrome Beta-Demo update:

The basic idea for the demo we are working on is that you beam in to an infected sector of Cyberdrome in your TRACER and attempt to locate and delete the sector's Replicator, and then return to the sector Transport Beam which will take you to the next mission. The Replicator is a device which allows the local ALife to quickly repopulate the sector, and will be hidden inside a protected Enemy Base which is located somewhere inside the sector. Deleting the Replicator will cause all ALife in the sector to come after you, so make sure you have a planned escape route back to your Transport Beam before deleting it (or at least be prepared for a fight!).

We have designed four levels for cybernauts to explore for the demo. Each level consists of a 25 square mile memory sector which is controlled by up to 2000 ALife "bugs." You enter the sector with Pulsars only since no advanced weapons or tool functions can be transmitted into infected memory. There are, however, numerous functions scattered throughout the Enemy base, and include memory bridges, elevators, mapping probes, etc. When you locate a function, simply drive over it to download it into your inventory.

Also, we have created one new weapon, which when launched at an ALife creature, will disinfect the creature, turning it against its fellow ALife. Having one or more creatures on your side can be a real help when you are surrounded by the enemy!



A final note: I stopped working on this simulation a few months after this last post, and got rid of the "C" software to compile it long ago. While we never released this version of Cyberdrome to the world (opted instead to concentrate on the novel), my brother and I still log back into this program from time to time just to drive around inside the ever-changing 3D world and watch the bugs do their stuff (and occasionally blow stuff up!) Even though the program was written on an old 33-MHz computer, it runs quite nicely on my modern-day, quad-core, 3Ghz system. Must have done something right back then.

Oh yeah, our hope is that one day when the book becomes a movie, someone will say, "Hey I bet this story would make a great online game!" and we'll say, "That not a bad idea!" ;-)

To learn more about Cyberdrome, go to www.Cyberdrome.org