modified getRule
This commit is contained in:
parent
cd5f987b97
commit
75e9fad8d6
|
|
@ -26,50 +26,39 @@ public class Rules {
|
|||
}
|
||||
|
||||
public void loadRule(ArrayList<String> row) {
|
||||
String surviveRulesRow = row.get(0);
|
||||
String[] surviveCells = surviveRulesRow.split(";");
|
||||
String birthRulesRow = row.get(1);
|
||||
String[] birthCells = birthRulesRow.split(";");
|
||||
survivalRulesArray = new int[surviveCells.length];
|
||||
birthRulesArray = new int[birthCells.length];
|
||||
//initialize my arrays with the correct length
|
||||
|
||||
if (row.size() <= 0) {
|
||||
System.out.println("wrong file buddy, this one's empty");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
String surviveRulesRow = row.get(0);
|
||||
String[] surviveCells = surviveRulesRow.split(";");
|
||||
if(surviveCells.length<=0) {
|
||||
}else if (surviveCells.length<=0) {
|
||||
System.out.println("wrong file buddy, this one's does not have survival rules, won't work");
|
||||
return;
|
||||
}
|
||||
|
||||
String birthRulesRow = row.get(1);
|
||||
String[] birthCells = birthRulesRow.split(";");
|
||||
|
||||
//places the values of our rules CSV file in the right category, as survival or birth rules
|
||||
|
||||
|
||||
|
||||
survivalRulesArray = new int[surviveCells.length];
|
||||
birthRulesArray = new int[birthCells.length];
|
||||
//initialize my arrays with the correct length
|
||||
|
||||
for (int x = 0; x < birthCells.length; x++) {
|
||||
String elem = surviveCells[x];
|
||||
int value = Integer.parseInt(elem);
|
||||
}
|
||||
//determines the number of alive neighboring cells needed to birth, and places them in the neededNb list
|
||||
|
||||
|
||||
for (int x = 0; x < surviveCells.length; x++) {
|
||||
String elem = surviveCells[x];
|
||||
int value = Integer.parseInt(elem);
|
||||
survivalRulesArray[x] = value;
|
||||
}
|
||||
}else {
|
||||
for (int x = 0; x < surviveCells.length; x++) {
|
||||
String elem = surviveCells[x];
|
||||
int value = Integer.parseInt(elem);
|
||||
survivalRulesArray[x] = value;
|
||||
}
|
||||
//determines the number of alive neighboring cells needed to survive, and places them in the survivalRulesArray
|
||||
|
||||
for (int x = 0; x < birthCells.length; x++) {
|
||||
String elem = birthCells[x];
|
||||
int value = Integer.parseInt(elem);
|
||||
birthRulesArray[x] = value;
|
||||
for (int x = 0; x < birthCells.length; x++) {
|
||||
String elem = birthCells[x];
|
||||
int value = Integer.parseInt(elem);
|
||||
birthRulesArray[x] = value;
|
||||
}
|
||||
//determines the number of alive neighboring cells needed to birth, and places them in the birthRules list
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue