wolf eats what he must

This commit is contained in:
benoi 2024-05-30 11:12:27 +02:00
parent 7a79420cd1
commit 029166181c
1 changed files with 7 additions and 2 deletions

View File

@ -26,8 +26,13 @@ public class Wolf extends Agent {
* as you wish
*/
public boolean liveTurn(ArrayList<Agent> neighbors, Simulator world) {
if(world.getCell(x, y)== Sheep sheep) {
world.setCell(x, y, 0);
//ArrayList<Agent> nearby=world.getNeighboringAnimals(x,y,1); //look if the cell has an agent
if (!neighbors.isEmpty()) {
if(world.typeAnimals(x,y, neighbors)== "Sheep") {
Sheep sheep = new Sheep(x,y) ;
world.getAnimals().remove(sheep);
}
} else {
hunger++;
}