fixing merge errors
This commit is contained in:
parent
7c4b0bc3b4
commit
0d3c62f142
|
|
@ -48,7 +48,7 @@ public class Simulator extends Thread {
|
||||||
this.width=COL_NUM;
|
this.width=COL_NUM;
|
||||||
this.height=LINE_NUM;
|
this.height=LINE_NUM;
|
||||||
enableLogs = true; // for debugging purposes
|
enableLogs = true; // for debugging purposes
|
||||||
table = new Table(height, width);
|
table = new Table(height, width, this);
|
||||||
|
|
||||||
|
|
||||||
//Default rule : Survive always, birth never
|
//Default rule : Survive always, birth never
|
||||||
|
|
@ -114,7 +114,7 @@ public class Simulator extends Thread {
|
||||||
}
|
}
|
||||||
//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
|
||||||
Table tempTable = new Table(this.height, this.width);
|
Table tempTable = new Table(this.height, this.width, this);
|
||||||
for(int x=0; x<width; x++) {
|
for(int x=0; x<width; x++) {
|
||||||
for(int y=0; y<height; y++) {
|
for(int y=0; y<height; y++) {
|
||||||
if (table.getCell(x, y).getValue()==1) {
|
if (table.getCell(x, y).getValue()==1) {
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,11 @@ public class Table {
|
||||||
private ArrayList<ArrayList<Cell>> table;
|
private ArrayList<ArrayList<Cell>> table;
|
||||||
private Simulator simulator;
|
private Simulator simulator;
|
||||||
|
|
||||||
|
|
||||||
//TODO-INPROGRESS : create constructor
|
//TODO-INPROGRESS : create constructor
|
||||||
public Table(int height, int width) {
|
public Table(int height, int width, Simulator tempSimulator) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.simulator = simulator;
|
this.simulator = tempSimulator;
|
||||||
|
|
||||||
|
|
||||||
//initialize the table
|
//initialize the table
|
||||||
int vertexCount = 3;
|
int vertexCount = 3;
|
||||||
|
|
@ -28,16 +26,35 @@ public class Table {
|
||||||
public int getwidth() {
|
public int getwidth() {
|
||||||
return this.width;
|
return this.width;
|
||||||
}
|
}
|
||||||
|
public boolean isLoopingBorder() {
|
||||||
|
return simulator.isLoopingBorder();
|
||||||
|
}
|
||||||
|
|
||||||
//TODO-COMPLETE : create getCell
|
//TODO-COMPLETE : create getCell
|
||||||
public Cell getCell(int x,int y) {
|
public Cell getCell(int x,int y) {
|
||||||
//return the Cell object of coordinates x, y
|
//return the Cell object of coordinates x, y
|
||||||
return table.get(x).get(y);
|
return table.get(x).get(y);
|
||||||
}
|
}
|
||||||
//TODO : set(Cell, x, y) set an object Cell to coordinate x, y
|
//TODO-complete : set(Cell, x, y) set an object Cell to coordinate x, y
|
||||||
|
public void setCell(Cell cell, int x, int y){
|
||||||
//TODO : count around (xy) -> return how many around this cell
|
this.table.get(x).set(y,cell);
|
||||||
|
}
|
||||||
|
//TODO-complete : count near (xy) -> return how many cells around this cell
|
||||||
|
public int countNear(int x, int y){
|
||||||
|
int cellCount =0;
|
||||||
|
// if border is true
|
||||||
|
for (int i = x-1;i<=x+1;i++){
|
||||||
|
for (int j = y-1;j<=y+1;y++){
|
||||||
|
if (!(i == j)){
|
||||||
|
cellCount += this.getCell(i,j).getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return cellCount;
|
||||||
|
//if border is false
|
||||||
|
|
||||||
|
}
|
||||||
//TODO : set agent (x y agent) load an agent to coordinates x,y
|
//TODO : set agent (x y agent) load an agent to coordinates x,y
|
||||||
|
|
||||||
//TODO : set random (density) create a random table of determined density
|
//TODO : set random (density) create a random table of determined density
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue