Merge remote-tracking branch 'origin/dev_bnb'

This commit is contained in:
Guillaume BONABAU 2024-05-29 13:56:13 +02:00
commit 2b913f1386
3 changed files with 12 additions and 10 deletions

View File

@ -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() {

View File

@ -120,17 +120,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

View File

@ -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;