wolf eats what he must
This commit is contained in:
parent
7a79420cd1
commit
029166181c
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue