Advertisemen
In my final year project the aim is to adapt life forms to an environment using Genetic Algorithms. For around 1.5 months I've been really puzzled - my life forms were only ever evolving to move in a straight line, when there were functions implemented to allow it to turn left and right. While the objective was accomplished - they were evolving to pick up more food. Sadly, life forms which move in a straight line would look pretty crap in a demonstration of my project. My LifeForm class has a field 'angle' which represents the angle it faces.
public class LifeForm {
private int angle;
}
Turns out my LifeForm.turnLeft() was:
public void turnLeft(int angle) {
angle += angle;
}Changing it to:public void turnLeft(int angle) {
this.angle += angle;
}(Obviously) fixes everything. FUCK. 5 letters. ADDING FIVE LETTERS KILLED THE BUG. I'VE BEEN PANICKING ABOUT THIS FOR SO LONG
















Advertisemen
Tidak ada komentar:
Posting Komentar