You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
878 B
36 lines
878 B
package model;
|
|
|
|
public class ArbitreConwayStyle extends Arbitre{
|
|
|
|
public ArbitreConwayStyle(Plateau plateau) {
|
|
super(plateau);
|
|
}
|
|
|
|
@Override
|
|
public CellState VerifierChangementCellules(int x, int y) {
|
|
if(verifierNaissance(x, y)) {
|
|
return CellState.BIRTH;
|
|
}
|
|
if(verifierMort(x, y)) {
|
|
return CellState.DIE;
|
|
}
|
|
return getPlateau().getCell(x, y).estAlive() ? CellState.LIVE : CellState.DIE;
|
|
}
|
|
|
|
private boolean verifierNaissance(int x, int y) {
|
|
int cpt = getCompteurCell().compteNombreCellulesAutour(x, y, getPlateau());
|
|
if(cpt == 3 && !getPlateau().getCell(x, y).estAlive()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private boolean verifierMort(int x, int y) {
|
|
int cpt = getCompteurCell().compteNombreCellulesAutour(x, y, getPlateau());
|
|
if(!(cpt == 2 || cpt == 3) && getPlateau().getCell(x, y).estAlive()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|