startSimulation work for all size of world
This commit is contained in:
parent
61e6b7a42a
commit
fba8069874
|
|
@ -183,19 +183,25 @@ public class Simulator extends Thread {
|
|||
// to modify agent behavior, see liveTurn method
|
||||
// in agent classes
|
||||
|
||||
|
||||
ArrayList<Agent> newAgents = new ArrayList<>();
|
||||
for (int i = agents.size() - 1; i >= 0; i--) {
|
||||
Agent agent = agents.get(i);
|
||||
ArrayList<Agent> neighbors = this.getNeighboringAnimals(agent.getX(), agent.getY(), ANIMAL_AREA_RADIUS);
|
||||
if (!agent.liveTurn(neighbors, this)) {
|
||||
agents.remove(i);
|
||||
}
|
||||
}
|
||||
/*ArrayList<Agent> newAgents = new ArrayList<>();
|
||||
for(Agent agent : agents) {
|
||||
ArrayList<Agent> neighbors =
|
||||
this.getNeighboringAnimals(
|
||||
agent.getX(),
|
||||
agent.getY(),
|
||||
ANIMAL_AREA_RADIUS);}
|
||||
/*if(!agent.liveTurn(
|
||||
if(!agent.liveTurn(
|
||||
neighbors,
|
||||
this)) {
|
||||
agents.remove(agent);
|
||||
{*/
|
||||
}*/
|
||||
|
||||
|
||||
// Apply Game of Life rules
|
||||
|
|
@ -570,8 +576,10 @@ public class Simulator extends Thread {
|
|||
|
||||
|
||||
public void startSimulation() {
|
||||
if (isWorldEmpty()) {
|
||||
if (isWorldEmpty() & getWidth()==100 & getHeight()==100) {
|
||||
mjf.clicLoadFileButtonCSV("World/baseworld.csv");
|
||||
}else {
|
||||
mjf.generateRandomBoard();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue