This is an archive of a previous version of Sodarace.

Please visit http://sodarace.net for the latest version.

forum  |  »» sodaplay
 
»» forums  »» artificial intelligence forum

subject: Ameobas created with a genetic algorithm

87 replies on 6 pages. most recent reply: 11-Jun-07 20:14 by Demosthenes2k7

»» back to topic list  

This topic has 87 replies on 6 pages [ 1 2 3 4 5 6 | » ]
»» previous topic   »» next topic  


Chirag

»» models
»» homepage

Ameobas created with a genetic algorithm   posted: 19-Nov-03 19:35   »» 
Hi,
Im part of a team from queen mary university and this is our ameoba created using a genetic algorithm. Here's how we did it:

using an "AmeobaFactory" class that takes in a set of parameters and generates an ameoba, our algorithm does the following

1. Create a population of randomly generated ameobas.

2. Test the fitness of each ameoba.

3. Select two ameobas from this population (favouring the fastest ones) and perform a crossover of the parameters to create a new ameoba.

4. Mutate the parameters of the newly created ameoba.

5. test the fitness of this ameoba. If it turns out to be faster than any of the ameobas in the population. Throw out the slowest ameoba and add this one to the population. Go to step 3

The crossover basically works by taking parameters from 2 ameobas and combining them to make a new ameoba.

The mutation just changes a parameter by some random amount.

Ok i admit this all may seem a bit confusing., but hopefully we'll have a website up soon so we can explain how we did this properly plus make our source code available to anyone needing help in creating there own intelligent modellers.

In the meanwhile try beat this one... this race is for ameobas only!




race: http://sodarace.net/upload/Chirag/AIAmeobaRace.jnlp



TC23

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 20-Nov-03 00:37   »» 
Great research Chirag, I'd be interested in seeing the fastest amoebas of your "colony" to see how they evolved.

Also, have you considered testing genetic algorithms for amoebas not only on flat terrain, but on hills and such?

I couldn't beat your evolved amoeba, but trust me, it wasn't lack of trying; the fastest I could make any amoeba finish that track was about 147 frames.

evilgoatfiend

»» models

Re: Ameobas created with a genetic algorithm   posted: 20-Nov-03 01:43   »» 
Chirag, you must realize that we have already determined that the simplest amoeba is the fastest bacause it is least effected by scaling because it lacks interiority. I agree with TC23, that an amoeba race should include terrain, and that will most put your program to the test as well as constructors.
By the way, that is a really cool technique that your program uses, using the same principal as breeding and evolution. And I must admit that I am puzzled as to how you can combine two amoebas, however you do it, I'm sure is quite inventive.

wwan

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 20-Nov-03 10:02   »» 
Hi
That sounds interesting and they are really fast.
Here some questions:
How many generations where needed to generate your ameoba?
How fast where the ameobas of the initial generation?
Good luck.

Chirag

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 20-Nov-03 12:01   »» 
We are planning to make a website about how we did this but here's a a quick explanation.
The algorithm we used is generally called a 'genetic algorithm'. They allow you to find
optimum solutions to problems that have a large search space. In this case it allowed us
to find the best amoeba from the huge number of amoeba variations that exist.
evilgoatfiend you pointed out that the best amoebas are the simplest. That is true but you
had to figure that out in your head. The genetic algorithm we used found this out for us and
the final amoeba it produced reflected this. when we wrote the algorithm we didnt know anything
at all about what makes a fast amoeba. The point of the algorithm was for it to find this for us.

We chose to start off with amoebas on flat terrain because it was simple to see to code
and to see how it works. Our next step would be to use terrain and try to evolve more complex
models.

For those interested in knowing more about the technique we used i found this site quite handy
as a good introduction http://cs.felk.cvut.cz/~xobitko/ga/ .

If you've read that or already know a little bit about genetic algorithms i'll go into more detail
about what we specifically did.

Encoding of a chromosome (in this case what defines an amoeba)
This involved finding a way to represent an amoeba as a set of parameters. Just like the blueprint
for making humans is in our DNA we needed to find a suitable representation for our amoeba. We decided
that each ameoba can be represented simply by the number of masses it has and the distance between the centre
and one of the masses on the outer ring. These two numbers define what the amoeba looks like. The other 6 numbers
we need to include are the three settings for the wave (amplitude , phase , speed) and the three settings for
the environment (gravity , friction , springyness). they have to be included because they affect how well the ameobas moves.
We coded a class that takes in these parameters and creates an amoeba, giving back the XML string representation
that can be passed to the race app. this is similar to existing ameoba creators already out where you enter the
numbers and it gives you an amoeba in xml form. our representation allows us to easily breed (cross-over) an amoeba from two models
and also perform mutation. Cross-over involves taking two amoebas and randomly picking parameters from each. for example You may
take the number of masses from one amoeba and the radius the other amoeba. Once we have crossed-over all the parameters
we can create a new amoeba with our amoeba factory. This is step 4 of the algorithm below. step 5, the mutation simply
involves taking the parameters of an amoeba and randomly changing them by some amount. The mutation encourages
genetic variation and ensures that a wider range of amoebas are created.

