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
|
* as you wish
|
||||||
*/
|
*/
|
||||||
public boolean liveTurn(ArrayList<Agent> neighbors, Simulator world) {
|
public boolean liveTurn(ArrayList<Agent> neighbors, Simulator world) {
|
||||||
if(world.getCell(x, y)== Sheep sheep) {
|
//ArrayList<Agent> nearby=world.getNeighboringAnimals(x,y,1); //look if the cell has an agent
|
||||||
world.setCell(x, y, 0);
|
if (!neighbors.isEmpty()) {
|
||||||
|
if(world.typeAnimals(x,y, neighbors)== "Sheep") {
|
||||||
|
Sheep sheep = new Sheep(x,y) ;
|
||||||
|
world.getAnimals().remove(sheep);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
hunger++;
|
hunger++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue