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) {Changing it to:
angle += angle;
}
public void turnLeft(int angle) {(Obviously) fixes everything. FUCK. 5 letters. ADDING FIVE LETTERS KILLED THE BUG. I'VE BEEN PANICKING ABOUT THIS FOR SO LONG
this.angle += angle;
}
tps://1-media-cdn.foolz.us/ffuuka/board/vp/image/1374/65/1374653239331.jpg" class="decoded" src="https://1-media-cdn.foolz.us/ffuuka/board/vp/image/1374/65/1374653239331.jpg">
































Advertisemen
Tidak ada komentar:
Posting Komentar