Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Problem in simple evolution simulator..

1. ## Problem in simple evolution simulator..

Hello,
I am creating a very simple evolution simulator in Processing.
It is a simple game where you must move the player around some terrain (circles that I call rocks).
There are 50 randomly generated creatures (brains) that each try to play this game.
At the end of a generation (50 creatures), half of the creatures (the worst performing ones) are killed off and the other half each get one slightly randomized offspring.
Here is the problem :
Sometimes, the best creature gets worse from one generation to the other. I don't know if it's getting randomized or getting killed, but I do know it shouldn't happen.
I've been trying to fix this, for days and I haven't found any solution!

2. ## Re: Problem in simple evolution simulator..

How are you trying to debug the code to understand why it works like it does?

3. ## Re: Problem in simple evolution simulator..

The "creatures" try to go to the top right of the screen.
They are sorted based on the distance from the top right.

Every step of the sort, I output in the console each creature's distance. So it would look like this, but with more numbers.
980, 560, 320, 1080
560, 320, 980, 1080
320, 560, 980, 1080

How ever, in the next generation, for some reason there is a chance the 320 would be gone and the 560 takes it's place..

4. ## Re: Problem in simple evolution simulator..

the 320 would be gone and the 560 takes it's place
Can you add some debug code to print out when that happens and why it happens?

5. ## Re: Problem in simple evolution simulator..

That's what I'm trying to find out!
What is making the best creature worst/die?