Food based fitness 

Hey,

I've been trying to make a fitness function solely based on the food a
creature has eaten. So far what I've done is add 1 to user1 of a creature
everytime OnFoodCollision is called for the creature. However, I can't seem
to get this number into the fitness. I changed the fitness formula to
"return 0.0+this.user1" but that doesn't work. What can I do to make this
work?

Thanks in advance,

Horatio

Forums: 

> However, I can't seem
> to get this number into the fitness. I changed the fitness formula to
> "return 0.0+this.user1" but that doesn't work.

I have encountered the same problem. The thing is that you are updating the
user1-field on the Creature objects. This does not appear in the genepool
since this is filled with Genotype objects.

To solve your problem, simple add...

Genotype.user1 = Creature.user1;

...in your onKill function, just before the...

updatePerformanceWithPopSize();

And you can use your fitness function. Good luck!