Problem with else/if statement
Though the for-loop problem has already been fixed, there is a problem with my model not calculating the happyRatio and hence stopping the step method when its conditions have been satisfied. Why is happyRatio and the else/if statement right before it not working? The debug statement "I'M FINALLY FREAKING WORKING NOW..." isn't working. And hasn't. For a long. long. time. Argh.
publicvoid step (){
System.out.printf("==> Swimmer step beginning" );
int moved = 0;// Has not yet moved this step
Vector swimmerNeighbors =new Vector();
Vector badNeighbors =new Vector();
System.out.printf("==> created variables in the step method");
vector = world.getMooreNeighbors(x, y,false);
//System.out.println(vector);
for (int i = 0; i < vector.size(); i++ ){
Object o = vector.get(i);
if (oinstanceof Swimmer){
swimmerNeighbors.add(o);
System.out.printf("==> swimmers getting added to list now");
}
elseif (oinstanceof Surfer){
badNeighbors.add(o);
System.out.printf("==> I'M FINALLY FREAKING WORKING NOW...);
}
}
//Is the Swimmer happy? ( >= 50% similarity)
//Empty and similar count as happy; dissimilar counts as unhappy;
double happyRatio = (8.0 - badNeighbors.size())/8.0;
if ( happyRatio > 0.5 ){//The Swimmer is happy; they end their move
System.out.printf("-- is happy right here!");
}
// Otherwise, the Swimmer is unhappy; they seek to move

