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