Main algorithm steps:

with encoding of the chromosome out they way we can proceed with the main algorithm process which goes as follows.

1. create a population of 100 amoebas by passing random numbers into our amoeba factory class.
2. test the speed of all amoebas in the population saving the results.
3. Pick two amoebas with some selection method that favours better performing amoebas.
4. Cross-over the parameters of the amoebas.
5. Mutate the parameters.
6. Test the fitness of this amoeba and compare it to the population. If it is faster than any in the popultion
than add it in and throw out the slowest. Go to step 3.

This carries on until some condition is met, such as an amoeba of sufficient fitness has been produced or the fitness
of the best amoeba hasnt changed for the last 1000 iterations or so.

As you can see even with this simple example of creating amoebas there are a significant number of steps involved. As i
mentioned before we will be making a website to give proper explanations, and make our source code available to those
interested.

The fastest amoeba that our algorithm produced actually does this race in a mere 36 frames (see the race). But it "cheats". The algorithm
eventually learns that setting gravity and friction to close to zero the amoeba can "fly" across the screen without
touching the ground. i had to restrain the the parameters gravity and friction to minimum values so the amoebas always
use the terrain.

just to answer wwans questions:
The initial amoebas didnt even finish. They all timed out. It was through mutation that an amoeba that finished was produced.
first of which finished in about 2000 seconds i think.
The total number of amoebas tested was around the 50,000 mark (500 generations with a population of 100) at which point a memory leak in the race app caused it to crash. i believe they fixed one of these memory leaks but another still exists.


race: http://sodarace.net/upload/Chirag/superAmoeba.jnlp

TC23

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 20-Nov-03 17:09   »» 
Yes, I was wondering if your algorithms would exploit flaws in the applet like that one.

Blueyoshi321

»» models

Re: Ameobas created with a genetic algorithm   posted: 20-Nov-03 19:54   »» 
That's not really a flaw (I don't think so); it's just an amoeba with g=0 and some initial velocity. If you put some terrain, it bounces off and flies around pointlessly.

TC23

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 01:19   »» 
Yes, but you notice that its movement in the air was spearlike, how could it have gotten that? Certainly not by gyrating like it was in the race.

Chirag

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 10:25   »» 
The spear like motion was achieved by giving the amoeba a huge initial velocity. This happens when you set all the vx values (initial velocity) to some unnaturally high value. Normally this wouldnt happen because you cant directly change these values unless you mess around with the xml file by hand or through a program. It has the effect of giving a model a boost start and i found it normally cuts of a significant number of frames from a models finish time in a race. Though its not a flaw i would consider it cheating

wwan

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 10:42   »» 
Did you think about setting the vx and vy values to zero before you test your models on the racer? It seems to be the only way to really compare models.

Chirag

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 11:01   »» 
Yes i agree that would be the fairest approach. Effectively giving all models a standing start. Just a quick survey. How many other people out there are actually doing any AI modelling? I see that wwan has done some work in this area. Also are there any people interested in getting into this particular area of soda constructing but dont quite know how to go about it? We're thinking of doing some tutorials on the basics but it would be helpful to know how many people are interested. thx

Mattis

»» models

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 11:54   »» 
I'm intrested, but have no idea how to do it, and even basic computer programming escapes me.

Mattis

»» models

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 11:55   »» 
not that I ever tried to learn basic coputer proggramming.

wwan

»» models
»» homepage

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 13:00   »» 
For everybody beeing interested how to access the racer you may browse the wodka source code:
http://cvs.sourceforge.net/viewcvs.py/wodka/src/java/wodka/
I have also extracted a schema definition for soda model xmls. That can help you a lot to find errors before you send your models to the racer.

Actually wodka is open source and everybody can and should use it. In the future I plan to make wodka a plattform to run diffrent kinds of GAs.
If anybody has any ideas for new selection strategies or genotype representations of soda models or anything else, I would be pleased to hear/dicuss them.

file: http://sodarace.net/upload/wwan/soda.xsd

the_duck

»» models

Re: Ameobas created with a genetic algorithm   posted: 21-Nov-03 23:32   »» 
I'm interested in doing AI modelling but I don't know how to write a program to work with XML files. I have some programming experience and have an idea about how to implement a genetic algorithm but I would have no clue how to go about editing a models data.



This topic has 87 replies on 6 pages [ 1 2 3 4 5 6 | » ]


»» previous topic   »» next topic  

»» back to topic list  »» top of the page  

PLEASE READ THE FORUM GUIDELINES AND ALWAYS PREVIEW TO CHECK MESSAGES BEFORE POSTING...
...Help keep our forums creative and constructive. Thank you.


»» forum home