last comments

This commit is contained in:
Laure BEL 2024-05-31 21:31:15 +02:00
parent a8a6c556b7
commit 2755e9695b
1 changed files with 2 additions and 3 deletions

View File

@ -26,12 +26,11 @@ public class Wolf extends Agent {
* as you wish
*/
public boolean liveTurn(ArrayList<Agent> neighbors, Simulator world) {
//ArrayList<Agent> nearby=world.getNeighboringAnimals(x,y,1); //look if the cell has an agent
if (!neighbors.isEmpty()) {
if (!neighbors.isEmpty()) { //checks if the adjacent cells are empty ; if it's a sheep, it makes another sheep appear and delete it, which makes both disappear
if(world.typeAnimals(x,y, neighbors)== "Sheep") {
Sheep sheep = new Sheep(x,y) ;
world.getAnimals().remove(sheep);
hunger=hunger-1;
hunger=hunger-1;
}else {
hunger++;
}