get rule finally

This commit is contained in:
benoi 2024-05-27 13:18:05 +02:00
parent 5bda7e3619
commit 63ea7a1b4d
1 changed files with 14 additions and 1 deletions

View File

@ -301,7 +301,20 @@ public class Simulator extends Thread {
* @param chanceOfLife the chance for each cell
* to be alive in new state
*/
public ArrayList<String> getRule() { //to check
ArrayList<String> rule = new ArrayList<>();
for (int i = 0; i < getHeight(); i++) {
StringBuilder lineState = new StringBuilder();
for (int j = 0 ; j < getHeight() ; j++) {
lineState.append(getCell(i, j));
if (j < getWidth() - 1) {
lineState.append(";");
}
}
rule.add(lineState.toString());
}
return rule;
}
public void generateRandom(float chanceOfLife) {
/*
* Advice :