views:

104

answers:

2

I'm still hacking on my old ruby for the undead post (I know, I know, stop trying to bring the post back from the dead Chuck). But the code has gotten a little out of hand and now I'm working on a genetic algorithm to create the ultimate battle of living and dead with the fitness being how long the battle lasts.

So, I've got the basics of it down; how to adjust attributes of the game and how to acquire the fitness of a solution, what I can't figure out is how to store the fitness so that I know when I've tried a combination before.

I've not been able to find much genetic code to look at let alone code that I can read well enough to tell what's going on. Does anyone have an idea how this is normally done or just simply an algorithm that could help point me in the right direction?

+1  A: 

what I can't figure out is how to store the fitness so that I know when I've tried a combination before.

Normally in a GA solution you are not concerned about generating the same "solution" what you are concerned about is when the rate of improvement in your 'score' stabilises.

Now if your wanting to log/track the "solution" history you many want to know when it reappears latter, but I assume there is some random nature to your "game" therefore you would want object to repeat runs.

Simeon Pilgrim
Oh that's a good point, there is randomness so I do want it to repeat.
Chuck Vose
+1  A: 

In a GA you don't want to reevaluate a solution if the fitness test takes a long time. Use a hash table to store your fitness scores and make the hash key the chromosome. Use the "Orcish Maneuver"; check the cache first, if it is there retrieve it and continue, else compute it and put it in the hash for next time.

Ryan
Thanks, I was wondering if this was a viable method. Fitness is indeed a long computation since in this case it's based on how long the 'game' lasts. So the most fit is the one that runs forever.
Chuck Vose