agents now makestep
This commit is contained in:
parent
e1a3b96e04
commit
cafe8800eb
|
|
@ -38,7 +38,7 @@ public class Sheep extends Agent {
|
||||||
hunger++;
|
hunger++;
|
||||||
}
|
}
|
||||||
this.moveRandom();
|
this.moveRandom();
|
||||||
return hunger>10;
|
return hunger<10; //condition to be alive
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveRandom() {
|
private void moveRandom() {
|
||||||
|
|
|
||||||
|
|
@ -122,17 +122,19 @@ public class Simulator extends Thread {
|
||||||
// only modify if sure of what you do
|
// only modify if sure of what you do
|
||||||
// to modify agent behavior, see liveTurn method
|
// to modify agent behavior, see liveTurn method
|
||||||
// in agent classes
|
// in agent classes
|
||||||
for(Agent agent : agents) {
|
/*for(Agent agent : agents) {
|
||||||
ArrayList<Agent> neighbors =
|
ArrayList<Agent> neighbors =
|
||||||
this.getNeighboringAnimals(
|
this.getNeighboringAnimals(agent.getX(), agent.getY(), ANIMAL_AREA_RADIUS);
|
||||||
agent.getX(),
|
if(!agent.liveTurn(neighbors,this)) {
|
||||||
agent.getY(),
|
|
||||||
ANIMAL_AREA_RADIUS);
|
|
||||||
if(!agent.liveTurn(
|
|
||||||
neighbors,
|
|
||||||
this)) {
|
|
||||||
agents.remove(agent);
|
agents.remove(agent);
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
for(int i=0; i<agents.size(); i++){
|
||||||
|
ArrayList<Agent> neighbors = this.getNeighboringAnimals(agents.get(i).getX(), agents.get(i).getY(), ANIMAL_AREA_RADIUS);
|
||||||
|
if(!agents.get(i).liveTurn(neighbors,this)) {
|
||||||
|
agents.remove(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//then evolution of the field
|
//then evolution of the field
|
||||||
//TODO-INPROGRESS : apply game rule to all cells of the field
|
//TODO-INPROGRESS : apply game rule to all cells of the field
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ public class Table {
|
||||||
private ArrayList<ArrayList<Cell>> table;
|
private ArrayList<ArrayList<Cell>> table;
|
||||||
private Simulator simulator;
|
private Simulator simulator;
|
||||||
|
|
||||||
//TODO-INPROGRESS : create constructor
|
//TODO-COMPLETE : create constructor
|
||||||
public Table(int height, int width, Simulator tempSimulator) {
|
public Table(int height, int width, Simulator tempSimulator) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue