Get Rule done ig
This commit is contained in:
parent
c5e5feecca
commit
84d0a890b7
|
|
@ -301,6 +301,20 @@ public class Simulator extends Thread {
|
||||||
* @param chanceOfLife the chance for each cell
|
* @param chanceOfLife the chance for each cell
|
||||||
* to be alive in new state
|
* 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) {
|
public void generateRandom(float chanceOfLife) {
|
||||||
//TODO : complete method
|
//TODO : complete method
|
||||||
/*
|
/*
|
||||||
|
|
@ -348,12 +362,7 @@ public class Simulator extends Thread {
|
||||||
* @return File content as an ArrayList of Lines (String)
|
* @return File content as an ArrayList of Lines (String)
|
||||||
* @see loadRule for inverse process
|
* @see loadRule for inverse process
|
||||||
*/
|
*/
|
||||||
public ArrayList<String> getRule() {
|
|
||||||
//TODO : complete method with proper return
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadRule(ArrayList<String> lines) {
|
public void loadRule(ArrayList<String> lines) {
|
||||||
if(lines.size()<=0) {
|
if(lines.size()<=0) {
|
||||||
System.out.println("empty rule file");
|
System.out.println("empty rule file");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue