Problem with Load World / Agent...

This commit is contained in:
paull 2024-05-27 16:54:58 +02:00
parent da3a5d5948
commit 7c681d1dfd
1 changed files with 14 additions and 3 deletions

View File

@ -257,14 +257,25 @@ public class Simulator extends Thread {
}
public ArrayList<String> getAgentsSave() {
// TODO: Same idea as the other save method, but for agents
return null;
ArrayList<String> saveState = new ArrayList<>();
for (Agent agent : agents) {
saveState.add(agent.toString());
}
return saveState;
}
public void loadAgents(ArrayList<String> stringArray) {
// TODO: Same idea as other load methods, but for agent list
agents.clear();
for (String line : stringArray) {
// Assuming Agent class has a static method fromString to parse agent information
Agent agent = Agent.fromString(line);
if (agent != null) {
agents.add(agent);
}
}
}
public String clickActionName() {
return clickActionFlag ? "sheep" : "cell";
}