getRule and loadRule

This commit is contained in:
yoyom 2024-05-14 15:05:15 +02:00
parent 4e024f0a74
commit f0330d5b59
1 changed files with 6 additions and 8 deletions

View File

@ -315,11 +315,10 @@ public class Simulator extends Thread {
}
public void loadRule(ArrayList<String> lines) {
if(lines.size()<=0) {
System.out.println("empty rule file");
return;
if (lines.size() < 4) {
System.out.println("Error: Insufficient number of lines for loading rules.");
return;
}
//TODO : remove previous rule (=emptying lists)
String surviveLine = lines.get(0);
@ -328,15 +327,14 @@ public class Simulator extends Thread {
for(int x=0; x<surviveElements.length;x++) {
String elem = surviveElements[x];
int value = Integer.parseInt(elem);
//TODO : add value to possible survive values
fieldSurviveValues.add(value);
}
String[] birthElements = birthLine.split(";");
for(int x=0; x<birthElements.length;x++) {
String elem = birthElements[x];
int value = Integer.parseInt(elem);
//TODO : add value to possible birth values
fieldBirthValues.add(value);
}
}