posted 9 years ago
hi Jesse,
I just had a look at your code. It looks rather weird in places, but I did not spot any
obvious error.
What I did notice however, is that when you move a herbivore, then the x and y are
changed by 0.000001, if I'm right. Now, on a area size of 1000 x 1000 that isn't much.
It would take many redraws to let a herbivore move only one pixel. Am I correct on this one?
(because there's also scaling going on, but I could not quite follow it).
Another thing I noticed is that you test whether a herbivore is 'on a plant' by comparing
doubles with '=='. Now, that is notoriously unreliable!
I see a strange thing in your 'main' method. First you create 20 herbivores, then
you remove the first 10 again. What's the meaning of that?
But my main question is: what testing have you done so far? Did you check, after each update,
if the herbivores moved correctly, for instance? That a 'nearest plant' was indeed found? And if
so, did you set the instance members correct?
Start with only one herbivore, for testing purposes, like Guillermo suggested. Make sure to
start without any plants, then with one plant that is within distance of the herbivore, et cetera.
Let us know what your findings are.
Greetz,
Piet
There are three kinds of actuaries: those who can count, and those who can't.