I understand that there are many answers to this question but I'm still having difficulty with this. I understand the idea of A > B, B > C, so A > C and I believe that what I'm doing is capable of working perfectly fine.
public int compareTo(Snake snake) {
double other=snake.testFitness();
double tFit = this.testFitness();
if(tFit < other)
return 1;
else if(tFit > other)
return -1;
else
return 0;
}
I don't understand how something so simple is able to violate the general contract.
Edit: For those asking for the testFitness() function.
public double testFitness() {
fit += ((this.length - 3)*2);
fit -= this.blocksTraveled*3;
return fit;
}