schrum2 / EvoCraft-SCOPE

0 stars 0 forks source link

Save parameter settings and load/resume #61

Closed schrum2 closed 2 years ago

schrum2 commented 2 years ago

MM-NEAT was configured so that the details of the save directory would also specify the location of a saved list of command line parameter values. The benefit of this was that there was a general way of loading any previously saved data simply by specifying the save directory. All other parameters would be loaded from the previously saved parameter list rather than needing to be accurately specified by the user.

Let's do something similar for this code.

If a BASE_DIR and EXPERIMENT_PREFIX are specified and a new parameter SAVE_PARAMETERS is True, then a file parameters.txt will be created in the save directory that contains all parameter settings. In the future, any attempt to execute code where the BASE_DIR and EXPERIMENT_PREFIX and RANDOM_SEED specify a parameters file that already exists will load the parameters from that file.

I want the contents of the parameters.txt file to be plaintext, easily readable by a human. This means we can't use pickle (even though that would be convenient). However, you also should not be hard-coding specifics of which command line parameters to save and load. We need some mechanism that processes all of the command line parameters in a loop, so that the code will still work as we add more command line parameters in the future.

alejmedinajr commented 2 years ago

I started adding things to main in order to load/save command line parameters because it makes sense to do that there. I successfully saved the command line parameters but am close to changing the values. I am thinking of using the split command from the file. There seems to be an issue with what I am doing. This is where I will most likely start tomorrow because I feel I am very close.

alejmedinajr commented 2 years ago

Now parameter settings can be loaded as well as saved. By default, if the parameters file exists at the location specified by BASE_DIR, EXPERIMENT_PREFIX, and RANDOM_SEED, then those preexisting command line parameters will be loaded.

alejmedinajr commented 2 years ago

There may be a potential issue since the parameters are not being updated after the first time they are saved. Maybe I should change the way the files are opened to allow rewriting.

schrum2 commented 2 years ago

Is it possible they can change? I think that anything loaded should be the same at any point later when you could possibly want to save it again ... but I could be wrong. This actually is not true in MM-NEAT (some parameters update their state), but I'm not sure if we're doing this in the Python code at all.