Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, June 29, 2010

Getting PIL to work well on Snow Leopard

I was trying to update my environment and ran into some linker problems. It turns out that PIL was not working well. My Python is 64 bit, the python that my environment was trying to use was i386 and ppc. I have not been building ppc files. I found a few great references out there.
Universal Binaries on Mac Ports was the best. Modifying your varients.conf file to include:
+universal
Gets you half of the way. If you need ppc support under a 64 bit Intel setup, you need to add them manually into macports.conf:
# machine architectures
universal_archs x86_64 i386
Changes to:
# machine architectures
universal_archs x86_64 i386 ppc
Save these two files and then rebuild. In this case, I was rebuilding a PIL dependency jpeg. I also found out I had to add a few more dependencies for linking to be happy:
sudo port upgrade --force jpeg
sudo port install zlib
sudo port install freetype 
The "--force" made sure to stomp over the existing compile even though other things depended on it. As mentioned in the article referenced at the top, the way to nuke and rebuild everything is by running "sudo port upgrade --force installed". I do not recommend this unless you need to or have a lot of time on your hands. It will all be rebuilt. :)

Hope this helps someone. If it does, please let me know.

Jacob

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

Monday, September 22, 2008

Contemplating Artificial Life...

I have long had a fascination with Artificial Life. My master's thesis at UCLA was evolving pack hunting and pack defense in artificial life forms. I thought it was an interesting project and it went well. I was quite surprised by the variety and completeness of the forms of hunting and defense that very simple organisms were capable of displaying. I was able to get my artificial life forms to display all of the kinds of hunting that were in a book on predatory behavior. My thesis was a parallel program written in C++. I am currently starting to port it to Python and I am going to present a talk on it at Py|Works "Exploring Artificial Intelligence with Python" . I hope that some of you can make it.

My ideal outcome would be to leverage my research and that of others to produce better, deeper, more realistic, and ultimately more fun creatures for games and education. Knowing how easy it is to evolve and/or run simple creatures that behave in amazing ways, I am constantly disappointed in the creatures that are out there in games today. I am also looking for people that would be interested in joining me in this pursuit. Do you love AI or online games? Would you love to make them better?

Let me know,
Jacob Taylor