last comments
This commit is contained in:
parent
a8a6c556b7
commit
2755e9695b
|
|
@ -26,12 +26,11 @@ 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) {
|
||||||
//ArrayList<Agent> nearby=world.getNeighboringAnimals(x,y,1); //look if the cell has an agent
|
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 (!neighbors.isEmpty()) {
|
|
||||||
if(world.typeAnimals(x,y, neighbors)== "Sheep") {
|
if(world.typeAnimals(x,y, neighbors)== "Sheep") {
|
||||||
Sheep sheep = new Sheep(x,y) ;
|
Sheep sheep = new Sheep(x,y) ;
|
||||||
world.getAnimals().remove(sheep);
|
world.getAnimals().remove(sheep);
|
||||||
hunger=hunger-1;
|
hunger=hunger-1;
|
||||||
}else {
|
}else {
|
||||||
hunger++;
|
hunger++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue