[pio-develop] Passing a particular chromosome to genetic AI
Rodrigo Espiga Gómez <rodrigoespiga <at> hotmail.com>
2014-03-17 18:46:56 GMT
Hi Roland and others!
Genetic AI is working right now, given the testing chromosome that is harcoded inside it. And now it's when fun part comes: evolution. But in order to evolve the algorithm I need to run hundreds of games, generation after generation, using different chromosomes, and I need genetic to use a given chromosome when is called.
To give you an idea of the process from now on it would be like this (at least fundamentally, numbers may vary, and the exact methods have yet to be decided):
1- A set of 100 randomized chromosomes are generated.
2- 100 games (with one genetic and three greedy players) are launched, each genetic player using one of those chromosomes.
3- Outcome (victory points) of every genetic player is recorded along with its chromosome (and probably other information for statistical purposes).
4- Each player (chromosome) has a probability of being selected for the next generation that depends on its fitness (victory points) in the previous generation.
5- 100 selections of one chromosome are done, based on those probabilities (some chromosomes could be selected more than once, others none).
6- Selected chromosomes are crossed in pairs, crossbreeding their genetic information, and their offspring are inserted in a new generation (some chromosomes could passed to the next generation unmodified, that depends on the method used).
7- With this new generation of 100 chromosomes, we go back to step 2 a repeat the whole process.
This sequence of steps is repeated until certain stop condition is met (usually depending on the concurrency of the chromosomes), or a maximum number of generations is run (about 500). This method will presumibly yield an optimal chromosome whose fitness has been proved after generations. This method can be reproduced for any given game configuration so it could learn for example that one resource is more important than other in certain type of game, or that ports are more valuable in other, etc.
So I need genetic to use different chromosomes.
The best way would be having the chromosome information on an external file that would be passed to pioneersai as an argument. That way I could evolve a "universal" chromosome that could be passed to any game, and specific chromosomes to be passed for specific games as well (like Ubuntuland, and the like. Genetic would then use the "generic" chromosome (hardcoded inside it) if no one else was given. Otherwise, it would use the values inside that file (that could be just a plain text file). However, this approach needs some modification to the way pioneersai works, so it accepts this chromosome file as part of the options when genetic is passed as the AI.
Another approach to avoid any modification to pioneersai is having all the chromosomes of one generation on a single file (my plan is to have generations of 100 chromosomes/players). Genetic would then take the information from that file and would take the chromosome inside that file that corresponds to its name inside the generation (assuming its name can be associated with a given chromosome inside the chromosomes file, naming each player, e.g., Genetic1, Genetic2, and the like). After a whole generation is run, this file would be modified to hold the new chromosomes, and would be used by the next generation run. That way there is no need to specify a chromosome file cause all the chromosomes are in the same file. Once the evolution has concluded, I would eliminate any reference to that file and hardcode that winning chromosome inside genetic.c.
The drawback of this method is that is very rigid, and lacks all the possibilities of passing different chromosomes for different games, or even giving the user the possibility of passing its own chromosomes, that the first method does have.
Which one do you think is better?
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
Pio-develop mailing list
Pio-develop <at> lists.sourceforge.net