Loading & Saving

No simulation program would be complete without the ability to save and re-load the world state at a later date. So it is with Evagents! With the click of two buttons and some typing, you can save and reload any previously saved world file (or load one shared to you by someone else!) and have the program load it up.

The files are saved in the "saves" folder, in a unique format for Evagents, with file extensions ending with ".SAV". The file structure is similar of XML markup, but it is not literally XML. If you open one up in a text editor like Notepad++, it will be organized with tags and named variables which you can manipulate outside the simulation. Do this at your own risk however; I cannot guarantee that invalid numbers are ignored!

Other than that disclaimer however, feel free to add as many new lines, comments or just random letters and number junk as you'd like; Evagents only reads lines which it is looking for and loads information it can indeed read as input, and will not crash if it finds something unexpected; it just doesn't read it! No need to be strict when you can design the file reader to accept human error as part of the experience! (this same logic applies to the Config File loading, by the way!)


After pressing the save button, the World pauses and a prompt appears asking for file name. Note that you do not have to enter an extension; that is managed by the program.


After a brief moment of delay, your simulation will resume. Please note this delay is proportional to the number of agents in the save, so it may take some time.


Loading is a similar process. After pausing the current world (which WILL be lost if loading is not cancelled and is successful!), the program checks for the filename provided and, if found, loads the simulation piece by piece. If you've enabled Autosaves in the GUI, then you can input "AUTOSAVE" to restore the last saved scene from that run (NOTE: Enable Autosaves will not be on by default when you do this; you have to manually re-enable it because it will overwrite the last autosave. I may change the default behavior at a later date or upon request.)

IMPORTANT NOTE: If you load a filename which was saved in an older version of Evagents, I cannot guarantee it will load properly! In some scenarios it will work as expected, and this would mainly be due to no new features with agents or their brains. Every effort will be made to preserve the world and its settings, but any new functions or features of either agents or the world will have Default Init Values! This means, for example, if a new inheritable trait was introduced, agents will load, but this trait will be set according to the spawn rules of new agents. (for technical details, see bottom of this page)



TECHNICAL DETAILS!

So you want to know the nitty-gritty of the saving and loading function? Alright, you asked for it!

When a file is loaded, it checks for the "<world>" flag, and, if found, creates a new world, immediately overwriting the old one. However, this new world is not passed through the spawn code. It is a completely blank slate - no cell values, no agents, just config variables (the ones from the config file).

First, if we had any settings saved with this world that effects how the Agents behave (such as Moonlight or number of Brain Boxes), it was saved will be re-loaded with the save's settings. This is because these settings can have far-reaching implications if the values don't match the data in the rest of the save!

Next, the file lists cell values. ALL of them. If you looked at the structure, you may have noticed not every cell coordinate has data for every layer; this is intentional as we already initialized the world with 0 value in every cell, so we skipped saving any layers with value= 0. Smart!

Next, the file contains an "<a>" flag. This signals the creation of an agent. The agent is completely random, like a fresh spawn. If this line in the save is immediately followed by an "</a>" flag and then the end of the file, then you would find a single random soul had spawned into the world (provided Closed World was enabled!)

Then, as the file loading encounters flags for agent traits, each one is read, and the value input into the respective datum of the random agent. Thus, if the saved data is missing ANYTHING, like a new trait introduced in the newer version of the program you may be running, or, dare I say, a manual removal of traits from the save file, the program will not give up loading. It will instead create random values like a randomly spawned agent.

... unfortunately, I was hyper-efficient with memory usage. Any subsequent agent loaded which is ALSO missing the same flag(s) will have the SAME randomly generated values. I am uncertain if this is a bug or a feature... but in most cases, if you're loading an agent you saved from the same version, it should load with all the traits and values it needs. Loading agents from older versions is only partially supported in most cases. See the "Loading and Saving" sections of the change logs to get an idea of what's possible.

Once an "</a>" flag is met, the program commits the agent structure to the world, and it gets added as a real agent, regardless of if it loaded all traits or not if it did not, and it will use, as mentioned above, the previous loaded value, or in lieu of that, some init value.

The same situation applies to the brain of each agent. Any trait; weight, bias, dampening, etc, not listed for a given box ID is just initialized as a spawn variable. If the brain data is missing completely, a new random one has already been created.