Saving the whole sim is unfortunately well and truly broken right now.
The reason for this is that we keep changing robot structures in the code and each time we do so it upsets the numerical order of the save file. [...]
It would be kind of pointless to fix the save feature right now because the first change we make to the robot definitions will just kill it again.
That's an old problem, and I think it needs to be solved rapidly: saving sims it's really important, and you can't go on without this feature.
I suggest to change once for all the simulation file structure this way (and the same should be made for organism files). The idea is to create a tag system: that is, divide simulation files in parts (should be called chunks) with a fixed structure and a tag identifying them. For example:
[[gravity]] value [[brownian]] value ... etc. etc.
There could be a tag hyerarchy: for instance:
[[robot]]
[[mutval1]] value [[mutval2]] value ...
[[dna]] plain dna file here... [[/dna]]
.....
[[/robot]]
[[robot]]
.....
[[/robot]]
etc. Much like HTML. (That's just an idea, you dont' actually have to use precisely this kind of tags... ). Or maybe (I just have a vague idea about it, but maybe it's exactly what we need here) XML.
When files are loaded, the program simply searches for the tags he's interested in, and ignores the others. So you can keep modifying everything, adding new variables, for instance, to the physical environment, or even adding a whole new chunk specifying the definition of an envgrid, and the program will still be able to load old simulation files without problems. And even older versions will be able to load newer simulation files, just without providing the new features, in case they are used. For example, say that tomorrow you decide to save the shape of a robot also (circle, square, triangle, etc.). You can just add a tag [[shape]] inside the robot definition, and older versions will simply ignore it.
Ok, maybe it looks complicated, but it's not. Once you've written down a few routines to manage tags (search tag, search tag end, get tag value... and so on) the rest is straightforward, and the problem of loading/saving (both simulations, organisms, and whatever) is solved once for all.