



















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















































Techniques
// try to move this rabbit Location newLoc = updatedField.freeAdjLoc(location); // find a new location if (newLoc != null) { // if new location is free setLocation(newLoc); updatedField.place(this, newLoc); } else // can't move - so die due to overcrowding isAlive = false; }
} // end of act()
public void act (Field currentField, Field updatedField, List
// try to move this fox Location newLoc = findFood(currentField, location); if (newLoc == null) // if no food found then move randomly newLoc = updatedField.freeAdjLoc(location);
if (newLoc != null) { // if new location is free setLocation(newLoc); updatedField.place(this, newLoc); } else // can't move - so die due to overcrowding isAlive = false; }
} // end of act()