Saturday, November 22, 2008

Building Life Part 1 (Withdrawal...)

I think I am experiencing withdrawal from PHP|Works and Py|Works. I had a great time in Atlanta. I was able to see lots of great people, spend time looking at at thinking about things I love, give a talk on AI and Artificial Life, and spend time working on my Artificial Life project.

A few months ago, I decided, on suggestion of Travis Swicegood, to revive my Artificial Life project of evolving group hunting and group defense among artificial life forms. This project was an excellent learning opportunity and I achieved most of the results that I set out to do. It started out very simply. I created a world with plants and added prey. I hand coded the prey so that they would be able to use antenna (a smell based system where smell decreased proportionally with the distance squared) to get to the plants near them and eat. This worked relatively well. Now to bring on the competition.

I started with simple predators that were the same model as the prey, but were following the "prey" antenna instead of the plant antenna. In my model, each pair of antenna would give information on only one scent. In order to handle multiple scents, the system would have multiple sets of antenna. Now I had predators hunting prey that were hunting plants. My world was charging creatures for each time slice, how far they moved, and how much they turned. The predators were able to keep alive for only a little while before they ran out of juice.

Now was time to add evolution into my "evolving group hunting and defense" project. I created a simple neural network, gave it nice high-level inputs and had it output neurons for speed (high, medium, stop) and turning (left, center, right). Remember that the predators were not living too long at this point. The very first time that I ran the evolving predators from a random start, the second generation did not die. One of the predators lived so long and ate so many prey that it actually wrapped the health counter to a negative number while the debugger was attached. Ouch. So much for my hand coded algorithm. At this point, the game was really on. I quickly modified the creatures to have a maximum lifetime and health count. No more infinite life or infinite energy. It also ensured that a trial would run for a maximum of around 37,500 clock ticks. Prey and predators were switched to evolving neural networks and physiology and were never switched back.

I have had several questions from people about how I managed plant populations and generations of predators and prey. Plants are replaced as needed to keep the population steady after every move cycle. Plants are centered on one of the four quadrants randomly chosen with a random distance (there is a multiplier that can be adjusted to make them more or less clustered). Prey and Predators have a similar methodology for being replaced. Once an entire generation of prey or predators are dead, a lottery is held. Each creature starts out with one lottery ticket, just for being alive. For each point of health that they have consumed in their lifetime, they get an extra ticket. This means that even completely ineffective creatures may have the ability to breed. It also means that you have to finish an entire generation before you can get more food. A single prey off in the corner can make it pretty hard for the predators to eat.

Jacob

2 comments:

herself said...

Sounds like a really cool project. I haven't gotten close to that far yet in evolution programs.

So are you going to start up an online version for us to watch? :D

Jacob Taylor said...

I need to find a good way to record a video. The system has logging and replay built into it, but I would have to record that and upload to something like YouTube. Any good and cheap video recorders for Mac?